ERC677 to ERC677 AMB bridge extension
How to deploy erc677-to-erc677 Arbitrary Message Bridge extension
Instructions for deploying a pair of ERC677-compatible tokens and the bridge mediator contract on top of the Arbitrary Message Bridge (AMB).
An AMB bridge extension is a pair of mediator contracts associated with a specific pair of Arbitrary Message Bridge contracts.
The steps below assume that the AMB is up and running and serves the bridge between Kovan (Foreign) chain and Sokol (Home) chain.
Instructions
docker pull poanetwork/tokenbridge-contracts:latest
Deploy an ERC20 token contract to the Foreign (Kovan) chain. The contract
PermittableToken
(PermittableToken_flat.sol
) from the archivetokenbridge-contracts-flattened-...zip
located on the release page in the TokenBridge contracts repo can be used for this. The deployment can be performed with Remix or MyEtherWallet. Note: In the steps below we assume that the address of the deployed token contract is0xff94183659f549D6273349696d73686Ee1d2AC83
. Verify the contract in the block explorer (contract name:PermittableToken
, compiler version:v0.4.24+commit.e67f0147
, optimization is enabled, automatic identification of constructor arguments).Mint some amount of tokens for an account.
Create
amb-erc20-to-erc677.config
config file with the following content:Please note: if
HOME_EXPLORER_URL
,FOREIGN_EXPLORER_URL
andFOREIGN_EXPLORER_API_KEY
are not configured, it will be necessary to verify the contracts in the block explorers manually. The flattened contracts sources from the archivetokenbridge-contracts-flattened-...zip
located on the release page in the TokenBridge contracts repo can be used for this. It is highly recommended to allow the deployment process to verify the contracts automatically since the verification could be not trivial and take lots of steps.docker run -ti --rm --env-fileamb-erc20-to-erc677.config
poanetwork/tokenbridge-contracts:latest deploy.sh
Output will look similar to this:If
HOME_EXPLORER_URL
,FOREIGN_EXPLORER_URL
andFOREIGN_EXPLORER_API_KEY
were not configured, verify the sources in the block explorers. Otherwise, skip this step.If your own ERC20 token was used in the configuration for the extension, execute the
approve
method on the token contract on the Foreign side as so the approved address is the mediator contract0xC3C5dcCeB4276aEd47c2129B2F3906Ec66803361
. Then invoke therelayTokens
method on the mediator contract. Note that for these two operations the amount of tokens must be equal or greater theFOREIGN_MIN_AMOUNT_PER_TX
parameter used in the deployment. If thePermittableToken
contract was used for the token on the foreign side, invoketransferAndCall
method from the token contract. The argumentto
for the call must contain the address of the mediator contract0xC3C5dcCeB4276aEd47c2129B2F3906Ec66803361
. Thedata
argument must be0x
. For both cases the sender of the transaction is used as the account to receive the tokens on another side of the bridge. The transaction hash can be used on the AMB Live monitoring app to track the status of the transfer confirmation and execution.The method
transferAndCall
can be used with the token contract (0xB36296478099555f9a2AD45AeA6E7b6c82DCc56d
) on the Home side to transfer tokens back to the Foreign chain. The argumentto
for the call must contain the address of the mediator contract0x8f33Ad10fdc10B56D4d4Ca09D5A5910D62d82375
. Thedata
argument must be0x
.
Last updated