Skip to Content
Playground@contracts · Deploy

Deploy ERC-20 (Bootstrap)

Use the erc20BaseAbi and erc20BaseBytecode from @cfxdevkit/contracts to deploy a production-ready ERC-20 with one function call.

network:Testnet· chain 71
import { erc20BaseAbi, erc20BaseBytecode } from '@cfxdevkit/contracts'
import { EspaceWalletClient, EVM_TESTNET, parseUnits, formatUnits } from '@cfxdevkit/core'

// Show the bootstrap ERC-20 contract structure
console.log('-- ERC20Base Bootstrap Contract --')
console.log('ABI entries : ' + erc20BaseAbi.length)
console.log('Bytecode    : ' + erc20BaseBytecode.slice(0, 28) + '... (' + Math.floor(erc20BaseBytecode.length / 2) + ' bytes)')

// List the ABI functions
const fns = erc20BaseAbi.filter(e => e.type === 'function').map(e => e.name + ' (' + e.stateMutability + ')')
console.log('-- Functions (' + fns.length + ') --')
for (const f of fns.slice(0, 10)) {
console.log('  ' + f)
}
if (fns.length > 10) console.log('  ... and ' + (fns.length - 10) + ' more')

// Constructor arguments for ERC20Base
// (name, symbol, initialSupply, owner)
const TOKEN_NAME    = 'Demo Token'
const TOKEN_SYMBOL  = 'DEMO'
const TOTAL_SUPPLY  = parseUnits('1000000', 18)
const OWNER_ADDR    = '0x85d80245dc02f5A89589e1f19c5c718E405B56AA'

console.log('-- Deploy Parameters --')
console.log('Name   : ' + TOKEN_NAME)
console.log('Symbol : ' + TOKEN_SYMBOL)
console.log('Supply : ' + formatUnits(TOTAL_SUPPLY, 18) + ' ' + TOKEN_SYMBOL)
console.log('Owner  : ' + OWNER_ADDR)

// Uncomment to deploy (requires a funded testnet wallet)
//
// const wallet = new EspaceWalletClient({
//   chainId:    EVM_TESTNET.id,
//   rpcUrl:     EVM_TESTNET.rpcUrls.default.http[0],
//   privateKey: '0xYOUR_TESTNET_PRIVATE_KEY',
// })
//
// const contractAddress = await wallet.deployContract(
//   erc20BaseAbi,
//   erc20BaseBytecode,
//   [TOKEN_NAME, TOKEN_SYMBOL, TOTAL_SUPPLY, OWNER_ADDR],
// )
// console.log('Deployed at: ' + contractAddress)

console.log('-- Deploy call commented out (no testnet funds in playground) --')
console.log('Paste your funded private key and uncomment wallet.deployContract(...) to deploy.')


How it works

  1. erc20BaseAbi + erc20BaseBytecode are exported from @cfxdevkit/contracts — a capped, burnable, pausable ERC-20 with ERC-2612 permit.
  2. wallet.deployContract(abi, bytecode, args) handles signing, broadcasting, and polling for the receipt — returns the deployed address directly.
  3. Constructor arguments: (name, symbol, initialSupply, owner) — the owner receives the full initial supply.
import { erc20BaseAbi, erc20BaseBytecode } from '@cfxdevkit/contracts' import { EspaceWalletClient, EVM_TESTNET, parseUnits } from '@cfxdevkit/core' const wallet = new EspaceWalletClient({ chainId: EVM_TESTNET.id, rpcUrl: EVM_TESTNET.rpcUrls.default.http[0], privateKey: '0x...', }) const contractAddress = await wallet.deployContract( erc20BaseAbi, erc20BaseBytecode, ['My Token', 'MTK', parseUnits('1000000', 18), wallet.getAddress()], ) console.log('Deployed at:', contractAddress)
Last updated on