Contract ABIs
Base Url: api.decentscan.xyz
Endpoint: /utils/getContractAbi
One of the most painful processes in configuring transactions is fetching the target contract's ABI so that you can accurately call its functions. Rather than scraping through block explorers or Github repositories, Decent provides a simple endpoint to return the ABI for any verified smart contract on any chain that Decent supports.
This endpoint accurately handles proxy contracts and returns the signature for all public functions on a contract. For example, rather than scraping through an NFT contract to find the mint methods, just hit this endpoint to return the ABI, filter for methods of type function
, and search for one called mint
.
Query Parameters
Parameter | Description | Type | Required | Default |
---|---|---|---|---|
chainId | Chain ID of the target contract. | ChainId | true | Not available. |
contractAddress | Address of the target contract. | 0x${string} | true | Not available. |
Sample Request
const queryParams = new URLSearchParams({
chainId: 10,
contractAddress: '0xa9de16b1484C11b481B23dbdEC534a29F5668a22'
});
const options = { method: 'GET', headers: { 'x-api-key': `${process.env.DECENT_API_KEY}` }}
fetch(`https://api.decentscan.xyz/utils/getContractAbi?{queryParams}`, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Response Schema
This API endpoint returns the full ABI for a contract. See more about ABI types here.
[{
inputs: Array,
name: string,
type: string,
outputs?: Array
}]