-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERC677-to-ERC677 bridge on top of AMB #267
Comments
Here are two questions that came to my mind about the implementation:
1- How should we proceed in the case of the transaction is above the execution limits? Should we add some mecanism similar to 2- Should we add some mecanism to unlock tokens if for some reason the AMB does not procces a message? or processed it but the the execution failed (maybe because the gas limit specified was small)? |
@patitonar thanks for questions:
|
@patitonar I think I have found an issue with the current approach: if a message call (to mint/unlock tokens) will be failed after confirmations by validators, tokens will be locked (or burnt) on another side of the bridge forever. It will lead to imbalance of the bridge. It is due to the fact that we agreed to not revert entire transaction appeared after validators confirmation. |
In order to demonstrate AMB features let's implement ERC677-to-ERC677 bridge that uses AMB interfaces to transfer assets.
From contracts set point of view the architecture could be as following:
Where
Token contract
have the same meaning as on the existingerc20-to-erc20
bridge.Token Management
is responsible for holding the tokens on the Foreign side and minting the tokens on the Home side, implementing theonTokenTransfer
method and checking limits before the transfer.Bridge contract
is the AMB contract.The call flaw for transferring assets from the Foreign side to the Home side could be the following:
transferAndCall
of the token contract specifying the Token Management contract address as receiver of the tokens.onTokenTransfer
of the Token Management contractrequireToPassMessage
on the Bridge contractThe opposite direction is similar but the Token Manager on the Home side burns tokens whereas the Token Manager on the Foreign side executes
transfer
to unlock the tokens.It is important to have the check on the Token Management contract side to make sure that the requests to unlock/mint tokens come from the bridge contract.
Also it is necessary to have extra functionality to provide an example of ability to transfer ordinary ERC20 tokens through the bridge. For this the Token Management contract must have a special method (e.g.
relayTokens
) that could be used in the following flow:approve
of the token contract specifying the Token Management contract address.relayTokens
of the Token Management contract address with the amount of tokens which less or equal the amount from the previous itemtransferFrom
of the token contract and executesrequireToPassMessage
on the Bridge contract.The text was updated successfully, but these errors were encountered: