Developers Forum for XinFin XDC Network

Daniel Liu
Daniel Liu

Posted on

Deploy StableCoin on XDC by EIP-1559

The devnet of XDC supports EIP-1559 now. This article demonstrates how to setup stablecoin on devnet by EIP-1559.

install nvm

Please install nvm first:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Then close your current terminal simply, open a new terminal to make nvm take effect.

install node and yarn

The stablecoin-evm project requires node v20.9.0 and yarn v1.22.19:

https://github.com/circlefin/stablecoin-evm/blob/master/package.json#L100-L101:

  "engines": {
    "node": "20.9.0",
    "yarn": "1.22.19"
  }
Enter fullscreen mode Exit fullscreen mode

So we install node and yarn with the following commands:

nvm install v20.9.0
nvm use v20.9.0
npm install -g yarn@1.22.19
Enter fullscreen mode Exit fullscreen mode

install stablecoin-evm

Install stablecoin-evm step by step according to the README. But we have to update the Foundry's version in the file setup.sh since nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9 has problem to support EIP-1559.

git clone https://github.com/circlefin/stablecoin-evm
cd stablecoin-evm

# Use nightly-206dab285437bd6889463ab006b6a5fb984079d8 which is latest at 2024-12-16
VER="nightly-206dab285437bd6889463ab006b6a5fb984079d8"
sed -i "s/^FOUNDRY_VERSION=nightly.*/FOUNDRY_VERSION=${VER}/" setup.sh

yarn
yarn compile
yarn hardhat typechain
Enter fullscreen mode Exit fullscreen mode

configure stablecoin-evm

Prepare 1 private key for deploy and 2 addresses for administration:

echo "[]" > blacklist.remote.json
cp .env.example .env
vi .env
Enter fullscreen mode Exit fullscreen mode

Here is my .env file:

DEPLOYER_PRIVATE_KEY="0x1234......"
TOKEN_NAME=USDC
TOKEN_SYMBOL=USDC
TOKEN_CURRENCY=USD
TOKEN_DECIMALS=6
PROXY_ADMIN_ADDRESS="0x85f33E1242d87a875301312BD4EbaEe8876517BA"
OWNER_ADDRESS="0xD4CE02705041F04135f1949Bc835c1Fe0885513c"
MASTER_MINTER_OWNER_ADDRESS="0xD4CE02705041F04135f1949Bc835c1Fe0885513c"
GAS_MULTIPLIER=110
BLACKLIST_FILE_NAME=blacklist.remote.json
Enter fullscreen mode Exit fullscreen mode

Notice:

  • PROXY_ADMIN_ADDRESS must be different with OWNER_ADDRESS
  • PAUSER_ADDRESS is optional, will be OWNER_ADDRESS if not set
  • BLACKLISTER_ADDRESS is optional, will be OWNER_ADDRESS if not set
  • LOST_AND_FOUND_ADDRESS is optional, will be OWNER_ADDRESS if not set

deploy on devnet

We can remove the --legacy flag in command line since the devnet supports EIP-1559 now:

forge script -vv --broadcast scripts/deploy/deploy-fiat-token.s.sol --rpc-url https://devnetstats.hashlabs.apothem.network/devnet/
Enter fullscreen mode Exit fullscreen mode
[⠢] Compiling...
No files changed, compilation skipped
Script ran successfully.

== Return ==
0: contract FiatTokenV2_2 0xcFBFDe74F1C71a49EEC3050ca3a0CB0A5de92F8E
1: contract MasterMinter 0x7bdb6EaB59864eE77C256cA3ca76533d28e8D143
2: contract FiatTokenProxy 0x1e1fEAa7c2C1Be60f3F4b864A4389Cd99f00a9dd

== Logs ==
  TOKEN_NAME: 'USDC'
  TOKEN_SYMBOL: 'USDC'
  TOKEN_CURRENCY: 'USD'
  TOKEN_DECIMALS: '6'
  FIAT_TOKEN_IMPLEMENTATION_ADDRESS: '0x0000000000000000000000000000000000000000'
  PROXY_ADMIN_ADDRESS: '0x85f33E1242d87a875301312BD4EbaEe8876517BA'
  MASTER_MINTER_OWNER_ADDRESS: '0xD4CE02705041F04135f1949Bc835c1Fe0885513c'
  OWNER_ADDRESS: '0xD4CE02705041F04135f1949Bc835c1Fe0885513c'
  PAUSER_ADDRESS: '0xD4CE02705041F04135f1949Bc835c1Fe0885513c'
  BLACKLISTER_ADDRESS: '0xD4CE02705041F04135f1949Bc835c1Fe0885513c'

## Setting up 1 EVM.

==========================

Chain 551

Estimated gas price: 25.000000001 gwei

Estimated total gas used for script: 10475541

Estimated amount required: 0.261888525010475541 ETH

==========================

##### 551
✅  [Success] Hash: 0x4c455802ca637ef7df21f6d3de372c1c07f5f2d88c52a1857db1657570000034
Contract Address: 0x1e1fEAa7c2C1Be60f3F4b864A4389Cd99f00a9dd
Block: 24076108
Paid: 0.007444637500595571 ETH (595571 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x5b82f47197bf00198e2fc9d7f7f7ce916d57bbffc152199d334719e26d09c059
Block: 24076108
Paid: 0.000439737500035179 ETH (35179 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0xd47ba4c5addee62973ec8a28e481acfeefc559418aac3569db585ced683d5b34
Contract Address: 0xf44117366AE0D8F43260E0262527FB9EB2003cad
Block: 24076108
Paid: 0.006345687500507655 ETH (507655 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x6b1999f459fc08fa33a41a2f28d8b9203010cd1b9e963b6212ee5ff4f8f31999
Contract Address: 0xcFBFDe74F1C71a49EEC3050ca3a0CB0A5de92F8E
Block: 24076108
Paid: 0.076860275006148822 ETH (6148822 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x571c359953870602fa6ca148c95f68a160bb6a98e5aaa95f0f175b8ee52356fe
Block: 24076108
Paid: 0.000618362500049469 ETH (49469 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x533aa609224a486a027320e29b1c71368b048efe346ec4055718c0d8b43bb52e
Block: 24076108
Paid: 0.001147850000091828 ETH (91828 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x45adfb2fe8e3e6cf46f43127fc496a693526f4e01562bfb7582e8e14f38eee81
Block: 24076108
Paid: 0.001410037500112803 ETH (112803 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0xf4f2981de76a559d7746775e9442e81fa0fba7999bb96bff83a3cb9894d20d37
Contract Address: 0x7bdb6EaB59864eE77C256cA3ca76533d28e8D143
Block: 24076108
Paid: 0.018582650001486612 ETH (1486612 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x3d060ff7dda50f202a952ed7a2dd07a31eed5addfd0a9a82229b8a9eb24dbbdd
Block: 24076108
Paid: 0.000334912500026793 ETH (26793 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x19fac97efe0f5b406735d1789a12bbc833e9455e5996c187a8ae410d7343ae66
Block: 24076108
Paid: 0.000560837500044867 ETH (44867 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x4ce999526026546ac62a60882aefda4ebbd006d405ef93585d4243f696ecffe6
Block: 24076108
Paid: 0.001019800000081584 ETH (81584 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x88741cf2dfb0da5dd5b7c6e7d5a3a2c6fea1094f253d35e647cc79bccadf0350
Block: 24076108
Paid: 0.000723087500057847 ETH (57847 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x5f7be603ffdb556bd506e14ef00c8c42c19f821c0dc8b3a59ac5b25fef99526f
Block: 24076108
Paid: 0.0003687500000295 ETH (29500 gas * 12.500000001 gwei)


##### 551
✅  [Success] Hash: 0x3c821e83e681fc67255d556c207935249377d46159a79d2c040bf44c8485d268
Block: 24076108
Paid: 0.002705475000216438 ETH (216438 gas * 12.500000001 gwei)

✅ Sequence #1 on 551 | Total Paid: 0.118562100009484968 ETH (9484968 gas * avg 12.500000001 gwei)


==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.

Transactions saved to: /home/me/stablecoin-evm/broadcast/deploy-fiat-token.s.sol/551/run-latest.json

Sensitive values saved to: /home/me/stablecoin-evm/cache/foundry/deploy-fiat-token.s.sol/551/run-latest.json
Enter fullscreen mode Exit fullscreen mode

Verify

TODO: The devnet does not support etherscan now. We will test the following command on testnet later.

yarn forge:verify scripts/deploy/deploy-fiat-token.s.sol --rpc-url <RPC>
Enter fullscreen mode Exit fullscreen mode

Discussion (0)