import { useState , useEffect } from 'react' ; const cmcEndpoint = 'https://3rdparty-apis.coinmarketcap.com/v1/cryptocurrency/contract?address=' ; const cmcAssetUrl = 'https://coinmarketcap.com/currencies/' ; param address export function useCMCLink ( address ) { const [ link , setLink ] = useState < string | undefined > ( undefined ) ; useEffect ( ( ) => { async function fetchLink ( ) { const result = await fetch ( cmcEndpoint + address ) ; if ( result . status === 200 ) { result . json ( ) . then ( ( { data } ) => { setLink ( data . url ) ; } ) ; } } if ( address ) { fetchLink ( ) ; } } , [ address ] ) ; return link ; }