crosschain.adoc 25 KB

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