crosschain.adoc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. :github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
  2. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  3. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  4. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  5. :AccessControlCrossChain: pass:normal[xref:access.adoc#AccessControlCrossChain[`AccessControlCrossChain`]]
  6. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  7. :xref-CrossChainEnabledAMB-constructor-address-: xref:crosschain.adoc#CrossChainEnabledAMB-constructor-address-
  8. :xref-CrossChainEnabledAMB-_isCrossChain--: xref:crosschain.adoc#CrossChainEnabledAMB-_isCrossChain--
  9. :xref-CrossChainEnabledAMB-_crossChainSender--: xref:crosschain.adoc#CrossChainEnabledAMB-_crossChainSender--
  10. :CrossChainEnabled-_isCrossChain: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_isCrossChain--[`CrossChainEnabled._isCrossChain`]]
  11. :CrossChainEnabled-_crossChainSender: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_crossChainSender--[`CrossChainEnabled._crossChainSender`]]
  12. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  13. :CrossChainEnabledArbitrumL2: pass:normal[xref:crosschain.adoc#CrossChainEnabledArbitrumL2[`CrossChainEnabledArbitrumL2`]]
  14. :xref-CrossChainEnabledArbitrumL1-constructor-address-: xref:crosschain.adoc#CrossChainEnabledArbitrumL1-constructor-address-
  15. :xref-CrossChainEnabledArbitrumL1-_isCrossChain--: xref:crosschain.adoc#CrossChainEnabledArbitrumL1-_isCrossChain--
  16. :xref-CrossChainEnabledArbitrumL1-_crossChainSender--: xref:crosschain.adoc#CrossChainEnabledArbitrumL1-_crossChainSender--
  17. :CrossChainEnabled-_isCrossChain: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_isCrossChain--[`CrossChainEnabled._isCrossChain`]]
  18. :CrossChainEnabled-_crossChainSender: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_crossChainSender--[`CrossChainEnabled._crossChainSender`]]
  19. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  20. :CrossChainEnabledArbitrumL1: pass:normal[xref:crosschain.adoc#CrossChainEnabledArbitrumL1[`CrossChainEnabledArbitrumL1`]]
  21. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  22. :xref-CrossChainEnabledArbitrumL2-_isCrossChain--: xref:crosschain.adoc#CrossChainEnabledArbitrumL2-_isCrossChain--
  23. :xref-CrossChainEnabledArbitrumL2-_crossChainSender--: xref:crosschain.adoc#CrossChainEnabledArbitrumL2-_crossChainSender--
  24. :CrossChainEnabled-_isCrossChain: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_isCrossChain--[`CrossChainEnabled._isCrossChain`]]
  25. :CrossChainEnabled-_crossChainSender: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_crossChainSender--[`CrossChainEnabled._crossChainSender`]]
  26. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  27. :xref-CrossChainEnabledOptimism-constructor-address-: xref:crosschain.adoc#CrossChainEnabledOptimism-constructor-address-
  28. :xref-CrossChainEnabledOptimism-_isCrossChain--: xref:crosschain.adoc#CrossChainEnabledOptimism-_isCrossChain--
  29. :xref-CrossChainEnabledOptimism-_crossChainSender--: xref:crosschain.adoc#CrossChainEnabledOptimism-_crossChainSender--
  30. :CrossChainEnabled-_isCrossChain: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_isCrossChain--[`CrossChainEnabled._isCrossChain`]]
  31. :CrossChainEnabled-_crossChainSender: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_crossChainSender--[`CrossChainEnabled._crossChainSender`]]
  32. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  33. :xref-CrossChainEnabledPolygonChild-constructor-address-: xref:crosschain.adoc#CrossChainEnabledPolygonChild-constructor-address-
  34. :xref-CrossChainEnabledPolygonChild-_isCrossChain--: xref:crosschain.adoc#CrossChainEnabledPolygonChild-_isCrossChain--
  35. :xref-CrossChainEnabledPolygonChild-_crossChainSender--: xref:crosschain.adoc#CrossChainEnabledPolygonChild-_crossChainSender--
  36. :xref-CrossChainEnabledPolygonChild-processMessageFromRoot-uint256-address-bytes-: xref:crosschain.adoc#CrossChainEnabledPolygonChild-processMessageFromRoot-uint256-address-bytes-
  37. :xref-ReentrancyGuard-_reentrancyGuardEntered--: xref:security.adoc#ReentrancyGuard-_reentrancyGuardEntered--
  38. :CrossChainEnabled-_isCrossChain: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_isCrossChain--[`CrossChainEnabled._isCrossChain`]]
  39. :CrossChainEnabled-_crossChainSender: pass:normal[xref:crosschain.adoc#CrossChainEnabled-_crossChainSender--[`CrossChainEnabled._crossChainSender`]]
  40. :CrossChainEnabled: pass:normal[xref:crosschain.adoc#CrossChainEnabled[`CrossChainEnabled`]]
  41. :xref-LibAMB-isCrossChain-address-: xref:crosschain.adoc#LibAMB-isCrossChain-address-
  42. :xref-LibAMB-crossChainSender-address-: xref:crosschain.adoc#LibAMB-crossChainSender-address-
  43. :LibArbitrumL2: pass:normal[xref:crosschain.adoc#LibArbitrumL2[`LibArbitrumL2`]]
  44. :xref-LibArbitrumL1-isCrossChain-address-: xref:crosschain.adoc#LibArbitrumL1-isCrossChain-address-
  45. :xref-LibArbitrumL1-crossChainSender-address-: xref:crosschain.adoc#LibArbitrumL1-crossChainSender-address-
  46. :LibArbitrumL1: pass:normal[xref:crosschain.adoc#LibArbitrumL1[`LibArbitrumL1`]]
  47. :xref-LibArbitrumL2-isCrossChain-address-: xref:crosschain.adoc#LibArbitrumL2-isCrossChain-address-
  48. :xref-LibArbitrumL2-crossChainSender-address-: xref:crosschain.adoc#LibArbitrumL2-crossChainSender-address-
  49. :xref-LibOptimism-isCrossChain-address-: xref:crosschain.adoc#LibOptimism-isCrossChain-address-
  50. :xref-LibOptimism-crossChainSender-address-: xref:crosschain.adoc#LibOptimism-crossChainSender-address-
  51. = Cross Chain Awareness
  52. [.readme-notice]
  53. NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/crosschain
  54. This directory provides building blocks to improve cross-chain awareness of smart contracts.
  55. - {CrossChainEnabled} is an abstraction that contains accessors and modifiers to control the execution flow when receiving cross-chain messages.
  56. == CrossChainEnabled specializations
  57. The following specializations of {CrossChainEnabled} provide implementations of the {CrossChainEnabled} abstraction for specific bridges. This can be used to complex cross-chain aware components such as {AccessControlCrossChain}.
  58. :constructor: pass:normal[xref:#CrossChainEnabledAMB-constructor-address-[`++constructor++`]]
  59. :_isCrossChain: pass:normal[xref:#CrossChainEnabledAMB-_isCrossChain--[`++_isCrossChain++`]]
  60. :_crossChainSender: pass:normal[xref:#CrossChainEnabledAMB-_crossChainSender--[`++_crossChainSender++`]]
  61. [.contract]
  62. [[CrossChainEnabledAMB]]
  63. === `++CrossChainEnabledAMB++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/amb/CrossChainEnabledAMB.sol[{github-icon},role=heading-link]
  64. [.hljs-theme-light.nopadding]
  65. ```solidity
  66. import "@openzeppelin/contracts/crosschain/amb/CrossChainEnabledAMB.sol";
  67. ```
  68. https://docs.tokenbridge.net/amb-bridge/about-amb-bridge[AMB]
  69. specialization or the {CrossChainEnabled} abstraction.
  70. As of february 2020, AMB bridges are available between the following chains:
  71. - https://docs.tokenbridge.net/eth-xdai-amb-bridge/about-the-eth-xdai-amb[ETH ⇌ xDai]
  72. - https://docs.tokenbridge.net/eth-qdai-bridge/about-the-eth-qdai-amb[ETH ⇌ qDai]
  73. - https://docs.tokenbridge.net/eth-etc-amb-bridge/about-the-eth-etc-amb[ETH ⇌ ETC]
  74. - https://docs.tokenbridge.net/eth-bsc-amb/about-the-eth-bsc-amb[ETH ⇌ BSC]
  75. - https://docs.tokenbridge.net/eth-poa-amb-bridge/about-the-eth-poa-amb[ETH ⇌ POA]
  76. - https://docs.tokenbridge.net/bsc-xdai-amb/about-the-bsc-xdai-amb[BSC ⇌ xDai]
  77. - https://docs.tokenbridge.net/poa-xdai-amb/about-the-poa-xdai-amb[POA ⇌ xDai]
  78. - https://docs.tokenbridge.net/rinkeby-xdai-amb-bridge/about-the-rinkeby-xdai-amb[Rinkeby ⇌ xDai]
  79. - https://docs.tokenbridge.net/kovan-sokol-amb-bridge/about-the-kovan-sokol-amb[Kovan ⇌ Sokol]
  80. _Available since v4.6._
  81. [.contract-index]
  82. .Functions
  83. --
  84. * {xref-CrossChainEnabledAMB-constructor-address-}[`++constructor(bridge)++`]
  85. * {xref-CrossChainEnabledAMB-_isCrossChain--}[`++_isCrossChain()++`]
  86. * {xref-CrossChainEnabledAMB-_crossChainSender--}[`++_crossChainSender()++`]
  87. [.contract-subindex-inherited]
  88. .CrossChainEnabled
  89. --
  90. [.contract-item]
  91. [[CrossChainEnabledAMB-constructor-address-]]
  92. ==== `[.contract-item-name]#++constructor++#++(address bridge)++` [.item-kind]#public#
  93. [.contract-item]
  94. [[CrossChainEnabledAMB-_isCrossChain--]]
  95. ==== `[.contract-item-name]#++_isCrossChain++#++() → bool++` [.item-kind]#internal#
  96. see {CrossChainEnabled-_isCrossChain}
  97. [.contract-item]
  98. [[CrossChainEnabledAMB-_crossChainSender--]]
  99. ==== `[.contract-item-name]#++_crossChainSender++#++() → address++` [.item-kind]#internal#
  100. see {CrossChainEnabled-_crossChainSender}
  101. :constructor: pass:normal[xref:#CrossChainEnabledArbitrumL1-constructor-address-[`++constructor++`]]
  102. :_isCrossChain: pass:normal[xref:#CrossChainEnabledArbitrumL1-_isCrossChain--[`++_isCrossChain++`]]
  103. :_crossChainSender: pass:normal[xref:#CrossChainEnabledArbitrumL1-_crossChainSender--[`++_crossChainSender++`]]
  104. [.contract]
  105. [[CrossChainEnabledArbitrumL1]]
  106. === `++CrossChainEnabledArbitrumL1++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol[{github-icon},role=heading-link]
  107. [.hljs-theme-light.nopadding]
  108. ```solidity
  109. import "@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol";
  110. ```
  111. https://arbitrum.io/[Arbitrum] specialization or the
  112. {CrossChainEnabled} abstraction the L1 side (mainnet).
  113. This version should only be deployed on L1 to process cross-chain messages
  114. originating from L2. For the other side, use {CrossChainEnabledArbitrumL2}.
  115. The bridge contract is provided and maintained by the arbitrum team. You can
  116. find the address of this contract on the rinkeby testnet in
  117. https://developer.offchainlabs.com/docs/useful_addresses[Arbitrum's developer documentation].
  118. _Available since v4.6._
  119. [.contract-index]
  120. .Functions
  121. --
  122. * {xref-CrossChainEnabledArbitrumL1-constructor-address-}[`++constructor(bridge)++`]
  123. * {xref-CrossChainEnabledArbitrumL1-_isCrossChain--}[`++_isCrossChain()++`]
  124. * {xref-CrossChainEnabledArbitrumL1-_crossChainSender--}[`++_crossChainSender()++`]
  125. [.contract-subindex-inherited]
  126. .CrossChainEnabled
  127. --
  128. [.contract-item]
  129. [[CrossChainEnabledArbitrumL1-constructor-address-]]
  130. ==== `[.contract-item-name]#++constructor++#++(address bridge)++` [.item-kind]#internal#
  131. [.contract-item]
  132. [[CrossChainEnabledArbitrumL1-_isCrossChain--]]
  133. ==== `[.contract-item-name]#++_isCrossChain++#++() → bool++` [.item-kind]#internal#
  134. see {CrossChainEnabled-_isCrossChain}
  135. [.contract-item]
  136. [[CrossChainEnabledArbitrumL1-_crossChainSender--]]
  137. ==== `[.contract-item-name]#++_crossChainSender++#++() → address++` [.item-kind]#internal#
  138. see {CrossChainEnabled-_crossChainSender}
  139. :_isCrossChain: pass:normal[xref:#CrossChainEnabledArbitrumL2-_isCrossChain--[`++_isCrossChain++`]]
  140. :_crossChainSender: pass:normal[xref:#CrossChainEnabledArbitrumL2-_crossChainSender--[`++_crossChainSender++`]]
  141. [.contract]
  142. [[CrossChainEnabledArbitrumL2]]
  143. === `++CrossChainEnabledArbitrumL2++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol[{github-icon},role=heading-link]
  144. [.hljs-theme-light.nopadding]
  145. ```solidity
  146. import "@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol";
  147. ```
  148. https://arbitrum.io/[Arbitrum] specialization or the
  149. {CrossChainEnabled} abstraction the L2 side (arbitrum).
  150. This version should only be deployed on L2 to process cross-chain messages
  151. originating from L1. For the other side, use {CrossChainEnabledArbitrumL1}.
  152. Arbitrum L2 includes the `ArbSys` contract at a fixed address. Therefore,
  153. this specialization of {CrossChainEnabled} does not include a constructor.
  154. _Available since v4.6._
  155. WARNING: There is currently a bug in Arbitrum that causes this contract to
  156. fail to detect cross-chain calls when deployed behind a proxy. This will be
  157. fixed when the network is upgraded to Arbitrum Nitro, currently scheduled for
  158. August 31st 2022.
  159. [.contract-index]
  160. .Functions
  161. --
  162. * {xref-CrossChainEnabledArbitrumL2-_isCrossChain--}[`++_isCrossChain()++`]
  163. * {xref-CrossChainEnabledArbitrumL2-_crossChainSender--}[`++_crossChainSender()++`]
  164. [.contract-subindex-inherited]
  165. .CrossChainEnabled
  166. --
  167. [.contract-item]
  168. [[CrossChainEnabledArbitrumL2-_isCrossChain--]]
  169. ==== `[.contract-item-name]#++_isCrossChain++#++() → bool++` [.item-kind]#internal#
  170. see {CrossChainEnabled-_isCrossChain}
  171. [.contract-item]
  172. [[CrossChainEnabledArbitrumL2-_crossChainSender--]]
  173. ==== `[.contract-item-name]#++_crossChainSender++#++() → address++` [.item-kind]#internal#
  174. see {CrossChainEnabled-_crossChainSender}
  175. :constructor: pass:normal[xref:#CrossChainEnabledOptimism-constructor-address-[`++constructor++`]]
  176. :_isCrossChain: pass:normal[xref:#CrossChainEnabledOptimism-_isCrossChain--[`++_isCrossChain++`]]
  177. :_crossChainSender: pass:normal[xref:#CrossChainEnabledOptimism-_crossChainSender--[`++_crossChainSender++`]]
  178. [.contract]
  179. [[CrossChainEnabledOptimism]]
  180. === `++CrossChainEnabledOptimism++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol[{github-icon},role=heading-link]
  181. [.hljs-theme-light.nopadding]
  182. ```solidity
  183. import "@openzeppelin/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol";
  184. ```
  185. https://www.optimism.io/[Optimism] specialization or the
  186. {CrossChainEnabled} abstraction.
  187. The messenger (`CrossDomainMessenger`) contract is provided and maintained by
  188. the optimism team. You can find the address of this contract on mainnet and
  189. kovan in the https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments[deployments section of Optimism monorepo].
  190. _Available since v4.6._
  191. [.contract-index]
  192. .Functions
  193. --
  194. * {xref-CrossChainEnabledOptimism-constructor-address-}[`++constructor(messenger)++`]
  195. * {xref-CrossChainEnabledOptimism-_isCrossChain--}[`++_isCrossChain()++`]
  196. * {xref-CrossChainEnabledOptimism-_crossChainSender--}[`++_crossChainSender()++`]
  197. [.contract-subindex-inherited]
  198. .CrossChainEnabled
  199. --
  200. [.contract-item]
  201. [[CrossChainEnabledOptimism-constructor-address-]]
  202. ==== `[.contract-item-name]#++constructor++#++(address messenger)++` [.item-kind]#internal#
  203. [.contract-item]
  204. [[CrossChainEnabledOptimism-_isCrossChain--]]
  205. ==== `[.contract-item-name]#++_isCrossChain++#++() → bool++` [.item-kind]#internal#
  206. see {CrossChainEnabled-_isCrossChain}
  207. [.contract-item]
  208. [[CrossChainEnabledOptimism-_crossChainSender--]]
  209. ==== `[.contract-item-name]#++_crossChainSender++#++() → address++` [.item-kind]#internal#
  210. see {CrossChainEnabled-_crossChainSender}
  211. :constructor: pass:normal[xref:#CrossChainEnabledPolygonChild-constructor-address-[`++constructor++`]]
  212. :_isCrossChain: pass:normal[xref:#CrossChainEnabledPolygonChild-_isCrossChain--[`++_isCrossChain++`]]
  213. :_crossChainSender: pass:normal[xref:#CrossChainEnabledPolygonChild-_crossChainSender--[`++_crossChainSender++`]]
  214. :processMessageFromRoot: pass:normal[xref:#CrossChainEnabledPolygonChild-processMessageFromRoot-uint256-address-bytes-[`++processMessageFromRoot++`]]
  215. [.contract]
  216. [[CrossChainEnabledPolygonChild]]
  217. === `++CrossChainEnabledPolygonChild++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol[{github-icon},role=heading-link]
  218. [.hljs-theme-light.nopadding]
  219. ```solidity
  220. import "@openzeppelin/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol";
  221. ```
  222. https://polygon.technology/[Polygon] specialization or the
  223. {CrossChainEnabled} abstraction the child side (polygon/mumbai).
  224. This version should only be deployed on child chain to process cross-chain
  225. messages originating from the parent chain.
  226. The fxChild contract is provided and maintained by the polygon team. You can
  227. find the address of this contract polygon and mumbai in
  228. https://docs.polygon.technology/docs/develop/l1-l2-communication/fx-portal/#contract-addresses[Polygon's Fx-Portal documentation].
  229. _Available since v4.6._
  230. [.contract-index]
  231. .Functions
  232. --
  233. * {xref-CrossChainEnabledPolygonChild-constructor-address-}[`++constructor(fxChild)++`]
  234. * {xref-CrossChainEnabledPolygonChild-_isCrossChain--}[`++_isCrossChain()++`]
  235. * {xref-CrossChainEnabledPolygonChild-_crossChainSender--}[`++_crossChainSender()++`]
  236. * {xref-CrossChainEnabledPolygonChild-processMessageFromRoot-uint256-address-bytes-}[`++processMessageFromRoot(, rootMessageSender, data)++`]
  237. [.contract-subindex-inherited]
  238. .ReentrancyGuard
  239. * {xref-ReentrancyGuard-_reentrancyGuardEntered--}[`++_reentrancyGuardEntered()++`]
  240. [.contract-subindex-inherited]
  241. .CrossChainEnabled
  242. [.contract-subindex-inherited]
  243. .IFxMessageProcessor
  244. --
  245. [.contract-item]
  246. [[CrossChainEnabledPolygonChild-constructor-address-]]
  247. ==== `[.contract-item-name]#++constructor++#++(address fxChild)++` [.item-kind]#internal#
  248. [.contract-item]
  249. [[CrossChainEnabledPolygonChild-_isCrossChain--]]
  250. ==== `[.contract-item-name]#++_isCrossChain++#++() → bool++` [.item-kind]#internal#
  251. see {CrossChainEnabled-_isCrossChain}
  252. [.contract-item]
  253. [[CrossChainEnabledPolygonChild-_crossChainSender--]]
  254. ==== `[.contract-item-name]#++_crossChainSender++#++() → address++` [.item-kind]#internal#
  255. see {CrossChainEnabled-_crossChainSender}
  256. [.contract-item]
  257. [[CrossChainEnabledPolygonChild-processMessageFromRoot-uint256-address-bytes-]]
  258. ==== `[.contract-item-name]#++processMessageFromRoot++#++(uint256, address rootMessageSender, bytes data)++` [.item-kind]#external#
  259. External entry point to receive and relay messages originating
  260. from the fxChild.
  261. Non-reentrancy is crucial to avoid a cross-chain call being able
  262. to impersonate anyone by just looping through this with user-defined
  263. arguments.
  264. Note: if _fxChild calls any other function that does a delegate-call,
  265. then security could be compromised.
  266. == Libraries for cross-chain
  267. In addition to the {CrossChainEnabled} abstraction, cross-chain awareness is also available through libraries. These libraries can be used to build complex designs such as contracts with the ability to interact with multiple bridges.
  268. :isCrossChain: pass:normal[xref:#LibAMB-isCrossChain-address-[`++isCrossChain++`]]
  269. :crossChainSender: pass:normal[xref:#LibAMB-crossChainSender-address-[`++crossChainSender++`]]
  270. [.contract]
  271. [[LibAMB]]
  272. === `++LibAMB++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/amb/LibAMB.sol[{github-icon},role=heading-link]
  273. [.hljs-theme-light.nopadding]
  274. ```solidity
  275. import "@openzeppelin/contracts/crosschain/amb/LibAMB.sol";
  276. ```
  277. Primitives for cross-chain aware contracts using the
  278. https://docs.tokenbridge.net/amb-bridge/about-amb-bridge[AMB]
  279. family of bridges.
  280. [.contract-index]
  281. .Functions
  282. --
  283. * {xref-LibAMB-isCrossChain-address-}[`++isCrossChain(bridge)++`]
  284. * {xref-LibAMB-crossChainSender-address-}[`++crossChainSender(bridge)++`]
  285. --
  286. [.contract-item]
  287. [[LibAMB-isCrossChain-address-]]
  288. ==== `[.contract-item-name]#++isCrossChain++#++(address bridge) → bool++` [.item-kind]#internal#
  289. Returns whether the current function call is the result of a
  290. cross-chain message relayed by `bridge`.
  291. [.contract-item]
  292. [[LibAMB-crossChainSender-address-]]
  293. ==== `[.contract-item-name]#++crossChainSender++#++(address bridge) → address++` [.item-kind]#internal#
  294. Returns the address of the sender that triggered the current
  295. cross-chain message through `bridge`.
  296. NOTE: {isCrossChain} should be checked before trying to recover the
  297. sender, as it will revert with `NotCrossChainCall` if the current
  298. function call is not the result of a cross-chain message.
  299. :isCrossChain: pass:normal[xref:#LibArbitrumL1-isCrossChain-address-[`++isCrossChain++`]]
  300. :crossChainSender: pass:normal[xref:#LibArbitrumL1-crossChainSender-address-[`++crossChainSender++`]]
  301. [.contract]
  302. [[LibArbitrumL1]]
  303. === `++LibArbitrumL1++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/arbitrum/LibArbitrumL1.sol[{github-icon},role=heading-link]
  304. [.hljs-theme-light.nopadding]
  305. ```solidity
  306. import "@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL1.sol";
  307. ```
  308. Primitives for cross-chain aware contracts for
  309. https://arbitrum.io/[Arbitrum].
  310. This version should only be used on L1 to process cross-chain messages
  311. originating from L2. For the other side, use {LibArbitrumL2}.
  312. [.contract-index]
  313. .Functions
  314. --
  315. * {xref-LibArbitrumL1-isCrossChain-address-}[`++isCrossChain(bridge)++`]
  316. * {xref-LibArbitrumL1-crossChainSender-address-}[`++crossChainSender(bridge)++`]
  317. --
  318. [.contract-item]
  319. [[LibArbitrumL1-isCrossChain-address-]]
  320. ==== `[.contract-item-name]#++isCrossChain++#++(address bridge) → bool++` [.item-kind]#internal#
  321. Returns whether the current function call is the result of a
  322. cross-chain message relayed by the `bridge`.
  323. [.contract-item]
  324. [[LibArbitrumL1-crossChainSender-address-]]
  325. ==== `[.contract-item-name]#++crossChainSender++#++(address bridge) → address++` [.item-kind]#internal#
  326. Returns the address of the sender that triggered the current
  327. cross-chain message through the `bridge`.
  328. NOTE: {isCrossChain} should be checked before trying to recover the
  329. sender, as it will revert with `NotCrossChainCall` if the current
  330. function call is not the result of a cross-chain message.
  331. :ARBSYS: pass:normal[xref:#LibArbitrumL2-ARBSYS-address[`++ARBSYS++`]]
  332. :isCrossChain: pass:normal[xref:#LibArbitrumL2-isCrossChain-address-[`++isCrossChain++`]]
  333. :crossChainSender: pass:normal[xref:#LibArbitrumL2-crossChainSender-address-[`++crossChainSender++`]]
  334. [.contract]
  335. [[LibArbitrumL2]]
  336. === `++LibArbitrumL2++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/arbitrum/LibArbitrumL2.sol[{github-icon},role=heading-link]
  337. [.hljs-theme-light.nopadding]
  338. ```solidity
  339. import "@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL2.sol";
  340. ```
  341. Primitives for cross-chain aware contracts for
  342. https://arbitrum.io/[Arbitrum].
  343. This version should only be used on L2 to process cross-chain messages
  344. originating from L1. For the other side, use {LibArbitrumL1}.
  345. WARNING: There is currently a bug in Arbitrum that causes this contract to
  346. fail to detect cross-chain calls when deployed behind a proxy. This will be
  347. fixed when the network is upgraded to Arbitrum Nitro, currently scheduled for
  348. August 31st 2022.
  349. [.contract-index]
  350. .Functions
  351. --
  352. * {xref-LibArbitrumL2-isCrossChain-address-}[`++isCrossChain(arbsys)++`]
  353. * {xref-LibArbitrumL2-crossChainSender-address-}[`++crossChainSender(arbsys)++`]
  354. --
  355. [.contract-item]
  356. [[LibArbitrumL2-isCrossChain-address-]]
  357. ==== `[.contract-item-name]#++isCrossChain++#++(address arbsys) → bool++` [.item-kind]#internal#
  358. [.contract-item]
  359. [[LibArbitrumL2-crossChainSender-address-]]
  360. ==== `[.contract-item-name]#++crossChainSender++#++(address arbsys) → address++` [.item-kind]#internal#
  361. Returns the address of the sender that triggered the current
  362. cross-chain message through `arbsys`.
  363. NOTE: {isCrossChain} should be checked before trying to recover the
  364. sender, as it will revert with `NotCrossChainCall` if the current
  365. function call is not the result of a cross-chain message.
  366. :isCrossChain: pass:normal[xref:#LibOptimism-isCrossChain-address-[`++isCrossChain++`]]
  367. :crossChainSender: pass:normal[xref:#LibOptimism-crossChainSender-address-[`++crossChainSender++`]]
  368. [.contract]
  369. [[LibOptimism]]
  370. === `++LibOptimism++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/crosschain/optimism/LibOptimism.sol[{github-icon},role=heading-link]
  371. [.hljs-theme-light.nopadding]
  372. ```solidity
  373. import "@openzeppelin/contracts/crosschain/optimism/LibOptimism.sol";
  374. ```
  375. Primitives for cross-chain aware contracts for https://www.optimism.io/[Optimism].
  376. See the https://community.optimism.io/docs/developers/bridge/messaging/#accessing-msg-sender[documentation]
  377. for the functionality used here.
  378. [.contract-index]
  379. .Functions
  380. --
  381. * {xref-LibOptimism-isCrossChain-address-}[`++isCrossChain(messenger)++`]
  382. * {xref-LibOptimism-crossChainSender-address-}[`++crossChainSender(messenger)++`]
  383. --
  384. [.contract-item]
  385. [[LibOptimism-isCrossChain-address-]]
  386. ==== `[.contract-item-name]#++isCrossChain++#++(address messenger) → bool++` [.item-kind]#internal#
  387. Returns whether the current function call is the result of a
  388. cross-chain message relayed by `messenger`.
  389. [.contract-item]
  390. [[LibOptimism-crossChainSender-address-]]
  391. ==== `[.contract-item-name]#++crossChainSender++#++(address messenger) → address++` [.item-kind]#internal#
  392. Returns the address of the sender that triggered the current
  393. cross-chain message through `messenger`.
  394. NOTE: {isCrossChain} should be checked before trying to recover the
  395. sender, as it will revert with `NotCrossChainCall` if the current
  396. function call is not the result of a cross-chain message.