|
| 1 | +# How to: Add IBC ERC20 tokens |
| 2 | + |
| 3 | +## Setup |
| 4 | + |
| 5 | +For a mainnet deployment, modify the .env file to include: |
| 6 | + |
| 7 | +``` |
| 8 | +MAINNET_URL=<mainnet_url> |
| 9 | +MAINNET_PRIVATE_KEY=<private_key> |
| 10 | +DEPLOYMENT_NAME=<deployment_name> |
| 11 | +TOKEN_FILE=data/ibc_mainnet_tokens.json |
| 12 | +TOKEN_ADDRESS_FILE=data/ibc_token_addresses.jsonl |
| 13 | +``` |
| 14 | + |
| 15 | +Where: |
| 16 | + |
| 17 | +| Item | Description | |
| 18 | +| ---------------------- | ------------------------------------------------------------ | |
| 19 | +| `<mainnet_url>` | Replace with the Infura Mainnet URL | |
| 20 | +| `<private_key>` | Replace with the ETH Private Key for the BridgeBank operator | |
| 21 | +| `<deployment_name>` | Replace with the deployment name like sifchain | |
| 22 | +| `<token_file>` | File with information on new tokens to be deployed | |
| 23 | +| `<token_address_file>` | File where new tokens that are created will be written to | |
| 24 | + |
| 25 | +# Overview |
| 26 | + |
| 27 | +There are two distinct steps to this script. |
| 28 | + |
| 29 | +One is creating the new bridge tokens. |
| 30 | +Two is attaching the bridge tokens to the bridgebank by calling addExistingBridgeToken on the bridgebank. |
| 31 | + |
| 32 | +The script to attach bridge tokens will be run by a user with priviledged access to the bridgebank with the owner role. |
| 33 | + |
| 34 | +## Mainnet Token Deployment |
| 35 | + |
| 36 | +This does not require any special permissions. Tokens will be handed off to another user |
| 37 | +before they're attached to the BridgeBank. |
| 38 | + |
| 39 | + cd smart-contracts |
| 40 | + npm install |
| 41 | + npx hardhat run scripts/create_ibc_matching_token.ts --network mainnet | grep -v 'No need to generate' | tee data/ibc_token_addresses.jsonl |
| 42 | + |
| 43 | +## Steps to Attach Tokens to BridgeBank |
| 44 | + |
| 45 | +This requires the private key of the BridgeBank owner. |
| 46 | + |
| 47 | + cd smart-contracts |
| 48 | + npm install |
| 49 | + npx hardhat run scripts/attach_ibc_matching_token.ts --network mainnet < data/ibc_token_addresses.jsonl |
| 50 | + |
| 51 | +## Testing with forked mainnnet |
| 52 | + |
| 53 | +Since you're running two scripts, you'll need a hardhat node running (otherwise the first script will run, execute transactions, then throw them away) |
| 54 | + |
| 55 | +Start a hardhat node in a shell: |
| 56 | + |
| 57 | + npx hardhat node --verbose |
| 58 | + |
| 59 | +Then run the two scripts in a different shell: |
| 60 | + |
| 61 | + npx hardhat run scripts/create_ibc_matching_token.ts --network localhost | grep -v 'No need to generate' | tee test_data/ibc_token_addresses.jsonl |
| 62 | + npx hardhat run scripts/attach_ibc_matching_token.ts --network localhost < test_data/ibc_token_addresses.jsonl |
| 63 | + |
| 64 | +or for ropsten |
| 65 | + |
| 66 | + npx hardhat run scripts/create_ibc_matching_token.ts --network ropsten | grep -v 'No need to generate' | tee test_data/ibc_token_addresses.jsonl |
| 67 | + npx hardhat run scripts/attach_ibc_matching_token.ts --network ropsten < test_data/ibc_token_addresses.jsonl |
| 68 | + |
| 69 | +# Updating dev and test deployments |
| 70 | + |
| 71 | +## Update symbol_translator.json |
| 72 | + |
| 73 | +Modify https://github.com/Sifchain/chainOps/blob/main/.github/workflows/variableMapping/ebrelayer.yaml |
| 74 | +with the new symbol_translation.json entries. It's a yaml file, so you need to escape json - you could |
| 75 | +use something like ```jq -aRs``` to do the quoting. |
| 76 | + |
| 77 | +To push that data out and restart the relayers, use https://github.com/Sifchain/chainOps/actions/workflows/peggy-ebrelayer-deployment.yml |
0 commit comments