|
| 1 | +# Token Deployment Guide |
| 2 | + |
| 3 | +This guide walks through the process of deploying the Recall token and testing cross-chain transfers. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. Install Foundry |
| 8 | +2. Install dependencies |
| 9 | +```bash |
| 10 | +pnpm install |
| 11 | +forge install |
| 12 | +``` |
| 13 | +3. Build contracts |
| 14 | +```bash |
| 15 | +forge build |
| 16 | +``` |
| 17 | +When you build the contracts, make sure to note down the version of the solidity compiler used. It might be useful later when verifying the contracts. |
| 18 | + |
| 19 | +## 1. Private key setup |
| 20 | + |
| 21 | +First off we need to create the private key used to deploy the token. This key is important to save because if we ever want to deploy the token on any new chains, we'll need it. This is because the 'interchainTokenID' is generate from a salt + the deployer's address. |
| 22 | + |
| 23 | +There are a few different options for how forge can handle private keys. |
| 24 | + |
| 25 | +- [Raw](https://book.getfoundry.sh/reference/forge/forge-script#wallet-options---raw), the key is provided either interactively or via a flag |
| 26 | +- [Keystore](https://book.getfoundry.sh/reference/forge/forge-script#wallet-options---keystore), forge has a built in encrypted keystore that can be used to store the key |
| 27 | +- [Hardware Wallet](https://book.getfoundry.sh/reference/forge/forge-script#wallet-options---hardware-wallet), forge supports trezor and ledger hardware wallets |
| 28 | + |
| 29 | +The rest of this guide presumes that every command is run with one of the above options so that signatures can be created. |
| 30 | + |
| 31 | +## 2. Fund wallet |
| 32 | + |
| 33 | +Should be straight forward, given the address of the key generated above, fund the wallet on Base and Filecoin. |
| 34 | + |
| 35 | +## 3. Deploy on desired chains |
| 36 | + |
| 37 | +The following commands will deploy the token and connect them through the Axelar Interchain Token Service automatically. Minting will not happen yet at this point. |
| 38 | + |
| 39 | +Please make sure to add the appropiate flag for the private key you want to use. |
| 40 | +Also note that you can run the command without the --broadcast flag to test the transaction without executing it. |
| 41 | + |
| 42 | +### Filecoin |
| 43 | + |
| 44 | +```bash |
| 45 | +forge script script/Recall.s.sol:DeployScript -vvv -g 100000 --rpc-url https://api.node.glif.io/rpc/v1 --sig "run(string)" filecoin --broadcast |
| 46 | +``` |
| 47 | + |
| 48 | +The `-g 100000` flag is used to set the gas multiplier for the transaction. This is needed because the gas price estimation is not working properly on Filecoin. |
| 49 | + |
| 50 | +The command above should yield an output that looks something like this: |
| 51 | + |
| 52 | +``` |
| 53 | +== Return == |
| 54 | +0: contract Recall 0xC28dDF617467d992f54AFe3340599F5325e869E4 |
| 55 | +
|
| 56 | +== Logs == |
| 57 | + Implementation address: 0xC2fea13f7220750b87AFA263Dc567c8fc6953510 |
| 58 | + Deployer: 0x3e7bEc04F2f812e01543D58eF5ab608674696665 |
| 59 | + Deploying token manager |
| 60 | + Recall Interchain Token ID: 0xcfb6e8744f9f354b2d9022a0b8c030daa8e2f029ba446566fbb21fbfd51bb09c |
| 61 | + Token manager: 0x0d0Cf8D25e0CD22a50dF66543e2cb0035047c21C |
| 62 | +``` |
| 63 | + |
| 64 | +### Base |
| 65 | + |
| 66 | +```bash |
| 67 | +forge script script/Recall.s.sol:DeployScript -vvv --rpc-url https://base-rpc.publicnode.com --sig "run(string)" base --broadcast |
| 68 | +``` |
| 69 | + |
| 70 | +Since we are deploying with the same private key on Base as we did on Filecoin, and it's the first transactions on both chains, the output should be exactly the same on both chains. |
| 71 | + |
| 72 | + |
| 73 | +## 4. Verify contracts |
| 74 | + |
| 75 | +On Base you can verify the contracts using the forge toolchain. You just need to get a [basescan api key](https://basescan.org/myapikey) and run the following command: |
| 76 | + |
| 77 | +```bash |
| 78 | +forge verify-contract --chain-id 8453 --watch <implementation_address> src/token/Recall.sol:Recall -e <etherscan_api_key> |
| 79 | +``` |
| 80 | + |
| 81 | +The Recall token address is a proxy account and can be verified directly on basescan.org by clicking in the interface after verifying the implementation address. |
| 82 | + |
| 83 | +On Filecoin you can verify the contracts on [filfox](https://filfox.info/en), which is more tricky. |
| 84 | + |
| 85 | + |
| 86 | +## 5. Set up new token admin |
| 87 | + |
| 88 | +We don't want the singular private key to remain the admin, and we want the foundation multisig to mint the token once ready. Therefore we should roles on the contracts before taking any next steps. |
| 89 | + |
| 90 | +There are three roles: |
| 91 | +- Admin: Can upgrade the contract, set roles, and unpause the token |
| 92 | +- Minter: Can mint new tokens |
| 93 | +- Pauser: Can pause the token, this is a separate role which enables swift action while the admin likely will have timelocks on all its actions in the future |
| 94 | + |
| 95 | +Create foundation multisigs for each chain: |
| 96 | +- Base: use regular [Safe frontend](https://app.safe.global/) |
| 97 | +- Filecoin: use [Filecoin hosted Safe](https://safe.filecoin.io/) |
| 98 | + |
| 99 | +In the commands below, `<proxy_address>` is the proxy address of the Recall token. |
| 100 | + |
| 101 | + |
| 102 | +### Base |
| 103 | + |
| 104 | +```bash |
| 105 | +forge script script/Recall.s.sol:DeployScript -vvv --rpc-url https://base-rpc.publicnode.com --sig "setDefaultRoles(address,address,address,address)" <proxy_address> <admin_address> <minter_address> <pauser_address> --broadcast |
| 106 | +``` |
| 107 | + |
| 108 | +### Filecoin |
| 109 | + |
| 110 | +```bash |
| 111 | +forge script script/Recall.s.sol:DeployScript -vvv -g 100000 --rpc-url https://api.node.glif.io/rpc/v1 --sig "setDefaultRoles(address,address,address,address)" <proxy_address> <admin_address> <minter_address> <pauser_address> --broadcast |
| 112 | +``` |
| 113 | + |
| 114 | +## 6. Mint tokens |
| 115 | + |
| 116 | +Since we gave the foundation multisig the admin and minter role, the mint function on the `<proxy_address>` now has to be called from the corresponding Safe interface. |
| 117 | + |
| 118 | +### Testing minting functionality |
| 119 | + |
| 120 | +If you are just testing the token and bridge and you haven't given away admin to a separate key yet, you can use the following commands to mint tokens. |
| 121 | + |
| 122 | +#### Base |
| 123 | + |
| 124 | +```bash |
| 125 | +forge script script/Bridge.s.sol:BridgeOps -vvv --rpc-url https://base-rpc.publicnode.com --sig "mintFunds(address,address,uint256)" <proxy_address> <recipient_address> <amount> --broadcast |
| 126 | +``` |
| 127 | + |
| 128 | +#### Filecoin |
| 129 | + |
| 130 | +```bash |
| 131 | +forge script script/Bridge.s.sol:BridgeOps -vvv -g 100000 --rpc-url https://api.node.glif.io/rpc/v1 --sig "mintFunds(address,address,uint256)" <proxy_address> <recipient_address> <amount> --broadcast |
| 132 | +``` |
| 133 | + |
| 134 | +## 7. Testing cross-chain transfers |
| 135 | + |
| 136 | +The BridgeOps script also has functionality for testing cross-chain transfers. This is how you can test the bridge. |
| 137 | + |
| 138 | +### Base to Filecoin |
| 139 | + |
| 140 | +```bash |
| 141 | +forge script script/Bridge.s.sol:BridgeOps -vvv --rpc-url https://base-rpc.publicnode.com --sig "xChainTransfer(address,string,address,uint256)" <proxy_address> "filecoin" <recipient_address> <amount> --broadcast |
| 142 | +``` |
| 143 | + |
| 144 | +### Filecoin to base |
| 145 | + |
| 146 | +```bash |
| 147 | +forge script script/Bridge.s.sol:BridgeOps -vvv -g 100000 --rpc-url https://api.node.glif.io/rpc/v1 --sig "xChainTransfer(address,string,address,uint256)" <proxy_address> "base" <recipient_address> <amount> --broadcast |
| 148 | +``` |
| 149 | + |
| 150 | +### Check balance |
| 151 | + |
| 152 | +There's also functionality for checking the balance of an address on a given chain, to see if the transfer was successful. |
| 153 | + |
| 154 | +#### Base |
| 155 | + |
| 156 | +```bash |
| 157 | +forge script script/Bridge.s.sol:BridgeOps -vvv --rpc-url https://base-rpc.publicnode.com --sig "checkBalance(address,address)" <proxy_address> <recipient_address> |
| 158 | +``` |
| 159 | + |
| 160 | +#### Filecoin |
| 161 | + |
| 162 | +```bash |
| 163 | +forge script script/Bridge.s.sol:BridgeOps -vvv -g 100000 --rpc-url https://api.node.glif.io/rpc/v1 --sig "checkBalance(address,address)" <proxy_address> <recipient_address> |
| 164 | +``` |
0 commit comments