ERC 865 Pay gas with Tokens By Igalabru #Repost

in #ethereum6 years ago

When using tokens as utility tokens, we need to try for a good UX. Introducing purses and transactions to end users is a challenge, and it should be clear that the token holder requires ETH to send the token adding some friction to the process. The purpose of this EIP is to abstract the gas for end users, by introducing fees paid in tokens. Third parties can then carry on-chain transactions, pay for gas from the given transaction and get the token from that user.

<h3>Implementation proposal <p dir="auto"><strong>On-chain operation (solidity) <pre><code>   /**<br />     * @notice Submit a presigned transfer<br />     * @param _signature bytes The signature, issued by the owner.<br />     * @param _to address The address which you want to transfer to.<br />     * @param _value uint256 The amount of tokens to be transferred.<br />     * @param _fee uint256 The amount of tokens paid to msg.sender, by the owner.<br />     * @param _nonce uint256 Presigned transaction number.<br />     */<br />    function transferPreSigned(<br />        bytes _signature,<br />        address _to,<br />        uint256 _value,<br />        uint256 _fee,<br />        uint256 _nonce<br />    )<br />        public<br />        returns (bool)<br />    {<br />        require(_to != address(0));<br />        require(signatures[_signature] == false);<br /> <br />        bytes32 hashedTx = transferPreSignedHashing(address(this), _to, _value, _fee, _nonce);<br /> <br />        address from = recover(hashedTx, _signature);<br />        require(from != address(0));<br /> <br />        balances[from] = balances[from].sub(_value).sub(_fee);<br />        balances[_to] = balances[_to].add(_value);<br />        balances[msg.sender] = balances[msg.sender].add(_fee);<br />        signatures[_signature] = true;<br /> <br />        Transfer(from, _to, _value);<br />        Transfer(from, msg.sender, _fee);<br />        TransferPreSigned(from, _to, msg.sender, _value, _fee);<br />        return true;<br />    }<br /> <br />    /**<br />     * @notice Hash (keccak256) of the payload used by transferPreSigned<br />     * @param _token address The address of the token.<br />     * @param _to address The address which you want to transfer to.<br />     * @param _value uint256 The amount of tokens to be transferred.<br />     * @param _fee uint256 The amount of tokens paid to msg.sender, by the owner.<br />     * @param _nonce uint256 Presigned transaction number.<br />     */<br />    function transferPreSignedHashing(<br />        address _token,<br />        address _to,<br />        uint256 _value,<br />        uint256 _fee,<br />        uint256 _nonce<br />    )<br />        public<br />        pure<br />        returns (bytes32)<br />    {<br />        /* "48664c16": transferPreSignedHashing(address,address,address,uint256,uint256,uint256) */<br />        return keccak256(bytes4(0x48664c16), _token, _to, _value, _fee, _nonce);<br />    } <p dir="auto"><br /> <p dir="auto"><strong>For full implementation <strong>Check here : <a href="https://github.com/OpenZeppelin/openzeppelin-solidity/pull/741" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><strong><span><a href="https://github.com/OpenZeppelin/openzeppelin-solidity/pull/741" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/OpenZeppelin/openzeppelin-solidity/pull/741 <p dir="auto"><strong>Source : <a href="https://github.com/ethereum/EIPs/issues/865" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><strong><span><a href="https://github.com/ethereum/EIPs/issues/865" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/ethereum/EIPs/issues/865
Sort:  

Congratulations @naomihasegawa! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@naomihasegawa" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 2x" /> Award for the number of upvotes received <p dir="auto"><sub><em>Click on the badge to view your Board of Honor.<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">Do you like <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard's project? Then <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!

Congratulations @naomihasegawa! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Are you a DrugWars early adopter? Benvenuto in famiglia!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @naomihasegawa! You received a personal award!

Happy Steem Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!