Skip to main content

Building with EVM API

Dual Token

The Root Network uses a dual token system - governance token ROOT and a fee token XRP. The native currency used by Ethereum RPCs on The Root Network for balances, paying gas fees, and value transfers is XRP.

XRP is a 6dp token, while Ethereum tooling like MetaMask and Solidity expect native token amounts in wei or 18dp units. To keep compatibility simple, The Root Network protocol takes care of scaling inputs down by 1e-12 and scaling up outputs by 1e12. Any fractional amounts < 1e12 / 0.000001 XRP are always rounded up only by adding 1e12.

ROOT token is available as an ERC-20 token at 0xcCcCCccC00000001000000000000000000000000. ROOT is also a 6dp token but requires no special handling as per the ERC20 standard.

The @therootnetwork/evm package exports a handy method assetIdToERC20Address that converts the native asset id to EVM contract address. In ROOT case, it's effectively assetIdToERC20Address(1) with ROOT asset id is 1.

Transfer Examples

  1. Transfers 1 XRP to receiver
receiver.call{value: 1 ether}("")
  1. Transfers 1.00001 XRP to receiver (i.e. rounds up by 0.00001 XRP)
receiver.call{value: 1 ether + 1 wei}("")

Similarly, the following will transfer 0.00001 XRP to receiver

await wallet.sendTransaction({
  to: receiver,
  value: 1,
});

or transfer 1.2 XRP to receiver

await wallet.sendTransaction({
  to: receiver,
  value: ethers.utils.parseEther("1.2"),
});
  • XRP is the default "native" currency
  • Input and output amounts for XRP on EVM are expressed in wei (18dp) as normal
  • Amounts transferred < 1e12 are always rounded up

Transaction Fees

The Root Network supports EIP-1559 and legacy transaction fee models. Ethereum tooling is able to query fee estimation info accurately out of the box without any special handling required. The eth_feeHistory RPC is provided for this purpose. See eth_feeHistory - Ethereum documentation for more details.

Fees are charged for deploying and executing smart contracts on The Root Network.

Executing a smart contract on The Root Network costs a minimal transaction fee, typically a few XRPs.

Deploying a smart contract is slightly more expensive than executing it. This is because each contract deployed to the EVM will be stored on the chain forever. It requires storage space.

Addresses

EVM contract developers on The Root Network can use existing Ethereum wallets and addresses without any changes. The network supports ECDSA addresses by default.

Solidity Version

The Root Network supports Solidity version v8.20.0 (Shanghai) and below, with future support for newer version is underway.