Site icon Crypto Week

Comment mettre en œuvre des transactions sans gaz ? — KryptoMind | de Kryptomind Pvt Ltd. | Coinmons | juin 2022

Comment mettre en œuvre des transactions sans gaz ? — KryptoMind | de Kryptomind Pvt Ltd. | Coinmons | juin 2022
Mettre en œuvre des transactions sans gaz
  • Les mineurs d’Ethereum reçoivent des frais de gaz pour leurs efforts de protection du réseau et de confirmation des transactions.
  • Les frais de gaz empêchent également les utilisateurs frauduleux d’inonder le réseau de transactions et de l’engorger.

Qu’est-ce que c’est?

Limitations sur Ethereum

Comment pouvons-nous résoudre ce problème ?

/*** @dev Verifies the signature based on typed structured data.* See https://eips.ethereum.org/EIPS/eip-712*/function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {address signer = _hashTypedDataV4(keccak256(abi.encode(_TYPEHASH,req.from,req.to,req.value,req.gas,req.nonce,keccak256(req.data)))).recover(signature);return _nonces[req.from] == req.nonce && signer == req.from;}execute: Executes the meta-transaction via a low-level call./*** @dev Main function; executes the meta-transaction via a low-level call.*/function execute(ForwardRequest calldata req, bytes calldata signature) public payable whenNotPaused() returns (bool, bytes memory) {require(_senderWhitelist[msg.sender], "AwlForwarder: sender of meta-transaction is not whitelisted");require(verify(req, signature), "AwlForwarder: signature does not match request");_nonces[req.from] = req.nonce + 1;// solhint-disable-next-line avoid-low-level-calls(bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(abi.encodePacked(req.data, req.from));if (!success) {// solhint-disable-next-line no-inline-assemblyassembly {returndatacopy(0, 0, returndatasize())revert(0, returndatasize())}}/*** @dev Validates that the relayer/forwarder EOA has sent enough gas for the call.* See https://ronan.eth.link/blog/ethereum-gas-dangers/.*/assert(gasleft() > req.gas / 63);emit MetaTransactionExecuted(req.from, req.to, req.data);return (success, returndata);}

Source https://medium.com/coinmonks/how-to-implement-gasless-transactions-kryptomind-2a12a992fdfd?source=rss—-721b17443fd5—4

Quitter la version mobile