Skip to Content
Playground@contracts · ABIs

Contract ABIs

@cfxdevkit/contracts ships ABI constants, deployment bytecodes and on-chain addresses for all DevKit contracts — everything you need to read, write, and deploy without writing raw ABI JSON.

network:Testnet· chain 71
import {
erc20Abi, erc721Abi, erc1155Abi,
erc20BaseAbi, erc20BaseBytecode,
automationManagerAbi, automationManagerAddress,
} from '@cfxdevkit/contracts'
import { EspaceClient, EVM_TESTNET, formatUnits } from '@cfxdevkit/core'

// 1. Standard ABIs shipped with the package
console.log('-- Standard ABIs --')
console.log('ERC-20   : ' + erc20Abi.length + ' entries')
console.log('ERC-721  : ' + erc721Abi.length + ' entries')
console.log('ERC-1155 : ' + erc1155Abi.length + ' entries')
const fns = erc20Abi.filter(e => e.type === 'function').map(e => e.name)
console.log('ERC-20 fns: ' + fns.join(', '))

// 2. Bootstrap ERC-20 -- deployable bytecode + full ABI
console.log('-- Bootstrap ERC-20 --')
console.log('ABI entries : ' + erc20BaseAbi.length)
console.log('Bytecode    : ' + erc20BaseBytecode.slice(0, 28) + '... (' + Math.floor(erc20BaseBytecode.length / 2) + ' bytes)')

// 3. Deployed DevKit contracts with on-chain addresses
console.log('-- AutomationManager (deployed) --')
console.log('Testnet : ' + automationManagerAddress[71])
console.log('Mainnet : ' + automationManagerAddress[1030])
console.log('ABI entries: ' + automationManagerAbi.length)

// 4. Live read using standard ABI -- WCFX on testnet
const WCFX   = '0x2ED3dddae5B2F321AF0806181FBFA6D049Be47d8'
const client = new EspaceClient({ chainId: EVM_TESTNET.id, rpcUrl: EVM_TESTNET.rpcUrls.default.http[0] })

;(async () => {
const [name, symbol, decimals, supply] = await Promise.all([
  client.publicClient.readContract({ address: WCFX, abi: erc20Abi, functionName: 'name' }),
  client.publicClient.readContract({ address: WCFX, abi: erc20Abi, functionName: 'symbol' }),
  client.publicClient.readContract({ address: WCFX, abi: erc20Abi, functionName: 'decimals' }),
  client.publicClient.readContract({ address: WCFX, abi: erc20Abi, functionName: 'totalSupply' }),
])

console.log('-- WCFX live data --')
console.log('Name   : ' + name)
console.log('Symbol : ' + symbol)
console.log('Supply : ' + formatUnits(supply, decimals) + ' ' + symbol)
})().catch(console.error)


How it works

  1. @cfxdevkit/contracts is a zero-dependency package of ABI and bytecode constants — no node: imports, browser-safe.
  2. Standard ABIs (erc20Abi, erc721Abi, erc1155Abi) — use with any compliant token on any EVM chain.
  3. Bootstrap bytecodes (erc20BaseBytecode, erc721BaseBytecode, …) — deploy production-ready contracts from code.
  4. DevKit configs (automationManagerConfig, swappiPriceAdapterConfig) — ABIs + testnet/mainnet addresses bundled together.
  5. Pass any ABI to client.publicClient.readContract for live on-chain data.
Last updated on