ABI Data

Fetch smart contract ABI JSON from Etherscan to use with wagmi and ethers.js in your app.

How do I use this API?

Append the contract address after abidata.net, that’s it. You don’t need any API keys.

Example:

abidata.net/0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413abidata.net/0x9a879320A9F7ad2BBb02063d67baF5551D6BD8B0?network=goerli
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 import { useState, useEffect } from 'react'; import { useContractWrite, usePrepareContractWrite } from 'wagmi'; const contractAddress = "0xecb504d39723b0be0e3a9aa33d646642d1051ee1"; const useContractABI = (contractAddress) => { const [contractABI, setContractABI] = useState(null); useEffect(() => { const fetchContractABI = async () => { const response = await fetch(`https://abidata.net/${contractAddress}`); const json = await response.json(); setContractABI(json.abi); }; fetchContractABI(); }, [contractAddress]); return contractABI; }; function App() { const contractABI = useContractABI(contractAddress); const { config } = usePrepareContractWrite({ address: contractAddress, abi: contractABI, functionName: 'feed', }); const { data, isLoading, isSuccess, write } = useContractWrite(config); return ( <div> <button disabled={!write} onClick={() => write?.()}> Feed </button> {isLoading && <div>Check Wallet</div>} {isSuccess && <div>Transaction: {JSON.stringify(data)}</div>} </div> ) }

Is this free to use?

Yes, it’s free for everyone.

If you wanna support this project send some eth to ens.pug.eth

Can this be used in production?

Yes. Records are cached for 365 days, so after the initial request for a contract, the API will respond very quickly from the CDN.

Which networks are supported?

Ethereum Mainnet and Goerli Testnet are supported right now. You can append ?network=goerli to the URL to fetch ABI for a Goerli contract.

Example:

abidata.net/0x9a879320A9F7ad2BBb02063d67baF5551D6BD8B0?network=goerli

Is the source code available?

Yes, check it out on GitHub. The main branch is automatically deployed to Vercel.