Generic cross chain smart contract communication #453
Unanswered
ilblackdragon
asked this question in
Ideas
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently the connectors are specialized for asset transfers. There is big value in that to reduce gas and number of cross contract calls on NEAR side.
But actually this is not really required, next design describes generic connector that allows to communicate for any contracts between each other, where asset transfers would just be special case.
Note, that in case of calling Ethereum, method name should be
method_name(uint256,...)
, e.g. containing the method specification so thatbytes4(sha3(method_name))
can be done. Bytes should be RLP encoded.For example, Token Locker like communication can then be implemented by creating a EvmTokenLocker contract that receives tokens and then calls
GenericConnector.send(near_token_locker_account_id, "deposit", BorshEncode(receiver,amount))
.In NearTokenLocker
deposit
method will check that it was called fromGenericConnector
on NEAR side to allow to execute this operation (e.g. GenericConnector already done all the bridge checks to indeed allow to call this method).Similar operation on calling
withdraw
, which would in turn callsend(eth_locker_address, "unlock(address,uint256)", RLP(receiver,amount))
to unlock given amount from the ETH locker and transfer it toreceiver
's address.This also means that a contract on NEAR can call some special contract on Ethereum, that would for example do set of actions and then call back to this NEAR contract. To keep track of the context for the callback, might need some additional identification system to verify that callback came from the same transaction on the other chain, e.g. some additional Prover logic that would track that this transaction was issuing specific request.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions