metatx.adoc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. :xref-ERC2771Context-_contextSuffixLength--: xref:metatx.adoc#ERC2771Context-_contextSuffixLength--
  7. :ERC2771Context: pass:normal[xref:metatx.adoc#ERC2771Context[`ERC2771Context`]]
  8. :xref-MinimalForwarder-constructor--: xref:metatx.adoc#MinimalForwarder-constructor--
  9. :xref-MinimalForwarder-getNonce-address-: xref:metatx.adoc#MinimalForwarder-getNonce-address-
  10. :xref-MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-: xref:metatx.adoc#MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-
  11. :xref-MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-: xref:metatx.adoc#MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-
  12. :xref-EIP712-_domainSeparatorV4--: xref:utils.adoc#EIP712-_domainSeparatorV4--
  13. :xref-EIP712-_hashTypedDataV4-bytes32-: xref:utils.adoc#EIP712-_hashTypedDataV4-bytes32-
  14. :xref-EIP712-eip712Domain--: xref:utils.adoc#EIP712-eip712Domain--
  15. :xref-IERC5267-EIP712DomainChanged--: xref:interfaces.adoc#IERC5267-EIP712DomainChanged--
  16. = Meta Transactions
  17. [.readme-notice]
  18. NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/metatx
  19. == Core
  20. :constructor: pass:normal[xref:#ERC2771Context-constructor-address-[`++constructor++`]]
  21. :isTrustedForwarder: pass:normal[xref:#ERC2771Context-isTrustedForwarder-address-[`++isTrustedForwarder++`]]
  22. :_msgSender: pass:normal[xref:#ERC2771Context-_msgSender--[`++_msgSender++`]]
  23. :_msgData: pass:normal[xref:#ERC2771Context-_msgData--[`++_msgData++`]]
  24. :_contextSuffixLength: pass:normal[xref:#ERC2771Context-_contextSuffixLength--[`++_contextSuffixLength++`]]
  25. [.contract]
  26. [[ERC2771Context]]
  27. === `++ERC2771Context++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/metatx/ERC2771Context.sol[{github-icon},role=heading-link]
  28. [.hljs-theme-light.nopadding]
  29. ```solidity
  30. import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
  31. ```
  32. Context variant with ERC2771 support.
  33. WARNING: The usage of `delegatecall` in this contract is dangerous and may result in context corruption.
  34. Any forwarded request to this contract triggering a `delegatecall` to itself will result in an invalid {_msgSender}
  35. recovery.
  36. [.contract-index]
  37. .Functions
  38. --
  39. * {xref-ERC2771Context-constructor-address-}[`++constructor(trustedForwarder)++`]
  40. * {xref-ERC2771Context-isTrustedForwarder-address-}[`++isTrustedForwarder(forwarder)++`]
  41. * {xref-ERC2771Context-_msgSender--}[`++_msgSender()++`]
  42. * {xref-ERC2771Context-_msgData--}[`++_msgData()++`]
  43. * {xref-ERC2771Context-_contextSuffixLength--}[`++_contextSuffixLength()++`]
  44. --
  45. [.contract-item]
  46. [[ERC2771Context-constructor-address-]]
  47. ==== `[.contract-item-name]#++constructor++#++(address trustedForwarder)++` [.item-kind]#internal#
  48. [.contract-item]
  49. [[ERC2771Context-isTrustedForwarder-address-]]
  50. ==== `[.contract-item-name]#++isTrustedForwarder++#++(address forwarder) → bool++` [.item-kind]#public#
  51. [.contract-item]
  52. [[ERC2771Context-_msgSender--]]
  53. ==== `[.contract-item-name]#++_msgSender++#++() → address++` [.item-kind]#internal#
  54. [.contract-item]
  55. [[ERC2771Context-_msgData--]]
  56. ==== `[.contract-item-name]#++_msgData++#++() → bytes++` [.item-kind]#internal#
  57. [.contract-item]
  58. [[ERC2771Context-_contextSuffixLength--]]
  59. ==== `[.contract-item-name]#++_contextSuffixLength++#++() → uint256++` [.item-kind]#internal#
  60. ERC-2771 specifies the context as being a single address (20 bytes).
  61. == Utils
  62. :ForwardRequest: pass:normal[xref:#MinimalForwarder-ForwardRequest[`++ForwardRequest++`]]
  63. :constructor: pass:normal[xref:#MinimalForwarder-constructor--[`++constructor++`]]
  64. :getNonce: pass:normal[xref:#MinimalForwarder-getNonce-address-[`++getNonce++`]]
  65. :verify: pass:normal[xref:#MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-[`++verify++`]]
  66. :execute: pass:normal[xref:#MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-[`++execute++`]]
  67. [.contract]
  68. [[MinimalForwarder]]
  69. === `++MinimalForwarder++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/metatx/MinimalForwarder.sol[{github-icon},role=heading-link]
  70. [.hljs-theme-light.nopadding]
  71. ```solidity
  72. import "@openzeppelin/contracts/metatx/MinimalForwarder.sol";
  73. ```
  74. Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.
  75. MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This
  76. contract does not intend to have all the properties that are needed for a sound forwarding system. A fully
  77. functioning forwarding system with good properties requires more complexity. We suggest you look at other projects
  78. such as the GSN which do have the goal of building a system like that.
  79. [.contract-index]
  80. .Functions
  81. --
  82. * {xref-MinimalForwarder-constructor--}[`++constructor()++`]
  83. * {xref-MinimalForwarder-getNonce-address-}[`++getNonce(from)++`]
  84. * {xref-MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-}[`++verify(req, signature)++`]
  85. * {xref-MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-}[`++execute(req, signature)++`]
  86. [.contract-subindex-inherited]
  87. .EIP712
  88. * {xref-EIP712-_domainSeparatorV4--}[`++_domainSeparatorV4()++`]
  89. * {xref-EIP712-_hashTypedDataV4-bytes32-}[`++_hashTypedDataV4(structHash)++`]
  90. * {xref-EIP712-eip712Domain--}[`++eip712Domain()++`]
  91. [.contract-subindex-inherited]
  92. .IERC5267
  93. --
  94. [.contract-index]
  95. .Events
  96. --
  97. [.contract-subindex-inherited]
  98. .EIP712
  99. [.contract-subindex-inherited]
  100. .IERC5267
  101. * {xref-IERC5267-EIP712DomainChanged--}[`++EIP712DomainChanged()++`]
  102. --
  103. [.contract-item]
  104. [[MinimalForwarder-constructor--]]
  105. ==== `[.contract-item-name]#++constructor++#++()++` [.item-kind]#public#
  106. [.contract-item]
  107. [[MinimalForwarder-getNonce-address-]]
  108. ==== `[.contract-item-name]#++getNonce++#++(address from) → uint256++` [.item-kind]#public#
  109. [.contract-item]
  110. [[MinimalForwarder-verify-struct-MinimalForwarder-ForwardRequest-bytes-]]
  111. ==== `[.contract-item-name]#++verify++#++(struct MinimalForwarder.ForwardRequest req, bytes signature) → bool++` [.item-kind]#public#
  112. [.contract-item]
  113. [[MinimalForwarder-execute-struct-MinimalForwarder-ForwardRequest-bytes-]]
  114. ==== `[.contract-item-name]#++execute++#++(struct MinimalForwarder.ForwardRequest req, bytes signature) → bool, bytes++` [.item-kind]#public#