pragma solidity >=0.4.22 <0.6.0; import "remix_tests.sol"; // this import is automatically injected by Remix. // 注意:凡是 relayer 想代為互動的 dapp contracts 都要個別建立 interface // 每個 interface 內含一個 function (metaTx) 即可。 // 所有想處理 meta-transaction 的 dapp 都要實作一個 metaTx(),實現 contest 目標。 interface dapp { function metaTx(address initiatorAddr, bytes calldata message, uint8 v, bytes32 r, bytes32 s, uint256 nonce) external returns (bool); } contract relayer { dapp dappContract; constructor(address dappAddr) public { // 傳入想幫忙 relay 的 address dappContract = dapp(dappAddr); } function relayTx(bytes memory message, uint8 v, bytes32 r, bytes32 s, uint256 nonce) public { dappContract.metaTx(msg.sender, message, v, r, s, nonce); // 注意:msg.sender 理應不需要為這行付 gas // 如果是用 dappAddr.call() 的話,不確定 msg.sender 要不要付 gas。如果要付,那就不符合 contest 目標。 } }
0.6.0