Skip to main content

Assets (ERC-20)

Asset Precompile

Contract Address

The ERC-20 contract address for The Root Network native tokens uses the following format:

0xCCCCCCCC[4-byte-token-id]000000000000000000000000
tip

To make things easier, the @therootnetwork/evm provides a handy function to convert token asset ID to its equivalent contract address.

import { assetIdToERC20Address } from "@therootnetwork/evm";

const ROOT_ASSET_ID = 1;
const ROOT_CONTRACT_ADDRESS = assetIdToERC20Address(ROOT_ASSET_ID);

Solidity Interfaces

interface IERC20 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);

function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}