proxy.adoc 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378
  1. :github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
  2. :Proxy: pass:normal[xref:proxy.adoc#Proxy[`Proxy`]]
  3. :ERC1967Upgrade: pass:normal[xref:proxy.adoc#ERC1967Upgrade[`ERC1967Upgrade`]]
  4. :ERC1967Proxy: pass:normal[xref:proxy.adoc#ERC1967Proxy[`ERC1967Proxy`]]
  5. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  6. :UUPSUpgradeable: pass:normal[xref:proxy.adoc#UUPSUpgradeable[`UUPSUpgradeable`]]
  7. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  8. :UpgradeableBeacon: pass:normal[xref:proxy.adoc#UpgradeableBeacon[`UpgradeableBeacon`]]
  9. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  10. :Clones: pass:normal[xref:proxy.adoc#Clones[`Clones`]]
  11. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  12. :ERC1967Proxy: pass:normal[xref:proxy.adoc#ERC1967Proxy[`ERC1967Proxy`]]
  13. :UUPSUpgradeable: pass:normal[xref:proxy.adoc#UUPSUpgradeable[`UUPSUpgradeable`]]
  14. :xref-UUPSUpgradeable-_authorizeUpgrade-address-: xref:proxy.adoc#UUPSUpgradeable-_authorizeUpgrade-address-
  15. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  16. :UUPSUpgradeable: pass:normal[xref:proxy.adoc#UUPSUpgradeable[`UUPSUpgradeable`]]
  17. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  18. :xref-Proxy-_implementation--: xref:proxy.adoc#Proxy-_implementation--
  19. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  20. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  21. :xref-Proxy-receive--: xref:proxy.adoc#Proxy-receive--
  22. :xref-Proxy-_beforeFallback--: xref:proxy.adoc#Proxy-_beforeFallback--
  23. :xref-ERC1967Proxy-constructor-address-bytes-: xref:proxy.adoc#ERC1967Proxy-constructor-address-bytes-
  24. :xref-ERC1967Proxy-_implementation--: xref:proxy.adoc#ERC1967Proxy-_implementation--
  25. :xref-ERC1967Upgrade-_getImplementation--: xref:proxy.adoc#ERC1967Upgrade-_getImplementation--
  26. :xref-ERC1967Upgrade-_upgradeTo-address-: xref:proxy.adoc#ERC1967Upgrade-_upgradeTo-address-
  27. :xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-
  28. :xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-
  29. :xref-ERC1967Upgrade-_getAdmin--: xref:proxy.adoc#ERC1967Upgrade-_getAdmin--
  30. :xref-ERC1967Upgrade-_changeAdmin-address-: xref:proxy.adoc#ERC1967Upgrade-_changeAdmin-address-
  31. :xref-ERC1967Upgrade-_getBeacon--: xref:proxy.adoc#ERC1967Upgrade-_getBeacon--
  32. :xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-
  33. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  34. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  35. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  36. :xref-Proxy-receive--: xref:proxy.adoc#Proxy-receive--
  37. :xref-Proxy-_beforeFallback--: xref:proxy.adoc#Proxy-_beforeFallback--
  38. :xref-ERC1967Upgrade-Upgraded-address-: xref:proxy.adoc#ERC1967Upgrade-Upgraded-address-
  39. :xref-ERC1967Upgrade-AdminChanged-address-address-: xref:proxy.adoc#ERC1967Upgrade-AdminChanged-address-address-
  40. :xref-ERC1967Upgrade-BeaconUpgraded-address-: xref:proxy.adoc#ERC1967Upgrade-BeaconUpgraded-address-
  41. :xref-ERC1967Upgrade-_getImplementation--: xref:proxy.adoc#ERC1967Upgrade-_getImplementation--
  42. :xref-ERC1967Upgrade-_upgradeTo-address-: xref:proxy.adoc#ERC1967Upgrade-_upgradeTo-address-
  43. :xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-
  44. :xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-
  45. :xref-ERC1967Upgrade-_getAdmin--: xref:proxy.adoc#ERC1967Upgrade-_getAdmin--
  46. :xref-ERC1967Upgrade-_changeAdmin-address-: xref:proxy.adoc#ERC1967Upgrade-_changeAdmin-address-
  47. :xref-ERC1967Upgrade-_getBeacon--: xref:proxy.adoc#ERC1967Upgrade-_getBeacon--
  48. :xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-
  49. :xref-ERC1967Upgrade-Upgraded-address-: xref:proxy.adoc#ERC1967Upgrade-Upgraded-address-
  50. :xref-ERC1967Upgrade-AdminChanged-address-address-: xref:proxy.adoc#ERC1967Upgrade-AdminChanged-address-address-
  51. :xref-ERC1967Upgrade-BeaconUpgraded-address-: xref:proxy.adoc#ERC1967Upgrade-BeaconUpgraded-address-
  52. :UpgradeableBeacon-_setImplementation: pass:normal[xref:proxy.adoc#UpgradeableBeacon-_setImplementation-address-[`UpgradeableBeacon._setImplementation`]]
  53. :ProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin[`ProxyAdmin`]]
  54. :xref-TransparentUpgradeableProxy-ifAdmin--: xref:proxy.adoc#TransparentUpgradeableProxy-ifAdmin--
  55. :xref-TransparentUpgradeableProxy-constructor-address-address-bytes-: xref:proxy.adoc#TransparentUpgradeableProxy-constructor-address-address-bytes-
  56. :xref-TransparentUpgradeableProxy-admin--: xref:proxy.adoc#TransparentUpgradeableProxy-admin--
  57. :xref-TransparentUpgradeableProxy-implementation--: xref:proxy.adoc#TransparentUpgradeableProxy-implementation--
  58. :xref-TransparentUpgradeableProxy-changeAdmin-address-: xref:proxy.adoc#TransparentUpgradeableProxy-changeAdmin-address-
  59. :xref-TransparentUpgradeableProxy-upgradeTo-address-: xref:proxy.adoc#TransparentUpgradeableProxy-upgradeTo-address-
  60. :xref-TransparentUpgradeableProxy-upgradeToAndCall-address-bytes-: xref:proxy.adoc#TransparentUpgradeableProxy-upgradeToAndCall-address-bytes-
  61. :xref-TransparentUpgradeableProxy-_admin--: xref:proxy.adoc#TransparentUpgradeableProxy-_admin--
  62. :xref-TransparentUpgradeableProxy-_beforeFallback--: xref:proxy.adoc#TransparentUpgradeableProxy-_beforeFallback--
  63. :xref-ERC1967Proxy-_implementation--: xref:proxy.adoc#ERC1967Proxy-_implementation--
  64. :xref-ERC1967Upgrade-_getImplementation--: xref:proxy.adoc#ERC1967Upgrade-_getImplementation--
  65. :xref-ERC1967Upgrade-_upgradeTo-address-: xref:proxy.adoc#ERC1967Upgrade-_upgradeTo-address-
  66. :xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-
  67. :xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-
  68. :xref-ERC1967Upgrade-_getAdmin--: xref:proxy.adoc#ERC1967Upgrade-_getAdmin--
  69. :xref-ERC1967Upgrade-_changeAdmin-address-: xref:proxy.adoc#ERC1967Upgrade-_changeAdmin-address-
  70. :xref-ERC1967Upgrade-_getBeacon--: xref:proxy.adoc#ERC1967Upgrade-_getBeacon--
  71. :xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-
  72. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  73. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  74. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  75. :xref-Proxy-receive--: xref:proxy.adoc#Proxy-receive--
  76. :xref-ERC1967Upgrade-Upgraded-address-: xref:proxy.adoc#ERC1967Upgrade-Upgraded-address-
  77. :xref-ERC1967Upgrade-AdminChanged-address-address-: xref:proxy.adoc#ERC1967Upgrade-AdminChanged-address-address-
  78. :xref-ERC1967Upgrade-BeaconUpgraded-address-: xref:proxy.adoc#ERC1967Upgrade-BeaconUpgraded-address-
  79. :ERC1967Proxy-constructor: pass:normal[xref:proxy.adoc#ERC1967Proxy-constructor-address-bytes-[`ERC1967Proxy.constructor`]]
  80. :ProxyAdmin-getProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin-getProxyAdmin-contract-TransparentUpgradeableProxy-[`ProxyAdmin.getProxyAdmin`]]
  81. :ProxyAdmin-getProxyImplementation: pass:normal[xref:proxy.adoc#ProxyAdmin-getProxyImplementation-contract-TransparentUpgradeableProxy-[`ProxyAdmin.getProxyImplementation`]]
  82. :ProxyAdmin-changeProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin-changeProxyAdmin-contract-TransparentUpgradeableProxy-address-[`ProxyAdmin.changeProxyAdmin`]]
  83. :ProxyAdmin-upgrade: pass:normal[xref:proxy.adoc#ProxyAdmin-upgrade-contract-TransparentUpgradeableProxy-address-[`ProxyAdmin.upgrade`]]
  84. :ProxyAdmin-upgradeAndCall: pass:normal[xref:proxy.adoc#ProxyAdmin-upgradeAndCall-contract-TransparentUpgradeableProxy-address-bytes-[`ProxyAdmin.upgradeAndCall`]]
  85. :Proxy-_beforeFallback: pass:normal[xref:proxy.adoc#Proxy-_beforeFallback--[`Proxy._beforeFallback`]]
  86. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  87. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  88. :xref-ProxyAdmin-getProxyImplementation-contract-TransparentUpgradeableProxy-: xref:proxy.adoc#ProxyAdmin-getProxyImplementation-contract-TransparentUpgradeableProxy-
  89. :xref-ProxyAdmin-getProxyAdmin-contract-TransparentUpgradeableProxy-: xref:proxy.adoc#ProxyAdmin-getProxyAdmin-contract-TransparentUpgradeableProxy-
  90. :xref-ProxyAdmin-changeProxyAdmin-contract-TransparentUpgradeableProxy-address-: xref:proxy.adoc#ProxyAdmin-changeProxyAdmin-contract-TransparentUpgradeableProxy-address-
  91. :xref-ProxyAdmin-upgrade-contract-TransparentUpgradeableProxy-address-: xref:proxy.adoc#ProxyAdmin-upgrade-contract-TransparentUpgradeableProxy-address-
  92. :xref-ProxyAdmin-upgradeAndCall-contract-TransparentUpgradeableProxy-address-bytes-: xref:proxy.adoc#ProxyAdmin-upgradeAndCall-contract-TransparentUpgradeableProxy-address-bytes-
  93. :xref-Ownable-owner--: xref:access.adoc#Ownable-owner--
  94. :xref-Ownable-_checkOwner--: xref:access.adoc#Ownable-_checkOwner--
  95. :xref-Ownable-renounceOwnership--: xref:access.adoc#Ownable-renounceOwnership--
  96. :xref-Ownable-transferOwnership-address-: xref:access.adoc#Ownable-transferOwnership-address-
  97. :xref-Ownable-_transferOwnership-address-: xref:access.adoc#Ownable-_transferOwnership-address-
  98. :xref-Ownable-OwnershipTransferred-address-address-: xref:access.adoc#Ownable-OwnershipTransferred-address-address-
  99. :TransparentUpgradeableProxy-upgradeTo: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy-upgradeTo-address-[`TransparentUpgradeableProxy.upgradeTo`]]
  100. :TransparentUpgradeableProxy-upgradeToAndCall: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy-upgradeToAndCall-address-bytes-[`TransparentUpgradeableProxy.upgradeToAndCall`]]
  101. :UpgradeableBeacon: pass:normal[xref:proxy.adoc#UpgradeableBeacon[`UpgradeableBeacon`]]
  102. :xref-BeaconProxy-constructor-address-bytes-: xref:proxy.adoc#BeaconProxy-constructor-address-bytes-
  103. :xref-BeaconProxy-_beacon--: xref:proxy.adoc#BeaconProxy-_beacon--
  104. :xref-BeaconProxy-_implementation--: xref:proxy.adoc#BeaconProxy-_implementation--
  105. :xref-BeaconProxy-_setBeacon-address-bytes-: xref:proxy.adoc#BeaconProxy-_setBeacon-address-bytes-
  106. :xref-ERC1967Upgrade-_getImplementation--: xref:proxy.adoc#ERC1967Upgrade-_getImplementation--
  107. :xref-ERC1967Upgrade-_upgradeTo-address-: xref:proxy.adoc#ERC1967Upgrade-_upgradeTo-address-
  108. :xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-
  109. :xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-
  110. :xref-ERC1967Upgrade-_getAdmin--: xref:proxy.adoc#ERC1967Upgrade-_getAdmin--
  111. :xref-ERC1967Upgrade-_changeAdmin-address-: xref:proxy.adoc#ERC1967Upgrade-_changeAdmin-address-
  112. :xref-ERC1967Upgrade-_getBeacon--: xref:proxy.adoc#ERC1967Upgrade-_getBeacon--
  113. :xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-
  114. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  115. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  116. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  117. :xref-Proxy-receive--: xref:proxy.adoc#Proxy-receive--
  118. :xref-Proxy-_beforeFallback--: xref:proxy.adoc#Proxy-_beforeFallback--
  119. :xref-ERC1967Upgrade-Upgraded-address-: xref:proxy.adoc#ERC1967Upgrade-Upgraded-address-
  120. :xref-ERC1967Upgrade-AdminChanged-address-address-: xref:proxy.adoc#ERC1967Upgrade-AdminChanged-address-address-
  121. :xref-ERC1967Upgrade-BeaconUpgraded-address-: xref:proxy.adoc#ERC1967Upgrade-BeaconUpgraded-address-
  122. :IBeacon: pass:normal[xref:proxy.adoc#IBeacon[`IBeacon`]]
  123. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  124. :xref-IBeacon-implementation--: xref:proxy.adoc#IBeacon-implementation--
  125. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  126. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  127. :xref-UpgradeableBeacon-constructor-address-: xref:proxy.adoc#UpgradeableBeacon-constructor-address-
  128. :xref-UpgradeableBeacon-implementation--: xref:proxy.adoc#UpgradeableBeacon-implementation--
  129. :xref-UpgradeableBeacon-upgradeTo-address-: xref:proxy.adoc#UpgradeableBeacon-upgradeTo-address-
  130. :xref-Ownable-owner--: xref:access.adoc#Ownable-owner--
  131. :xref-Ownable-_checkOwner--: xref:access.adoc#Ownable-_checkOwner--
  132. :xref-Ownable-renounceOwnership--: xref:access.adoc#Ownable-renounceOwnership--
  133. :xref-Ownable-transferOwnership-address-: xref:access.adoc#Ownable-transferOwnership-address-
  134. :xref-Ownable-_transferOwnership-address-: xref:access.adoc#Ownable-_transferOwnership-address-
  135. :xref-UpgradeableBeacon-Upgraded-address-: xref:proxy.adoc#UpgradeableBeacon-Upgraded-address-
  136. :xref-Ownable-OwnershipTransferred-address-address-: xref:access.adoc#Ownable-OwnershipTransferred-address-address-
  137. :xref-Clones-clone-address-: xref:proxy.adoc#Clones-clone-address-
  138. :xref-Clones-cloneDeterministic-address-bytes32-: xref:proxy.adoc#Clones-cloneDeterministic-address-bytes32-
  139. :xref-Clones-predictDeterministicAddress-address-bytes32-address-: xref:proxy.adoc#Clones-predictDeterministicAddress-address-bytes32-address-
  140. :xref-Clones-predictDeterministicAddress-address-bytes32-: xref:proxy.adoc#Clones-predictDeterministicAddress-address-bytes32-
  141. :Clones-cloneDeterministic: pass:normal[xref:proxy.adoc#Clones-cloneDeterministic-address-bytes32-[`Clones.cloneDeterministic`]]
  142. :Clones-cloneDeterministic: pass:normal[xref:proxy.adoc#Clones-cloneDeterministic-address-bytes32-[`Clones.cloneDeterministic`]]
  143. :ERC1967Proxy-constructor: pass:normal[xref:proxy.adoc#ERC1967Proxy-constructor-address-bytes-[`ERC1967Proxy.constructor`]]
  144. :xref-Initializable-initializer--: xref:proxy.adoc#Initializable-initializer--
  145. :xref-Initializable-reinitializer-uint8-: xref:proxy.adoc#Initializable-reinitializer-uint8-
  146. :xref-Initializable-onlyInitializing--: xref:proxy.adoc#Initializable-onlyInitializing--
  147. :xref-Initializable-_disableInitializers--: xref:proxy.adoc#Initializable-_disableInitializers--
  148. :xref-Initializable-_getInitializedVersion--: xref:proxy.adoc#Initializable-_getInitializedVersion--
  149. :xref-Initializable-_isInitializing--: xref:proxy.adoc#Initializable-_isInitializing--
  150. :xref-Initializable-Initialized-uint8-: xref:proxy.adoc#Initializable-Initialized-uint8-
  151. :ERC1967Proxy: pass:normal[xref:proxy.adoc#ERC1967Proxy[`ERC1967Proxy`]]
  152. :xref-UUPSUpgradeable-onlyProxy--: xref:proxy.adoc#UUPSUpgradeable-onlyProxy--
  153. :xref-UUPSUpgradeable-notDelegated--: xref:proxy.adoc#UUPSUpgradeable-notDelegated--
  154. :xref-UUPSUpgradeable-proxiableUUID--: xref:proxy.adoc#UUPSUpgradeable-proxiableUUID--
  155. :xref-UUPSUpgradeable-upgradeTo-address-: xref:proxy.adoc#UUPSUpgradeable-upgradeTo-address-
  156. :xref-UUPSUpgradeable-upgradeToAndCall-address-bytes-: xref:proxy.adoc#UUPSUpgradeable-upgradeToAndCall-address-bytes-
  157. :xref-UUPSUpgradeable-_authorizeUpgrade-address-: xref:proxy.adoc#UUPSUpgradeable-_authorizeUpgrade-address-
  158. :xref-ERC1967Upgrade-_getImplementation--: xref:proxy.adoc#ERC1967Upgrade-_getImplementation--
  159. :xref-ERC1967Upgrade-_upgradeTo-address-: xref:proxy.adoc#ERC1967Upgrade-_upgradeTo-address-
  160. :xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-
  161. :xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-
  162. :xref-ERC1967Upgrade-_getAdmin--: xref:proxy.adoc#ERC1967Upgrade-_getAdmin--
  163. :xref-ERC1967Upgrade-_changeAdmin-address-: xref:proxy.adoc#ERC1967Upgrade-_changeAdmin-address-
  164. :xref-ERC1967Upgrade-_getBeacon--: xref:proxy.adoc#ERC1967Upgrade-_getBeacon--
  165. :xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-: xref:proxy.adoc#ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-
  166. :xref-ERC1967Upgrade-Upgraded-address-: xref:proxy.adoc#ERC1967Upgrade-Upgraded-address-
  167. :xref-ERC1967Upgrade-AdminChanged-address-address-: xref:proxy.adoc#ERC1967Upgrade-AdminChanged-address-address-
  168. :xref-ERC1967Upgrade-BeaconUpgraded-address-: xref:proxy.adoc#ERC1967Upgrade-BeaconUpgraded-address-
  169. :Ownable-onlyOwner: pass:normal[xref:access.adoc#Ownable-onlyOwner--[`Ownable.onlyOwner`]]
  170. = Proxies
  171. [.readme-notice]
  172. NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/proxy
  173. This is a low-level set of contracts implementing different proxy patterns with and without upgradeability. For an in-depth overview of this pattern check out the xref:upgrades-plugins::proxies.adoc[Proxy Upgrade Pattern] page.
  174. Most of the proxies below are built on an abstract base contract.
  175. - {Proxy}: Abstract contract implementing the core delegation functionality.
  176. In order to avoid clashes with the storage variables of the implementation contract behind a proxy, we use https://eips.ethereum.org/EIPS/eip-1967[EIP1967] storage slots.
  177. - {ERC1967Upgrade}: Internal functions to get and set the storage slots defined in EIP1967.
  178. - {ERC1967Proxy}: A proxy using EIP1967 storage slots. Not upgradeable by default.
  179. There are two alternative ways to add upgradeability to an ERC1967 proxy. Their differences are explained below in <<transparent-vs-uups>>.
  180. - {TransparentUpgradeableProxy}: A proxy with a built in admin and upgrade interface.
  181. - {UUPSUpgradeable}: An upgradeability mechanism to be included in the implementation contract.
  182. CAUTION: Using upgradeable proxies correctly and securely is a difficult task that requires deep knowledge of the proxy pattern, Solidity, and the EVM. Unless you want a lot of low level control, we recommend using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins] for Truffle and Hardhat.
  183. A different family of proxies are beacon proxies. This pattern, popularized by Dharma, allows multiple proxies to be upgraded to a different implementation in a single transaction.
  184. - {BeaconProxy}: A proxy that retrieves its implementation from a beacon contract.
  185. - {UpgradeableBeacon}: A beacon contract with a built in admin that can upgrade the {BeaconProxy} pointing to it.
  186. In this pattern, the proxy contract doesn't hold the implementation address in storage like an ERC1967 proxy. Instead, the address is stored in a separate beacon contract. The `upgrade` operations are sent to the beacon instead of to the proxy contract, and all proxies that follow that beacon are automatically upgraded.
  187. Outside the realm of upgradeability, proxies can also be useful to make cheap contract clones, such as those created by an on-chain factory contract that creates many instances of the same contract. These instances are designed to be both cheap to deploy, and cheap to call.
  188. - {Clones}: A library that can deploy cheap minimal non-upgradeable proxies.
  189. [[transparent-vs-uups]]
  190. == Transparent vs UUPS Proxies
  191. The original proxies included in OpenZeppelin followed the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[Transparent Proxy Pattern]. While this pattern is still provided, our recommendation is now shifting towards UUPS proxies, which are both lightweight and versatile. The name UUPS comes from https://eips.ethereum.org/EIPS/eip-1822[EIP1822], which first documented the pattern.
  192. While both of these share the same interface for upgrades, in UUPS proxies the upgrade is handled by the implementation, and can eventually be removed. Transparent proxies, on the other hand, include the upgrade and admin logic in the proxy itself. This means {TransparentUpgradeableProxy} is more expensive to deploy than what is possible with UUPS proxies.
  193. UUPS proxies are implemented using an {ERC1967Proxy}. Note that this proxy is not by itself upgradeable. It is the role of the implementation to include, alongside the contract's logic, all the code necessary to update the implementation's address that is stored at a specific slot in the proxy's storage space. This is where the {UUPSUpgradeable} contract comes in. Inheriting from it (and overriding the {xref-UUPSUpgradeable-_authorizeUpgrade-address-}[`_authorizeUpgrade`] function with the relevant access control mechanism) will turn your contract into a UUPS compliant implementation.
  194. Note that since both proxies use the same storage slot for the implementation address, using a UUPS compliant implementation with a {TransparentUpgradeableProxy} might allow non-admins to perform upgrade operations.
  195. By default, the upgrade functionality included in {UUPSUpgradeable} contains a security mechanism that will prevent any upgrades to a non UUPS compliant implementation. This prevents upgrades to an implementation contract that wouldn't contain the necessary upgrade mechanism, as it would lock the upgradeability of the proxy forever. This security mechanism can be bypassed by either of:
  196. - Adding a flag mechanism in the implementation that will disable the upgrade function when triggered.
  197. - Upgrading to an implementation that features an upgrade mechanism without the additional security check, and then upgrading again to another implementation without the upgrade mechanism.
  198. The current implementation of this security mechanism uses https://eips.ethereum.org/EIPS/eip-1822[EIP1822] to detect the storage slot used by the implementation. A previous implementation, now deprecated, relied on a rollback check. It is possible to upgrade from a contract using the old mechanism to a new one. The inverse is however not possible, as old implementations (before version 4.5) did not include the `ERC1822` interface.
  199. == Core
  200. :_delegate: pass:normal[xref:#Proxy-_delegate-address-[`++_delegate++`]]
  201. :_implementation: pass:normal[xref:#Proxy-_implementation--[`++_implementation++`]]
  202. :_fallback: pass:normal[xref:#Proxy-_fallback--[`++_fallback++`]]
  203. :fallback: pass:normal[xref:#Proxy-fallback--[`++fallback++`]]
  204. :receive: pass:normal[xref:#Proxy-receive--[`++receive++`]]
  205. :_beforeFallback: pass:normal[xref:#Proxy-_beforeFallback--[`++_beforeFallback++`]]
  206. [.contract]
  207. [[Proxy]]
  208. === `++Proxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/Proxy.sol[{github-icon},role=heading-link]
  209. [.hljs-theme-light.nopadding]
  210. ```solidity
  211. import "@openzeppelin/contracts/proxy/Proxy.sol";
  212. ```
  213. This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
  214. instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
  215. be specified by overriding the virtual {_implementation} function.
  216. Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
  217. different contract through the {_delegate} function.
  218. The success and return data of the delegated call will be returned back to the caller of the proxy.
  219. [.contract-index]
  220. .Functions
  221. --
  222. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  223. * {xref-Proxy-_implementation--}[`++_implementation()++`]
  224. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  225. * {xref-Proxy-fallback--}[`++fallback()++`]
  226. * {xref-Proxy-receive--}[`++receive()++`]
  227. * {xref-Proxy-_beforeFallback--}[`++_beforeFallback()++`]
  228. --
  229. [.contract-item]
  230. [[Proxy-_delegate-address-]]
  231. ==== `[.contract-item-name]#++_delegate++#++(address implementation)++` [.item-kind]#internal#
  232. Delegates the current call to `implementation`.
  233. This function does not return to its internal call site, it will return directly to the external caller.
  234. [.contract-item]
  235. [[Proxy-_implementation--]]
  236. ==== `[.contract-item-name]#++_implementation++#++() → address++` [.item-kind]#internal#
  237. This is a virtual function that should be overridden so it returns the address to which the fallback function
  238. and {_fallback} should delegate.
  239. [.contract-item]
  240. [[Proxy-_fallback--]]
  241. ==== `[.contract-item-name]#++_fallback++#++()++` [.item-kind]#internal#
  242. Delegates the current call to the address returned by `_implementation()`.
  243. This function does not return to its internal call site, it will return directly to the external caller.
  244. [.contract-item]
  245. [[Proxy-fallback--]]
  246. ==== `[.contract-item-name]#++fallback++#++()++` [.item-kind]#external#
  247. Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
  248. function in the contract matches the call data.
  249. [.contract-item]
  250. [[Proxy-receive--]]
  251. ==== `[.contract-item-name]#++receive++#++()++` [.item-kind]#external#
  252. Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
  253. is empty.
  254. [.contract-item]
  255. [[Proxy-_beforeFallback--]]
  256. ==== `[.contract-item-name]#++_beforeFallback++#++()++` [.item-kind]#internal#
  257. Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
  258. call, or as part of the Solidity `fallback` or `receive` functions.
  259. If overridden should call `super._beforeFallback()`.
  260. == ERC1967
  261. :constructor: pass:normal[xref:#ERC1967Proxy-constructor-address-bytes-[`++constructor++`]]
  262. :_implementation: pass:normal[xref:#ERC1967Proxy-_implementation--[`++_implementation++`]]
  263. [.contract]
  264. [[ERC1967Proxy]]
  265. === `++ERC1967Proxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/ERC1967/ERC1967Proxy.sol[{github-icon},role=heading-link]
  266. [.hljs-theme-light.nopadding]
  267. ```solidity
  268. import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
  269. ```
  270. This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
  271. implementation address that can be changed. This address is stored in storage in the location specified by
  272. https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
  273. implementation behind the proxy.
  274. [.contract-index]
  275. .Functions
  276. --
  277. * {xref-ERC1967Proxy-constructor-address-bytes-}[`++constructor(_logic, _data)++`]
  278. * {xref-ERC1967Proxy-_implementation--}[`++_implementation()++`]
  279. [.contract-subindex-inherited]
  280. .ERC1967Upgrade
  281. * {xref-ERC1967Upgrade-_getImplementation--}[`++_getImplementation()++`]
  282. * {xref-ERC1967Upgrade-_upgradeTo-address-}[`++_upgradeTo(newImplementation)++`]
  283. * {xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-}[`++_upgradeToAndCall(newImplementation, data, forceCall)++`]
  284. * {xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-}[`++_upgradeToAndCallUUPS(newImplementation, data, forceCall)++`]
  285. * {xref-ERC1967Upgrade-_getAdmin--}[`++_getAdmin()++`]
  286. * {xref-ERC1967Upgrade-_changeAdmin-address-}[`++_changeAdmin(newAdmin)++`]
  287. * {xref-ERC1967Upgrade-_getBeacon--}[`++_getBeacon()++`]
  288. * {xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-}[`++_upgradeBeaconToAndCall(newBeacon, data, forceCall)++`]
  289. [.contract-subindex-inherited]
  290. .Proxy
  291. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  292. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  293. * {xref-Proxy-fallback--}[`++fallback()++`]
  294. * {xref-Proxy-receive--}[`++receive()++`]
  295. * {xref-Proxy-_beforeFallback--}[`++_beforeFallback()++`]
  296. --
  297. [.contract-index]
  298. .Events
  299. --
  300. [.contract-subindex-inherited]
  301. .ERC1967Upgrade
  302. * {xref-ERC1967Upgrade-Upgraded-address-}[`++Upgraded(implementation)++`]
  303. * {xref-ERC1967Upgrade-AdminChanged-address-address-}[`++AdminChanged(previousAdmin, newAdmin)++`]
  304. * {xref-ERC1967Upgrade-BeaconUpgraded-address-}[`++BeaconUpgraded(beacon)++`]
  305. [.contract-subindex-inherited]
  306. .Proxy
  307. --
  308. [.contract-item]
  309. [[ERC1967Proxy-constructor-address-bytes-]]
  310. ==== `[.contract-item-name]#++constructor++#++(address _logic, bytes _data)++` [.item-kind]#public#
  311. Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
  312. If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
  313. function call, and allows initializing the storage of the proxy like a Solidity constructor.
  314. [.contract-item]
  315. [[ERC1967Proxy-_implementation--]]
  316. ==== `[.contract-item-name]#++_implementation++#++() → address impl++` [.item-kind]#internal#
  317. Returns the current implementation address.
  318. :_ROLLBACK_SLOT: pass:normal[xref:#ERC1967Upgrade-_ROLLBACK_SLOT-bytes32[`++_ROLLBACK_SLOT++`]]
  319. :_IMPLEMENTATION_SLOT: pass:normal[xref:#ERC1967Upgrade-_IMPLEMENTATION_SLOT-bytes32[`++_IMPLEMENTATION_SLOT++`]]
  320. :Upgraded: pass:normal[xref:#ERC1967Upgrade-Upgraded-address-[`++Upgraded++`]]
  321. :_getImplementation: pass:normal[xref:#ERC1967Upgrade-_getImplementation--[`++_getImplementation++`]]
  322. :_setImplementation: pass:normal[xref:#ERC1967Upgrade-_setImplementation-address-[`++_setImplementation++`]]
  323. :_upgradeTo: pass:normal[xref:#ERC1967Upgrade-_upgradeTo-address-[`++_upgradeTo++`]]
  324. :_upgradeToAndCall: pass:normal[xref:#ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-[`++_upgradeToAndCall++`]]
  325. :_upgradeToAndCallUUPS: pass:normal[xref:#ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-[`++_upgradeToAndCallUUPS++`]]
  326. :_ADMIN_SLOT: pass:normal[xref:#ERC1967Upgrade-_ADMIN_SLOT-bytes32[`++_ADMIN_SLOT++`]]
  327. :AdminChanged: pass:normal[xref:#ERC1967Upgrade-AdminChanged-address-address-[`++AdminChanged++`]]
  328. :_getAdmin: pass:normal[xref:#ERC1967Upgrade-_getAdmin--[`++_getAdmin++`]]
  329. :_setAdmin: pass:normal[xref:#ERC1967Upgrade-_setAdmin-address-[`++_setAdmin++`]]
  330. :_changeAdmin: pass:normal[xref:#ERC1967Upgrade-_changeAdmin-address-[`++_changeAdmin++`]]
  331. :_BEACON_SLOT: pass:normal[xref:#ERC1967Upgrade-_BEACON_SLOT-bytes32[`++_BEACON_SLOT++`]]
  332. :BeaconUpgraded: pass:normal[xref:#ERC1967Upgrade-BeaconUpgraded-address-[`++BeaconUpgraded++`]]
  333. :_getBeacon: pass:normal[xref:#ERC1967Upgrade-_getBeacon--[`++_getBeacon++`]]
  334. :_setBeacon: pass:normal[xref:#ERC1967Upgrade-_setBeacon-address-[`++_setBeacon++`]]
  335. :_upgradeBeaconToAndCall: pass:normal[xref:#ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-[`++_upgradeBeaconToAndCall++`]]
  336. [.contract]
  337. [[ERC1967Upgrade]]
  338. === `++ERC1967Upgrade++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/ERC1967/ERC1967Upgrade.sol[{github-icon},role=heading-link]
  339. [.hljs-theme-light.nopadding]
  340. ```solidity
  341. import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";
  342. ```
  343. This abstract contract provides getters and event emitting update functions for
  344. https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
  345. _Available since v4.1._
  346. [.contract-index]
  347. .Functions
  348. --
  349. * {xref-ERC1967Upgrade-_getImplementation--}[`++_getImplementation()++`]
  350. * {xref-ERC1967Upgrade-_upgradeTo-address-}[`++_upgradeTo(newImplementation)++`]
  351. * {xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-}[`++_upgradeToAndCall(newImplementation, data, forceCall)++`]
  352. * {xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-}[`++_upgradeToAndCallUUPS(newImplementation, data, forceCall)++`]
  353. * {xref-ERC1967Upgrade-_getAdmin--}[`++_getAdmin()++`]
  354. * {xref-ERC1967Upgrade-_changeAdmin-address-}[`++_changeAdmin(newAdmin)++`]
  355. * {xref-ERC1967Upgrade-_getBeacon--}[`++_getBeacon()++`]
  356. * {xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-}[`++_upgradeBeaconToAndCall(newBeacon, data, forceCall)++`]
  357. --
  358. [.contract-index]
  359. .Events
  360. --
  361. * {xref-ERC1967Upgrade-Upgraded-address-}[`++Upgraded(implementation)++`]
  362. * {xref-ERC1967Upgrade-AdminChanged-address-address-}[`++AdminChanged(previousAdmin, newAdmin)++`]
  363. * {xref-ERC1967Upgrade-BeaconUpgraded-address-}[`++BeaconUpgraded(beacon)++`]
  364. --
  365. [.contract-item]
  366. [[ERC1967Upgrade-_getImplementation--]]
  367. ==== `[.contract-item-name]#++_getImplementation++#++() → address++` [.item-kind]#internal#
  368. Returns the current implementation address.
  369. [.contract-item]
  370. [[ERC1967Upgrade-_upgradeTo-address-]]
  371. ==== `[.contract-item-name]#++_upgradeTo++#++(address newImplementation)++` [.item-kind]#internal#
  372. Perform implementation upgrade
  373. Emits an {Upgraded} event.
  374. [.contract-item]
  375. [[ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-]]
  376. ==== `[.contract-item-name]#++_upgradeToAndCall++#++(address newImplementation, bytes data, bool forceCall)++` [.item-kind]#internal#
  377. Perform implementation upgrade with additional setup call.
  378. Emits an {Upgraded} event.
  379. [.contract-item]
  380. [[ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-]]
  381. ==== `[.contract-item-name]#++_upgradeToAndCallUUPS++#++(address newImplementation, bytes data, bool forceCall)++` [.item-kind]#internal#
  382. Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
  383. Emits an {Upgraded} event.
  384. [.contract-item]
  385. [[ERC1967Upgrade-_getAdmin--]]
  386. ==== `[.contract-item-name]#++_getAdmin++#++() → address++` [.item-kind]#internal#
  387. Returns the current admin.
  388. [.contract-item]
  389. [[ERC1967Upgrade-_changeAdmin-address-]]
  390. ==== `[.contract-item-name]#++_changeAdmin++#++(address newAdmin)++` [.item-kind]#internal#
  391. Changes the admin of the proxy.
  392. Emits an {AdminChanged} event.
  393. [.contract-item]
  394. [[ERC1967Upgrade-_getBeacon--]]
  395. ==== `[.contract-item-name]#++_getBeacon++#++() → address++` [.item-kind]#internal#
  396. Returns the current beacon.
  397. [.contract-item]
  398. [[ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-]]
  399. ==== `[.contract-item-name]#++_upgradeBeaconToAndCall++#++(address newBeacon, bytes data, bool forceCall)++` [.item-kind]#internal#
  400. Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
  401. not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
  402. Emits a {BeaconUpgraded} event.
  403. [.contract-item]
  404. [[ERC1967Upgrade-Upgraded-address-]]
  405. ==== `[.contract-item-name]#++Upgraded++#++(address implementation)++` [.item-kind]#event#
  406. Emitted when the implementation is upgraded.
  407. [.contract-item]
  408. [[ERC1967Upgrade-AdminChanged-address-address-]]
  409. ==== `[.contract-item-name]#++AdminChanged++#++(address previousAdmin, address newAdmin)++` [.item-kind]#event#
  410. Emitted when the admin account has changed.
  411. [.contract-item]
  412. [[ERC1967Upgrade-BeaconUpgraded-address-]]
  413. ==== `[.contract-item-name]#++BeaconUpgraded++#++(address beacon)++` [.item-kind]#event#
  414. Emitted when the beacon is upgraded.
  415. == Transparent Proxy
  416. :constructor: pass:normal[xref:#TransparentUpgradeableProxy-constructor-address-address-bytes-[`++constructor++`]]
  417. :ifAdmin: pass:normal[xref:#TransparentUpgradeableProxy-ifAdmin--[`++ifAdmin++`]]
  418. :admin: pass:normal[xref:#TransparentUpgradeableProxy-admin--[`++admin++`]]
  419. :implementation: pass:normal[xref:#TransparentUpgradeableProxy-implementation--[`++implementation++`]]
  420. :changeAdmin: pass:normal[xref:#TransparentUpgradeableProxy-changeAdmin-address-[`++changeAdmin++`]]
  421. :upgradeTo: pass:normal[xref:#TransparentUpgradeableProxy-upgradeTo-address-[`++upgradeTo++`]]
  422. :upgradeToAndCall: pass:normal[xref:#TransparentUpgradeableProxy-upgradeToAndCall-address-bytes-[`++upgradeToAndCall++`]]
  423. :_admin: pass:normal[xref:#TransparentUpgradeableProxy-_admin--[`++_admin++`]]
  424. :_beforeFallback: pass:normal[xref:#TransparentUpgradeableProxy-_beforeFallback--[`++_beforeFallback++`]]
  425. [.contract]
  426. [[TransparentUpgradeableProxy]]
  427. === `++TransparentUpgradeableProxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol[{github-icon},role=heading-link]
  428. [.hljs-theme-light.nopadding]
  429. ```solidity
  430. import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
  431. ```
  432. This contract implements a proxy that is upgradeable by an admin.
  433. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
  434. clashing], which can potentially be used in an attack, this contract uses the
  435. https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
  436. things that go hand in hand:
  437. 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
  438. that call matches one of the admin functions exposed by the proxy itself.
  439. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
  440. implementation. If the admin tries to call a function on the implementation it will fail with an error that says
  441. "admin cannot fallback to proxy target".
  442. These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
  443. the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
  444. to sudden errors when trying to call a function from the proxy implementation.
  445. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
  446. you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
  447. [.contract-index]
  448. .Modifiers
  449. --
  450. * {xref-TransparentUpgradeableProxy-ifAdmin--}[`++ifAdmin()++`]
  451. --
  452. [.contract-index]
  453. .Functions
  454. --
  455. * {xref-TransparentUpgradeableProxy-constructor-address-address-bytes-}[`++constructor(_logic, admin_, _data)++`]
  456. * {xref-TransparentUpgradeableProxy-admin--}[`++admin()++`]
  457. * {xref-TransparentUpgradeableProxy-implementation--}[`++implementation()++`]
  458. * {xref-TransparentUpgradeableProxy-changeAdmin-address-}[`++changeAdmin(newAdmin)++`]
  459. * {xref-TransparentUpgradeableProxy-upgradeTo-address-}[`++upgradeTo(newImplementation)++`]
  460. * {xref-TransparentUpgradeableProxy-upgradeToAndCall-address-bytes-}[`++upgradeToAndCall(newImplementation, data)++`]
  461. * {xref-TransparentUpgradeableProxy-_admin--}[`++_admin()++`]
  462. * {xref-TransparentUpgradeableProxy-_beforeFallback--}[`++_beforeFallback()++`]
  463. [.contract-subindex-inherited]
  464. .ERC1967Proxy
  465. * {xref-ERC1967Proxy-_implementation--}[`++_implementation()++`]
  466. [.contract-subindex-inherited]
  467. .ERC1967Upgrade
  468. * {xref-ERC1967Upgrade-_getImplementation--}[`++_getImplementation()++`]
  469. * {xref-ERC1967Upgrade-_upgradeTo-address-}[`++_upgradeTo(newImplementation)++`]
  470. * {xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-}[`++_upgradeToAndCall(newImplementation, data, forceCall)++`]
  471. * {xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-}[`++_upgradeToAndCallUUPS(newImplementation, data, forceCall)++`]
  472. * {xref-ERC1967Upgrade-_getAdmin--}[`++_getAdmin()++`]
  473. * {xref-ERC1967Upgrade-_changeAdmin-address-}[`++_changeAdmin(newAdmin)++`]
  474. * {xref-ERC1967Upgrade-_getBeacon--}[`++_getBeacon()++`]
  475. * {xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-}[`++_upgradeBeaconToAndCall(newBeacon, data, forceCall)++`]
  476. [.contract-subindex-inherited]
  477. .Proxy
  478. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  479. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  480. * {xref-Proxy-fallback--}[`++fallback()++`]
  481. * {xref-Proxy-receive--}[`++receive()++`]
  482. --
  483. [.contract-index]
  484. .Events
  485. --
  486. [.contract-subindex-inherited]
  487. .ERC1967Proxy
  488. [.contract-subindex-inherited]
  489. .ERC1967Upgrade
  490. * {xref-ERC1967Upgrade-Upgraded-address-}[`++Upgraded(implementation)++`]
  491. * {xref-ERC1967Upgrade-AdminChanged-address-address-}[`++AdminChanged(previousAdmin, newAdmin)++`]
  492. * {xref-ERC1967Upgrade-BeaconUpgraded-address-}[`++BeaconUpgraded(beacon)++`]
  493. [.contract-subindex-inherited]
  494. .Proxy
  495. --
  496. [.contract-item]
  497. [[TransparentUpgradeableProxy-ifAdmin--]]
  498. ==== `[.contract-item-name]#++ifAdmin++#++()++` [.item-kind]#modifier#
  499. Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
  500. [.contract-item]
  501. [[TransparentUpgradeableProxy-constructor-address-address-bytes-]]
  502. ==== `[.contract-item-name]#++constructor++#++(address _logic, address admin_, bytes _data)++` [.item-kind]#public#
  503. Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
  504. optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
  505. [.contract-item]
  506. [[TransparentUpgradeableProxy-admin--]]
  507. ==== `[.contract-item-name]#++admin++#++() → address admin_++` [.item-kind]#external#
  508. Returns the current admin.
  509. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
  510. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
  511. https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
  512. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
  513. [.contract-item]
  514. [[TransparentUpgradeableProxy-implementation--]]
  515. ==== `[.contract-item-name]#++implementation++#++() → address implementation_++` [.item-kind]#external#
  516. Returns the current implementation.
  517. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
  518. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
  519. https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
  520. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
  521. [.contract-item]
  522. [[TransparentUpgradeableProxy-changeAdmin-address-]]
  523. ==== `[.contract-item-name]#++changeAdmin++#++(address newAdmin)++` [.item-kind]#external#
  524. Changes the admin of the proxy.
  525. Emits an {AdminChanged} event.
  526. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
  527. [.contract-item]
  528. [[TransparentUpgradeableProxy-upgradeTo-address-]]
  529. ==== `[.contract-item-name]#++upgradeTo++#++(address newImplementation)++` [.item-kind]#external#
  530. Upgrade the implementation of the proxy.
  531. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
  532. [.contract-item]
  533. [[TransparentUpgradeableProxy-upgradeToAndCall-address-bytes-]]
  534. ==== `[.contract-item-name]#++upgradeToAndCall++#++(address newImplementation, bytes data)++` [.item-kind]#external#
  535. Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
  536. by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
  537. proxied contract.
  538. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
  539. [.contract-item]
  540. [[TransparentUpgradeableProxy-_admin--]]
  541. ==== `[.contract-item-name]#++_admin++#++() → address++` [.item-kind]#internal#
  542. Returns the current admin.
  543. [.contract-item]
  544. [[TransparentUpgradeableProxy-_beforeFallback--]]
  545. ==== `[.contract-item-name]#++_beforeFallback++#++()++` [.item-kind]#internal#
  546. Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
  547. :getProxyImplementation: pass:normal[xref:#ProxyAdmin-getProxyImplementation-contract-TransparentUpgradeableProxy-[`++getProxyImplementation++`]]
  548. :getProxyAdmin: pass:normal[xref:#ProxyAdmin-getProxyAdmin-contract-TransparentUpgradeableProxy-[`++getProxyAdmin++`]]
  549. :changeProxyAdmin: pass:normal[xref:#ProxyAdmin-changeProxyAdmin-contract-TransparentUpgradeableProxy-address-[`++changeProxyAdmin++`]]
  550. :upgrade: pass:normal[xref:#ProxyAdmin-upgrade-contract-TransparentUpgradeableProxy-address-[`++upgrade++`]]
  551. :upgradeAndCall: pass:normal[xref:#ProxyAdmin-upgradeAndCall-contract-TransparentUpgradeableProxy-address-bytes-[`++upgradeAndCall++`]]
  552. [.contract]
  553. [[ProxyAdmin]]
  554. === `++ProxyAdmin++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/transparent/ProxyAdmin.sol[{github-icon},role=heading-link]
  555. [.hljs-theme-light.nopadding]
  556. ```solidity
  557. import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
  558. ```
  559. This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
  560. explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
  561. [.contract-index]
  562. .Functions
  563. --
  564. * {xref-ProxyAdmin-getProxyImplementation-contract-TransparentUpgradeableProxy-}[`++getProxyImplementation(proxy)++`]
  565. * {xref-ProxyAdmin-getProxyAdmin-contract-TransparentUpgradeableProxy-}[`++getProxyAdmin(proxy)++`]
  566. * {xref-ProxyAdmin-changeProxyAdmin-contract-TransparentUpgradeableProxy-address-}[`++changeProxyAdmin(proxy, newAdmin)++`]
  567. * {xref-ProxyAdmin-upgrade-contract-TransparentUpgradeableProxy-address-}[`++upgrade(proxy, implementation)++`]
  568. * {xref-ProxyAdmin-upgradeAndCall-contract-TransparentUpgradeableProxy-address-bytes-}[`++upgradeAndCall(proxy, implementation, data)++`]
  569. [.contract-subindex-inherited]
  570. .Ownable
  571. * {xref-Ownable-owner--}[`++owner()++`]
  572. * {xref-Ownable-_checkOwner--}[`++_checkOwner()++`]
  573. * {xref-Ownable-renounceOwnership--}[`++renounceOwnership()++`]
  574. * {xref-Ownable-transferOwnership-address-}[`++transferOwnership(newOwner)++`]
  575. * {xref-Ownable-_transferOwnership-address-}[`++_transferOwnership(newOwner)++`]
  576. --
  577. [.contract-index]
  578. .Events
  579. --
  580. [.contract-subindex-inherited]
  581. .Ownable
  582. * {xref-Ownable-OwnershipTransferred-address-address-}[`++OwnershipTransferred(previousOwner, newOwner)++`]
  583. --
  584. [.contract-item]
  585. [[ProxyAdmin-getProxyImplementation-contract-TransparentUpgradeableProxy-]]
  586. ==== `[.contract-item-name]#++getProxyImplementation++#++(contract TransparentUpgradeableProxy proxy) → address++` [.item-kind]#public#
  587. Returns the current implementation of `proxy`.
  588. Requirements:
  589. - This contract must be the admin of `proxy`.
  590. [.contract-item]
  591. [[ProxyAdmin-getProxyAdmin-contract-TransparentUpgradeableProxy-]]
  592. ==== `[.contract-item-name]#++getProxyAdmin++#++(contract TransparentUpgradeableProxy proxy) → address++` [.item-kind]#public#
  593. Returns the current admin of `proxy`.
  594. Requirements:
  595. - This contract must be the admin of `proxy`.
  596. [.contract-item]
  597. [[ProxyAdmin-changeProxyAdmin-contract-TransparentUpgradeableProxy-address-]]
  598. ==== `[.contract-item-name]#++changeProxyAdmin++#++(contract TransparentUpgradeableProxy proxy, address newAdmin)++` [.item-kind]#public#
  599. Changes the admin of `proxy` to `newAdmin`.
  600. Requirements:
  601. - This contract must be the current admin of `proxy`.
  602. [.contract-item]
  603. [[ProxyAdmin-upgrade-contract-TransparentUpgradeableProxy-address-]]
  604. ==== `[.contract-item-name]#++upgrade++#++(contract TransparentUpgradeableProxy proxy, address implementation)++` [.item-kind]#public#
  605. Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
  606. Requirements:
  607. - This contract must be the admin of `proxy`.
  608. [.contract-item]
  609. [[ProxyAdmin-upgradeAndCall-contract-TransparentUpgradeableProxy-address-bytes-]]
  610. ==== `[.contract-item-name]#++upgradeAndCall++#++(contract TransparentUpgradeableProxy proxy, address implementation, bytes data)++` [.item-kind]#public#
  611. Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
  612. {TransparentUpgradeableProxy-upgradeToAndCall}.
  613. Requirements:
  614. - This contract must be the admin of `proxy`.
  615. == Beacon
  616. :constructor: pass:normal[xref:#BeaconProxy-constructor-address-bytes-[`++constructor++`]]
  617. :_beacon: pass:normal[xref:#BeaconProxy-_beacon--[`++_beacon++`]]
  618. :_implementation: pass:normal[xref:#BeaconProxy-_implementation--[`++_implementation++`]]
  619. :_setBeacon: pass:normal[xref:#BeaconProxy-_setBeacon-address-bytes-[`++_setBeacon++`]]
  620. [.contract]
  621. [[BeaconProxy]]
  622. === `++BeaconProxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/beacon/BeaconProxy.sol[{github-icon},role=heading-link]
  623. [.hljs-theme-light.nopadding]
  624. ```solidity
  625. import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
  626. ```
  627. This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
  628. The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't
  629. conflict with the storage layout of the implementation behind the proxy.
  630. _Available since v3.4._
  631. [.contract-index]
  632. .Functions
  633. --
  634. * {xref-BeaconProxy-constructor-address-bytes-}[`++constructor(beacon, data)++`]
  635. * {xref-BeaconProxy-_beacon--}[`++_beacon()++`]
  636. * {xref-BeaconProxy-_implementation--}[`++_implementation()++`]
  637. * {xref-BeaconProxy-_setBeacon-address-bytes-}[`++_setBeacon(beacon, data)++`]
  638. [.contract-subindex-inherited]
  639. .ERC1967Upgrade
  640. * {xref-ERC1967Upgrade-_getImplementation--}[`++_getImplementation()++`]
  641. * {xref-ERC1967Upgrade-_upgradeTo-address-}[`++_upgradeTo(newImplementation)++`]
  642. * {xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-}[`++_upgradeToAndCall(newImplementation, data, forceCall)++`]
  643. * {xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-}[`++_upgradeToAndCallUUPS(newImplementation, data, forceCall)++`]
  644. * {xref-ERC1967Upgrade-_getAdmin--}[`++_getAdmin()++`]
  645. * {xref-ERC1967Upgrade-_changeAdmin-address-}[`++_changeAdmin(newAdmin)++`]
  646. * {xref-ERC1967Upgrade-_getBeacon--}[`++_getBeacon()++`]
  647. * {xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-}[`++_upgradeBeaconToAndCall(newBeacon, data, forceCall)++`]
  648. [.contract-subindex-inherited]
  649. .Proxy
  650. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  651. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  652. * {xref-Proxy-fallback--}[`++fallback()++`]
  653. * {xref-Proxy-receive--}[`++receive()++`]
  654. * {xref-Proxy-_beforeFallback--}[`++_beforeFallback()++`]
  655. --
  656. [.contract-index]
  657. .Events
  658. --
  659. [.contract-subindex-inherited]
  660. .ERC1967Upgrade
  661. * {xref-ERC1967Upgrade-Upgraded-address-}[`++Upgraded(implementation)++`]
  662. * {xref-ERC1967Upgrade-AdminChanged-address-address-}[`++AdminChanged(previousAdmin, newAdmin)++`]
  663. * {xref-ERC1967Upgrade-BeaconUpgraded-address-}[`++BeaconUpgraded(beacon)++`]
  664. [.contract-subindex-inherited]
  665. .Proxy
  666. --
  667. [.contract-item]
  668. [[BeaconProxy-constructor-address-bytes-]]
  669. ==== `[.contract-item-name]#++constructor++#++(address beacon, bytes data)++` [.item-kind]#public#
  670. Initializes the proxy with `beacon`.
  671. If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
  672. will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
  673. constructor.
  674. Requirements:
  675. - `beacon` must be a contract with the interface {IBeacon}.
  676. [.contract-item]
  677. [[BeaconProxy-_beacon--]]
  678. ==== `[.contract-item-name]#++_beacon++#++() → address++` [.item-kind]#internal#
  679. Returns the current beacon address.
  680. [.contract-item]
  681. [[BeaconProxy-_implementation--]]
  682. ==== `[.contract-item-name]#++_implementation++#++() → address++` [.item-kind]#internal#
  683. Returns the current implementation address of the associated beacon.
  684. [.contract-item]
  685. [[BeaconProxy-_setBeacon-address-bytes-]]
  686. ==== `[.contract-item-name]#++_setBeacon++#++(address beacon, bytes data)++` [.item-kind]#internal#
  687. Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.
  688. If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.
  689. Requirements:
  690. - `beacon` must be a contract.
  691. - The implementation returned by `beacon` must be a contract.
  692. :implementation: pass:normal[xref:#IBeacon-implementation--[`++implementation++`]]
  693. [.contract]
  694. [[IBeacon]]
  695. === `++IBeacon++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/beacon/IBeacon.sol[{github-icon},role=heading-link]
  696. [.hljs-theme-light.nopadding]
  697. ```solidity
  698. import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
  699. ```
  700. This is the interface that {BeaconProxy} expects of its beacon.
  701. [.contract-index]
  702. .Functions
  703. --
  704. * {xref-IBeacon-implementation--}[`++implementation()++`]
  705. --
  706. [.contract-item]
  707. [[IBeacon-implementation--]]
  708. ==== `[.contract-item-name]#++implementation++#++() → address++` [.item-kind]#external#
  709. Must return an address that can be used as a delegate call target.
  710. {BeaconProxy} will check that this address is a contract.
  711. :_implementation: pass:normal[xref:#UpgradeableBeacon-_implementation-address[`++_implementation++`]]
  712. :Upgraded: pass:normal[xref:#UpgradeableBeacon-Upgraded-address-[`++Upgraded++`]]
  713. :constructor: pass:normal[xref:#UpgradeableBeacon-constructor-address-[`++constructor++`]]
  714. :implementation: pass:normal[xref:#UpgradeableBeacon-implementation--[`++implementation++`]]
  715. :upgradeTo: pass:normal[xref:#UpgradeableBeacon-upgradeTo-address-[`++upgradeTo++`]]
  716. :_setImplementation: pass:normal[xref:#UpgradeableBeacon-_setImplementation-address-[`++_setImplementation++`]]
  717. [.contract]
  718. [[UpgradeableBeacon]]
  719. === `++UpgradeableBeacon++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/beacon/UpgradeableBeacon.sol[{github-icon},role=heading-link]
  720. [.hljs-theme-light.nopadding]
  721. ```solidity
  722. import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
  723. ```
  724. This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
  725. implementation contract, which is where they will delegate all function calls.
  726. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
  727. [.contract-index]
  728. .Functions
  729. --
  730. * {xref-UpgradeableBeacon-constructor-address-}[`++constructor(implementation_)++`]
  731. * {xref-UpgradeableBeacon-implementation--}[`++implementation()++`]
  732. * {xref-UpgradeableBeacon-upgradeTo-address-}[`++upgradeTo(newImplementation)++`]
  733. [.contract-subindex-inherited]
  734. .Ownable
  735. * {xref-Ownable-owner--}[`++owner()++`]
  736. * {xref-Ownable-_checkOwner--}[`++_checkOwner()++`]
  737. * {xref-Ownable-renounceOwnership--}[`++renounceOwnership()++`]
  738. * {xref-Ownable-transferOwnership-address-}[`++transferOwnership(newOwner)++`]
  739. * {xref-Ownable-_transferOwnership-address-}[`++_transferOwnership(newOwner)++`]
  740. [.contract-subindex-inherited]
  741. .IBeacon
  742. --
  743. [.contract-index]
  744. .Events
  745. --
  746. * {xref-UpgradeableBeacon-Upgraded-address-}[`++Upgraded(implementation)++`]
  747. [.contract-subindex-inherited]
  748. .Ownable
  749. * {xref-Ownable-OwnershipTransferred-address-address-}[`++OwnershipTransferred(previousOwner, newOwner)++`]
  750. [.contract-subindex-inherited]
  751. .IBeacon
  752. --
  753. [.contract-item]
  754. [[UpgradeableBeacon-constructor-address-]]
  755. ==== `[.contract-item-name]#++constructor++#++(address implementation_)++` [.item-kind]#public#
  756. Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the
  757. beacon.
  758. [.contract-item]
  759. [[UpgradeableBeacon-implementation--]]
  760. ==== `[.contract-item-name]#++implementation++#++() → address++` [.item-kind]#public#
  761. Returns the current implementation address.
  762. [.contract-item]
  763. [[UpgradeableBeacon-upgradeTo-address-]]
  764. ==== `[.contract-item-name]#++upgradeTo++#++(address newImplementation)++` [.item-kind]#public#
  765. Upgrades the beacon to a new implementation.
  766. Emits an {Upgraded} event.
  767. Requirements:
  768. - msg.sender must be the owner of the contract.
  769. - `newImplementation` must be a contract.
  770. [.contract-item]
  771. [[UpgradeableBeacon-Upgraded-address-]]
  772. ==== `[.contract-item-name]#++Upgraded++#++(address implementation)++` [.item-kind]#event#
  773. Emitted when the implementation returned by the beacon is changed.
  774. == Minimal Clones
  775. :clone: pass:normal[xref:#Clones-clone-address-[`++clone++`]]
  776. :cloneDeterministic: pass:normal[xref:#Clones-cloneDeterministic-address-bytes32-[`++cloneDeterministic++`]]
  777. :predictDeterministicAddress: pass:normal[xref:#Clones-predictDeterministicAddress-address-bytes32-address-[`++predictDeterministicAddress++`]]
  778. :predictDeterministicAddress: pass:normal[xref:#Clones-predictDeterministicAddress-address-bytes32-[`++predictDeterministicAddress++`]]
  779. [.contract]
  780. [[Clones]]
  781. === `++Clones++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/Clones.sol[{github-icon},role=heading-link]
  782. [.hljs-theme-light.nopadding]
  783. ```solidity
  784. import "@openzeppelin/contracts/proxy/Clones.sol";
  785. ```
  786. https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
  787. deploying minimal proxy contracts, also known as "clones".
  788. > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
  789. > a minimal bytecode implementation that delegates all calls to a known, fixed address.
  790. The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
  791. (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
  792. deterministic method.
  793. _Available since v3.4._
  794. [.contract-index]
  795. .Functions
  796. --
  797. * {xref-Clones-clone-address-}[`++clone(implementation)++`]
  798. * {xref-Clones-cloneDeterministic-address-bytes32-}[`++cloneDeterministic(implementation, salt)++`]
  799. * {xref-Clones-predictDeterministicAddress-address-bytes32-address-}[`++predictDeterministicAddress(implementation, salt, deployer)++`]
  800. * {xref-Clones-predictDeterministicAddress-address-bytes32-}[`++predictDeterministicAddress(implementation, salt)++`]
  801. --
  802. [.contract-item]
  803. [[Clones-clone-address-]]
  804. ==== `[.contract-item-name]#++clone++#++(address implementation) → address instance++` [.item-kind]#internal#
  805. Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
  806. This function uses the create opcode, which should never revert.
  807. [.contract-item]
  808. [[Clones-cloneDeterministic-address-bytes32-]]
  809. ==== `[.contract-item-name]#++cloneDeterministic++#++(address implementation, bytes32 salt) → address instance++` [.item-kind]#internal#
  810. Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
  811. This function uses the create2 opcode and a `salt` to deterministically deploy
  812. the clone. Using the same `implementation` and `salt` multiple time will revert, since
  813. the clones cannot be deployed twice at the same address.
  814. [.contract-item]
  815. [[Clones-predictDeterministicAddress-address-bytes32-address-]]
  816. ==== `[.contract-item-name]#++predictDeterministicAddress++#++(address implementation, bytes32 salt, address deployer) → address predicted++` [.item-kind]#internal#
  817. Computes the address of a clone deployed using {Clones-cloneDeterministic}.
  818. [.contract-item]
  819. [[Clones-predictDeterministicAddress-address-bytes32-]]
  820. ==== `[.contract-item-name]#++predictDeterministicAddress++#++(address implementation, bytes32 salt) → address predicted++` [.item-kind]#internal#
  821. Computes the address of a clone deployed using {Clones-cloneDeterministic}.
  822. == Utils
  823. :_initialized: pass:normal[xref:#Initializable-_initialized-uint8[`++_initialized++`]]
  824. :_initializing: pass:normal[xref:#Initializable-_initializing-bool[`++_initializing++`]]
  825. :Initialized: pass:normal[xref:#Initializable-Initialized-uint8-[`++Initialized++`]]
  826. :initializer: pass:normal[xref:#Initializable-initializer--[`++initializer++`]]
  827. :reinitializer: pass:normal[xref:#Initializable-reinitializer-uint8-[`++reinitializer++`]]
  828. :onlyInitializing: pass:normal[xref:#Initializable-onlyInitializing--[`++onlyInitializing++`]]
  829. :_disableInitializers: pass:normal[xref:#Initializable-_disableInitializers--[`++_disableInitializers++`]]
  830. :_getInitializedVersion: pass:normal[xref:#Initializable-_getInitializedVersion--[`++_getInitializedVersion++`]]
  831. :_isInitializing: pass:normal[xref:#Initializable-_isInitializing--[`++_isInitializing++`]]
  832. [.contract]
  833. [[Initializable]]
  834. === `++Initializable++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/utils/Initializable.sol[{github-icon},role=heading-link]
  835. [.hljs-theme-light.nopadding]
  836. ```solidity
  837. import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
  838. ```
  839. This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
  840. behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
  841. external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
  842. function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
  843. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
  844. reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
  845. case an upgrade adds a module that needs to be initialized.
  846. For example:
  847. [.hljs-theme-light.nopadding]
  848. ```
  849. contract MyToken is ERC20Upgradeable {
  850. function initialize() initializer public {
  851. __ERC20_init("MyToken", "MTK");
  852. }
  853. }
  854. contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
  855. function initializeV2() reinitializer(2) public {
  856. __ERC20Permit_init("MyToken");
  857. }
  858. }
  859. ```
  860. TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
  861. possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
  862. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
  863. that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
  864. [CAUTION]
  865. ====
  866. Avoid leaving a contract uninitialized.
  867. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
  868. contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
  869. the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
  870. [.hljs-theme-light.nopadding]
  871. ```
  872. /// @custom:oz-upgrades-unsafe-allow constructor
  873. constructor() {
  874. _disableInitializers();
  875. }
  876. ```
  877. ====
  878. [.contract-index]
  879. .Modifiers
  880. --
  881. * {xref-Initializable-initializer--}[`++initializer()++`]
  882. * {xref-Initializable-reinitializer-uint8-}[`++reinitializer(version)++`]
  883. * {xref-Initializable-onlyInitializing--}[`++onlyInitializing()++`]
  884. --
  885. [.contract-index]
  886. .Functions
  887. --
  888. * {xref-Initializable-_disableInitializers--}[`++_disableInitializers()++`]
  889. * {xref-Initializable-_getInitializedVersion--}[`++_getInitializedVersion()++`]
  890. * {xref-Initializable-_isInitializing--}[`++_isInitializing()++`]
  891. --
  892. [.contract-index]
  893. .Events
  894. --
  895. * {xref-Initializable-Initialized-uint8-}[`++Initialized(version)++`]
  896. --
  897. [.contract-item]
  898. [[Initializable-initializer--]]
  899. ==== `[.contract-item-name]#++initializer++#++()++` [.item-kind]#modifier#
  900. A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
  901. `onlyInitializing` functions can be used to initialize parent contracts.
  902. Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
  903. constructor.
  904. Emits an {Initialized} event.
  905. [.contract-item]
  906. [[Initializable-reinitializer-uint8-]]
  907. ==== `[.contract-item-name]#++reinitializer++#++(uint8 version)++` [.item-kind]#modifier#
  908. A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
  909. contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
  910. used to initialize parent contracts.
  911. A reinitializer may be used after the original initialization step. This is essential to configure modules that
  912. are added through upgrades and that require initialization.
  913. When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
  914. cannot be nested. If one is invoked in the context of another, execution will revert.
  915. Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
  916. a contract, executing them in the right order is up to the developer or operator.
  917. WARNING: setting the version to 255 will prevent any future reinitialization.
  918. Emits an {Initialized} event.
  919. [.contract-item]
  920. [[Initializable-onlyInitializing--]]
  921. ==== `[.contract-item-name]#++onlyInitializing++#++()++` [.item-kind]#modifier#
  922. Modifier to protect an initialization function so that it can only be invoked by functions with the
  923. {initializer} and {reinitializer} modifiers, directly or indirectly.
  924. [.contract-item]
  925. [[Initializable-_disableInitializers--]]
  926. ==== `[.contract-item-name]#++_disableInitializers++#++()++` [.item-kind]#internal#
  927. Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
  928. Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
  929. to any version. It is recommended to use this to lock implementation contracts that are designed to be called
  930. through proxies.
  931. Emits an {Initialized} event the first time it is successfully executed.
  932. [.contract-item]
  933. [[Initializable-_getInitializedVersion--]]
  934. ==== `[.contract-item-name]#++_getInitializedVersion++#++() → uint8++` [.item-kind]#internal#
  935. Returns the highest version that has been initialized. See {reinitializer}.
  936. [.contract-item]
  937. [[Initializable-_isInitializing--]]
  938. ==== `[.contract-item-name]#++_isInitializing++#++() → bool++` [.item-kind]#internal#
  939. Returns `true` if the contract is currently initializing. See {onlyInitializing}.
  940. [.contract-item]
  941. [[Initializable-Initialized-uint8-]]
  942. ==== `[.contract-item-name]#++Initialized++#++(uint8 version)++` [.item-kind]#event#
  943. Triggered when the contract has been initialized or reinitialized.
  944. :__self: pass:normal[xref:#UUPSUpgradeable-__self-address[`++__self++`]]
  945. :onlyProxy: pass:normal[xref:#UUPSUpgradeable-onlyProxy--[`++onlyProxy++`]]
  946. :notDelegated: pass:normal[xref:#UUPSUpgradeable-notDelegated--[`++notDelegated++`]]
  947. :proxiableUUID: pass:normal[xref:#UUPSUpgradeable-proxiableUUID--[`++proxiableUUID++`]]
  948. :upgradeTo: pass:normal[xref:#UUPSUpgradeable-upgradeTo-address-[`++upgradeTo++`]]
  949. :upgradeToAndCall: pass:normal[xref:#UUPSUpgradeable-upgradeToAndCall-address-bytes-[`++upgradeToAndCall++`]]
  950. :_authorizeUpgrade: pass:normal[xref:#UUPSUpgradeable-_authorizeUpgrade-address-[`++_authorizeUpgrade++`]]
  951. [.contract]
  952. [[UUPSUpgradeable]]
  953. === `++UUPSUpgradeable++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/utils/UUPSUpgradeable.sol[{github-icon},role=heading-link]
  954. [.hljs-theme-light.nopadding]
  955. ```solidity
  956. import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
  957. ```
  958. An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
  959. {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
  960. A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
  961. reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
  962. `UUPSUpgradeable` with a custom implementation of upgrades.
  963. The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
  964. _Available since v4.1._
  965. [.contract-index]
  966. .Modifiers
  967. --
  968. * {xref-UUPSUpgradeable-onlyProxy--}[`++onlyProxy()++`]
  969. * {xref-UUPSUpgradeable-notDelegated--}[`++notDelegated()++`]
  970. --
  971. [.contract-index]
  972. .Functions
  973. --
  974. * {xref-UUPSUpgradeable-proxiableUUID--}[`++proxiableUUID()++`]
  975. * {xref-UUPSUpgradeable-upgradeTo-address-}[`++upgradeTo(newImplementation)++`]
  976. * {xref-UUPSUpgradeable-upgradeToAndCall-address-bytes-}[`++upgradeToAndCall(newImplementation, data)++`]
  977. * {xref-UUPSUpgradeable-_authorizeUpgrade-address-}[`++_authorizeUpgrade(newImplementation)++`]
  978. [.contract-subindex-inherited]
  979. .ERC1967Upgrade
  980. * {xref-ERC1967Upgrade-_getImplementation--}[`++_getImplementation()++`]
  981. * {xref-ERC1967Upgrade-_upgradeTo-address-}[`++_upgradeTo(newImplementation)++`]
  982. * {xref-ERC1967Upgrade-_upgradeToAndCall-address-bytes-bool-}[`++_upgradeToAndCall(newImplementation, data, forceCall)++`]
  983. * {xref-ERC1967Upgrade-_upgradeToAndCallUUPS-address-bytes-bool-}[`++_upgradeToAndCallUUPS(newImplementation, data, forceCall)++`]
  984. * {xref-ERC1967Upgrade-_getAdmin--}[`++_getAdmin()++`]
  985. * {xref-ERC1967Upgrade-_changeAdmin-address-}[`++_changeAdmin(newAdmin)++`]
  986. * {xref-ERC1967Upgrade-_getBeacon--}[`++_getBeacon()++`]
  987. * {xref-ERC1967Upgrade-_upgradeBeaconToAndCall-address-bytes-bool-}[`++_upgradeBeaconToAndCall(newBeacon, data, forceCall)++`]
  988. [.contract-subindex-inherited]
  989. .IERC1822Proxiable
  990. --
  991. [.contract-index]
  992. .Events
  993. --
  994. [.contract-subindex-inherited]
  995. .ERC1967Upgrade
  996. * {xref-ERC1967Upgrade-Upgraded-address-}[`++Upgraded(implementation)++`]
  997. * {xref-ERC1967Upgrade-AdminChanged-address-address-}[`++AdminChanged(previousAdmin, newAdmin)++`]
  998. * {xref-ERC1967Upgrade-BeaconUpgraded-address-}[`++BeaconUpgraded(beacon)++`]
  999. [.contract-subindex-inherited]
  1000. .IERC1822Proxiable
  1001. --
  1002. [.contract-item]
  1003. [[UUPSUpgradeable-onlyProxy--]]
  1004. ==== `[.contract-item-name]#++onlyProxy++#++()++` [.item-kind]#modifier#
  1005. Check that the execution is being performed through a delegatecall call and that the execution context is
  1006. a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
  1007. for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
  1008. function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
  1009. fail.
  1010. [.contract-item]
  1011. [[UUPSUpgradeable-notDelegated--]]
  1012. ==== `[.contract-item-name]#++notDelegated++#++()++` [.item-kind]#modifier#
  1013. Check that the execution is not being performed through a delegate call. This allows a function to be
  1014. callable on the implementing contract but not through proxies.
  1015. [.contract-item]
  1016. [[UUPSUpgradeable-proxiableUUID--]]
  1017. ==== `[.contract-item-name]#++proxiableUUID++#++() → bytes32++` [.item-kind]#external#
  1018. Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
  1019. implementation. It is used to validate the implementation's compatibility when performing an upgrade.
  1020. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
  1021. bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
  1022. function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
  1023. [.contract-item]
  1024. [[UUPSUpgradeable-upgradeTo-address-]]
  1025. ==== `[.contract-item-name]#++upgradeTo++#++(address newImplementation)++` [.item-kind]#external#
  1026. Upgrade the implementation of the proxy to `newImplementation`.
  1027. Calls {_authorizeUpgrade}.
  1028. Emits an {Upgraded} event.
  1029. [.contract-item]
  1030. [[UUPSUpgradeable-upgradeToAndCall-address-bytes-]]
  1031. ==== `[.contract-item-name]#++upgradeToAndCall++#++(address newImplementation, bytes data)++` [.item-kind]#external#
  1032. Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
  1033. encoded in `data`.
  1034. Calls {_authorizeUpgrade}.
  1035. Emits an {Upgraded} event.
  1036. [.contract-item]
  1037. [[UUPSUpgradeable-_authorizeUpgrade-address-]]
  1038. ==== `[.contract-item-name]#++_authorizeUpgrade++#++(address newImplementation)++` [.item-kind]#internal#
  1039. Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
  1040. {upgradeTo} and {upgradeToAndCall}.
  1041. Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
  1042. ```solidity
  1043. function _authorizeUpgrade(address) internal override onlyOwner {}
  1044. ```