Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAlternative receiver for TokenBridge transfer operations #295
Labels
Comments
This was referenced Oct 3, 2019
This was referenced Nov 6, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Below is a proposal to implement a new functionality for the TokenBridge to transfer DAI tokens through the bridge with simultaneous change of the receiver account. It will allow to specify receiver of the tokens.
Background
Currently ordinary TokenBridge operations (not Arbitrary Message Bridging) assume that an account that receives tokens is the same as the account that sends the tokens.
Let's consider the scenario when Alice transfer tokens through the xDai bridge:
Similar is performed if Alice transfers tokens in the opposite direction from the Ethereum Mainnet to the xDai chain.
transfer
method on the token contract.Transfer
event targeted to the bridge account and consider it as a relay request. The fieldfrom
of the event data (which is Alice's account address) is used as the receiver account address for this relay request.These examples demonstrate that it is not possible to explicitly specify a receiver on the step 1 of every scenario. So, another sequence of operations is needed to implement required functionality.
Proposal
In order to implement the Alternative receiver functionality the new scenario is being suggested. Whether a user transfers tokens either from the xDai chain or from the Ethereum Mainnet, the bridge contract should be called explicitly.
For the transfer from the xDai chain it means that the user needs to invoke a special method (e.g.
relayRequest
) of the bridge contract and specify the receiver of the tokens.Since the method is payable the corresponding transaction will have both the
input
data to handle the method invocation and thevalue
of xDai. The bridge contract will use the address specified in the method parameters to notify the oracles about recipient of tokens on another side of the bridge.The user's actions to transfer tokens from the Ethereum Mainnet consist of two parts:
approve
method of the DAI token contract and specifies the bridge account to be allowable to transfer some specific amount of tokens.relayRequest
) on the bridge contract, specifies the amount of tokens to be transferred through the bridge and the receiver account address.The bridge contract invoked through the method will collect approved amount of tokens by
transferFrom
and notify the oracles about recipient of tokens on another side of the bridge.Similar functionality can be easily extended for any type of supported bridge modes.
transferAndCall
method for these tokens, thedata
field of this method can be used to specify the receiver account address.Let me clarify the second item by using the POA-POA20 bridge as an example.
At this particular moment the tokens are bridged from the Ethereum Mainnet in the following manner:
transferAndCall
on the token contract. The bridge contract address is specified as the recipient of the tokens.onTokenTransfer
method of the bridge contract. That causes emitting of an event where Alice’s account address is used as the receiver account address for the relay request.For both
transferAndCall
andonTokenTransfer
ERC677 standart specifies the fielddata
as the third parameter:So the functionality of these method in the TokenBridge related contracts could be extended to utilize the
data
field for an alternative receiver address.If a user need to alter the receiver of tokens on another side of the bridge, the
data
field must be filled with the address of tokens recipient.