getsourcecode action returns them for any address, so you can read a contract’s code, pull its ABI to build a call, or check whether an address is verified at all. It is the read counterpart to verifying a contract.
New to the API? Start with Make your first call.
Get the source code
1
Make the request
Send a
GET to the getsourcecode action with the contract address. The example reads the USDT contract on Ethereum.2
Read the response
The
result is an array with a single object. For a verified contract, it carries the source and the exact settings it was compiled with.Check whether a contract is verified
For an unverified address, the call still returnsstatus 1, but the ABI field reads Contract source code not verified and SourceCode is empty. Check that field before trying to use the source or ABI.
Get just the ABI
When you only need the ABI to build a call, usegetabi instead. It returns the ABI JSON directly, without the surrounding source and settings.