Skip to main content

ABIs

Application Binary Interfaces (ABIs) are JSON representations of a contract's functions and events. They enable interaction with the contract on the blockchain by providing the necessary information to encode and decode the data involved in these interactions. ABIs should be stored in the /abis/ directory of your project and imported into your handler functions as needed.

Example ABI

export const ERC20Abi = [
{"name":"symbol","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},
{"name":"name","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},
{"name":"balanceOf","constant":true,"inputs":[{"name":"_owner","type":"address"}],"outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},
{"name":"totalSupply","constant":true,"inputs":[],"outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},
{"name":"transferFrom","constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},
{"name":"approve","constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},
{"name":"decimals","constant":true,"inputs":[],"outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},
{"name":"transfer","constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},
{"name":"Transfer","anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"}, {"indexed":false,"name":"value","type":"uint256"}],,"type":"event"}
] as const; // must add `as const` to get full typings