metatx.adoc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. :github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
  2. :xref-ERC2771Context-constructor-address-: xref:metatx.adoc#ERC2771Context-constructor-address-
  3. :xref-ERC2771Context-isTrustedForwarder-address-: xref:metatx.adoc#ERC2771Context-isTrustedForwarder-address-
  4. :xref-ERC2771Context-_msgSender--: xref:metatx.adoc#ERC2771Context-_msgSender--
  5. :xref-ERC2771Context-_msgData--: xref:metatx.adoc#ERC2771Context-_msgData--
  6. :ERC2771Context: pass:normal[xref:metatx.adoc#ERC2771Context[`ERC2771Context`]]
  7. :xref-MinimalForwarder-constructor--: xref:metatx.adoc#MinimalForwarder-constructor--
  8. :xref-MinimalForwarder-getNonce-address-: xref:metatx.adoc#MinimalForwarder-getNonce-address-
  9. :xref-MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-: xref:metatx.adoc#MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-
  10. :xref-MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-: xref:metatx.adoc#MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-
  11. :xref-EIP712-_domainSeparatorV4--: xref:utils.adoc#EIP712-_domainSeparatorV4--
  12. :xref-EIP712-_hashTypedDataV4-bytes32-: xref:utils.adoc#EIP712-_hashTypedDataV4-bytes32-
  13. = Meta Transactions
  14. [.readme-notice]
  15. NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/metatx
  16. == Core
  17. :_trustedForwarder: pass:normal[xref:#ERC2771Context-_trustedForwarder-address[`++_trustedForwarder++`]]
  18. :constructor: pass:normal[xref:#ERC2771Context-constructor-address-[`++constructor++`]]
  19. :isTrustedForwarder: pass:normal[xref:#ERC2771Context-isTrustedForwarder-address-[`++isTrustedForwarder++`]]
  20. :_msgSender: pass:normal[xref:#ERC2771Context-_msgSender--[`++_msgSender++`]]
  21. :_msgData: pass:normal[xref:#ERC2771Context-_msgData--[`++_msgData++`]]
  22. [.contract]
  23. [[ERC2771Context]]
  24. === `++ERC2771Context++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.3/contracts/metatx/ERC2771Context.sol[{github-icon},role=heading-link]
  25. [.hljs-theme-light.nopadding]
  26. ```solidity
  27. import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
  28. ```
  29. Context variant with ERC2771 support.
  30. [.contract-index]
  31. .Functions
  32. --
  33. * {xref-ERC2771Context-constructor-address-}[`++constructor(trustedForwarder)++`]
  34. * {xref-ERC2771Context-isTrustedForwarder-address-}[`++isTrustedForwarder(forwarder)++`]
  35. * {xref-ERC2771Context-_msgSender--}[`++_msgSender()++`]
  36. * {xref-ERC2771Context-_msgData--}[`++_msgData()++`]
  37. --
  38. [.contract-item]
  39. [[ERC2771Context-constructor-address-]]
  40. ==== `[.contract-item-name]#++constructor++#++(address trustedForwarder)++` [.item-kind]#internal#
  41. [.contract-item]
  42. [[ERC2771Context-isTrustedForwarder-address-]]
  43. ==== `[.contract-item-name]#++isTrustedForwarder++#++(address forwarder) → bool++` [.item-kind]#public#
  44. [.contract-item]
  45. [[ERC2771Context-_msgSender--]]
  46. ==== `[.contract-item-name]#++_msgSender++#++() → address sender++` [.item-kind]#internal#
  47. [.contract-item]
  48. [[ERC2771Context-_msgData--]]
  49. ==== `[.contract-item-name]#++_msgData++#++() → bytes++` [.item-kind]#internal#
  50. == Utils
  51. :ForwardRequest: pass:normal[xref:#MinimalForwarder-ForwardRequest[`++ForwardRequest++`]]
  52. :_TYPEHASH: pass:normal[xref:#MinimalForwarder-_TYPEHASH-bytes32[`++_TYPEHASH++`]]
  53. :_nonces: pass:normal[xref:#MinimalForwarder-_nonces-mapping-address----uint256-[`++_nonces++`]]
  54. :constructor: pass:normal[xref:#MinimalForwarder-constructor--[`++constructor++`]]
  55. :getNonce: pass:normal[xref:#MinimalForwarder-getNonce-address-[`++getNonce++`]]
  56. :verify: pass:normal[xref:#MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-[`++verify++`]]
  57. :execute: pass:normal[xref:#MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-[`++execute++`]]
  58. [.contract]
  59. [[MinimalForwarder]]
  60. === `++MinimalForwarder++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.3/contracts/metatx/MinimalForwarder.sol[{github-icon},role=heading-link]
  61. [.hljs-theme-light.nopadding]
  62. ```solidity
  63. import "@openzeppelin/contracts/metatx/MinimalForwarder.sol";
  64. ```
  65. Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.
  66. MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This
  67. contract does not intend to have all the properties that are needed for a sound forwarding system. A fully
  68. functioning forwarding system with good properties requires more complexity. We suggest you look at other projects
  69. such as the GSN which do have the goal of building a system like that.
  70. [.contract-index]
  71. .Functions
  72. --
  73. * {xref-MinimalForwarder-constructor--}[`++constructor()++`]
  74. * {xref-MinimalForwarder-getNonce-address-}[`++getNonce(from)++`]
  75. * {xref-MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-}[`++verify(req, signature)++`]
  76. * {xref-MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-}[`++execute(req, signature)++`]
  77. [.contract-subindex-inherited]
  78. .EIP712
  79. * {xref-EIP712-_domainSeparatorV4--}[`++_domainSeparatorV4()++`]
  80. * {xref-EIP712-_hashTypedDataV4-bytes32-}[`++_hashTypedDataV4(structHash)++`]
  81. --
  82. [.contract-item]
  83. [[MinimalForwarder-constructor--]]
  84. ==== `[.contract-item-name]#++constructor++#++()++` [.item-kind]#public#
  85. [.contract-item]
  86. [[MinimalForwarder-getNonce-address-]]
  87. ==== `[.contract-item-name]#++getNonce++#++(address from) → uint256++` [.item-kind]#public#
  88. [.contract-item]
  89. [[MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-]]
  90. ==== `[.contract-item-name]#++verify++#++(struct MinimalForwarder.ForwardRequest req, bytes signature) → bool++` [.item-kind]#public#
  91. [.contract-item]
  92. [[MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-]]
  93. ==== `[.contract-item-name]#++execute++#++(struct MinimalForwarder.ForwardRequest req, bytes signature) → bool, bytes++` [.item-kind]#public#