diff --git a/404.html b/404.html index ae7e3138c..685c680af 100644 --- a/404.html +++ b/404.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - +
diff --git a/abi-decode/index.html b/abi-decode/index.html index ae7e3138c..685c680af 100644 --- a/abi-decode/index.html +++ b/abi-decode/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/abi-encode/index.html b/abi-encode/index.html index ae7e3138c..685c680af 100644 --- a/abi-encode/index.html +++ b/abi-encode/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/airdrop/index.html b/app/airdrop/index.html index ae7e3138c..685c680af 100644 --- a/app/airdrop/index.html +++ b/app/airdrop/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/assembly-bin-exp/index.html b/app/assembly-bin-exp/index.html index ae7e3138c..685c680af 100644 --- a/app/assembly-bin-exp/index.html +++ b/app/assembly-bin-exp/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/bi-directional-payment-channel/index.html b/app/bi-directional-payment-channel/index.html index ae7e3138c..685c680af 100644 --- a/app/bi-directional-payment-channel/index.html +++ b/app/bi-directional-payment-channel/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/create2/index.html b/app/create2/index.html index ae7e3138c..685c680af 100644 --- a/app/create2/index.html +++ b/app/create2/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/crowd-fund/index.html b/app/crowd-fund/index.html index ae7e3138c..685c680af 100644 --- a/app/crowd-fund/index.html +++ b/app/crowd-fund/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/deploy-any-contract/index.html b/app/deploy-any-contract/index.html index ae7e3138c..685c680af 100644 --- a/app/deploy-any-contract/index.html +++ b/app/deploy-any-contract/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/dutch-auction/index.html b/app/dutch-auction/index.html index ae7e3138c..685c680af 100644 --- a/app/dutch-auction/index.html +++ b/app/dutch-auction/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/english-auction/index.html b/app/english-auction/index.html index ae7e3138c..685c680af 100644 --- a/app/english-auction/index.html +++ b/app/english-auction/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/erc1155/index.html b/app/erc1155/index.html index ae7e3138c..685c680af 100644 --- a/app/erc1155/index.html +++ b/app/erc1155/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/erc20/index.html b/app/erc20/index.html index ae7e3138c..685c680af 100644 --- a/app/erc20/index.html +++ b/app/erc20/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/erc721/index.html b/app/erc721/index.html index ae7e3138c..685c680af 100644 --- a/app/erc721/index.html +++ b/app/erc721/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/ether-wallet/index.html b/app/ether-wallet/index.html index ae7e3138c..685c680af 100644 --- a/app/ether-wallet/index.html +++ b/app/ether-wallet/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/gasless-token-transfer/index.html b/app/gasless-token-transfer/index.html index ae7e3138c..685c680af 100644 --- a/app/gasless-token-transfer/index.html +++ b/app/gasless-token-transfer/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/iterable-mapping/index.html b/app/iterable-mapping/index.html index ae7e3138c..685c680af 100644 --- a/app/iterable-mapping/index.html +++ b/app/iterable-mapping/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/merkle-tree/index.html b/app/merkle-tree/index.html index ae7e3138c..685c680af 100644 --- a/app/merkle-tree/index.html +++ b/app/merkle-tree/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/minimal-proxy/index.html b/app/minimal-proxy/index.html index ae7e3138c..685c680af 100644 --- a/app/minimal-proxy/index.html +++ b/app/minimal-proxy/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/multi-call/index.html b/app/multi-call/index.html index ae7e3138c..685c680af 100644 --- a/app/multi-call/index.html +++ b/app/multi-call/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/multi-delegatecall/index.html b/app/multi-delegatecall/index.html index ae7e3138c..685c680af 100644 --- a/app/multi-delegatecall/index.html +++ b/app/multi-delegatecall/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/multi-sig-wallet/index.html b/app/multi-sig-wallet/index.html index ae7e3138c..685c680af 100644 --- a/app/multi-sig-wallet/index.html +++ b/app/multi-sig-wallet/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/simple-bytecode-contract/index.html b/app/simple-bytecode-contract/index.html index ae7e3138c..685c680af 100644 --- a/app/simple-bytecode-contract/index.html +++ b/app/simple-bytecode-contract/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/time-lock/index.html b/app/time-lock/index.html index ae7e3138c..685c680af 100644 --- a/app/time-lock/index.html +++ b/app/time-lock/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/uni-directional-payment-channel/index.html b/app/uni-directional-payment-channel/index.html index ae7e3138c..685c680af 100644 --- a/app/uni-directional-payment-channel/index.html +++ b/app/uni-directional-payment-channel/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/upgradeable-proxy/index.html b/app/upgradeable-proxy/index.html index ae7e3138c..685c680af 100644 --- a/app/upgradeable-proxy/index.html +++ b/app/upgradeable-proxy/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/app/write-to-any-slot/index.html b/app/write-to-any-slot/index.html index ae7e3138c..685c680af 100644 --- a/app/write-to-any-slot/index.html +++ b/app/write-to-any-slot/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/array/index.html b/array/index.html index ae7e3138c..685c680af 100644 --- a/array/index.html +++ b/array/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/assembly-error/index.html b/assembly-error/index.html index ae7e3138c..685c680af 100644 --- a/assembly-error/index.html +++ b/assembly-error/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/assembly-if/index.html b/assembly-if/index.html index ae7e3138c..685c680af 100644 --- a/assembly-if/index.html +++ b/assembly-if/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/assembly-loop/index.html b/assembly-loop/index.html index ae7e3138c..685c680af 100644 --- a/assembly-loop/index.html +++ b/assembly-loop/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/assembly-math/index.html b/assembly-math/index.html index ae7e3138c..685c680af 100644 --- a/assembly-math/index.html +++ b/assembly-math/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/assembly-variable/index.html b/assembly-variable/index.html index ae7e3138c..685c680af 100644 --- a/assembly-variable/index.html +++ b/assembly-variable/index.html @@ -28,7 +28,7 @@ gtag("config", "UA-133759045-1") - + diff --git a/assets/index-BwP8mGg_.js b/assets/index-mQp8j2HZ.js similarity index 97% rename from assets/index-BwP8mGg_.js rename to assets/index-mQp8j2HZ.js index 32c8a05e8..e5c129dfa 100644 --- a/assets/index-BwP8mGg_.js +++ b/assets/index-mQp8j2HZ.js @@ -6,7 +6,7 @@ function Ag(s,a){for(var n=0;n>>1;T >>1;T
Example of upgradeable proxy contract. Never use this in production.
@@ -3624,7 +3676,7 @@ Each slot in the array can store 32 bytes. } } } -`,ky=({prev:s,next:a})=>i.jsx(A,{version:Ay,title:uy,description:yy,cyfrinLink:my,html:wy,prev:s,next:a,codes:by}),Zy="0.8.26",Wy="Assembly Loop",Gy="Example of loop in assembly",By="https://www.cyfrin.io/glossary/assembly-loop-code-example",fy=[{fileName:"AssemblyLoop.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IEFzc2VtYmx5TG9vcCB7CiAgICBmdW5jdGlvbiB5dWxfZm9yX2xvb3AoKSBwdWJsaWMgcHVyZSByZXR1cm5zICh1aW50MjU2IHopIHsKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIGZvciB7IGxldCBpIDo9IDAgfSBsdChpLCAxMCkgeyBpIDo9IGFkZChpLCAxKSB9IHsgeiA6PSBhZGQoeiwgMSkgfQogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiB5dWxfd2hpbGVfbG9vcCgpIHB1YmxpYyBwdXJlIHJldHVybnMgKHVpbnQyNTYgeikgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgbGV0IGkgOj0gMAogICAgICAgICAgICBmb3Ige30gbHQoaSwgNSkge30gewogICAgICAgICAgICAgICAgaSA6PSBhZGQoaSwgMSkKICAgICAgICAgICAgICAgIHogOj0gYWRkKHosIDEpCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K"}],Vy=`Example of loop in assembly
+`,ky=({prev:s,next:a})=>i.jsx(A,{version:Ay,title:uy,description:yy,cyfrinLink:my,html:wy,prev:s,next:a,codes:by}),Zy="0.8.26",Wy="Assembly Loop",By="Example of loop in assembly",Gy="https://www.cyfrin.io/glossary/assembly-loop-code-example",fy=[{fileName:"AssemblyLoop.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IEFzc2VtYmx5TG9vcCB7CiAgICBmdW5jdGlvbiB5dWxfZm9yX2xvb3AoKSBwdWJsaWMgcHVyZSByZXR1cm5zICh1aW50MjU2IHopIHsKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIGZvciB7IGxldCBpIDo9IDAgfSBsdChpLCAxMCkgeyBpIDo9IGFkZChpLCAxKSB9IHsgeiA6PSBhZGQoeiwgMSkgfQogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiB5dWxfd2hpbGVfbG9vcCgpIHB1YmxpYyBwdXJlIHJldHVybnMgKHVpbnQyNTYgeikgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgbGV0IGkgOj0gMAogICAgICAgICAgICBmb3Ige30gbHQoaSwgNSkge30gewogICAgICAgICAgICAgICAgaSA6PSBhZGQoaSwgMSkKICAgICAgICAgICAgICAgIHogOj0gYWRkKHosIDEpCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K"}],Vy=`Example of loop in assembly
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -3645,7 +3697,7 @@ Each slot in the array can store 32 bytes.
}
}
}
-
`,Yy=({prev:s,next:a})=>i.jsx(A,{version:Zy,title:Wy,description:Gy,cyfrinLink:By,html:Vy,prev:s,next:a,codes:fy}),Xy="0.8.26",vy="Assembly Math",Ry="Example of math in assembly",Ny="https://www.cyfrin.io/glossary/assembly-math-code-example",Hy=[{fileName:"AssemblyMath.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IEFzc2VtYmx5TWF0aCB7CiAgICBmdW5jdGlvbiB5dWxfYWRkKHVpbnQyNTYgeCwgdWludDI1NiB5KSBwdWJsaWMgcHVyZSByZXR1cm5zICh1aW50MjU2IHopIHsKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIHogOj0gYWRkKHgsIHkpCiAgICAgICAgICAgIGlmIGx0KHosIHgpIHsgcmV2ZXJ0KDAsIDApIH0KICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24geXVsX211bCh1aW50MjU2IHgsIHVpbnQyNTYgeSkgcHVibGljIHB1cmUgcmV0dXJucyAodWludDI1NiB6KSB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBzd2l0Y2ggeAogICAgICAgICAgICBjYXNlIDAgeyB6IDo9IDAgfQogICAgICAgICAgICBkZWZhdWx0IHsKICAgICAgICAgICAgICAgIHogOj0gbXVsKHgsIHkpCiAgICAgICAgICAgICAgICBpZiBpc3plcm8oZXEoZGl2KHosIHgpLCB5KSkgeyByZXZlcnQoMCwgMCkgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIC8vIFJvdW5kIHRvIG5lYXJlc3QgbXVsdGlwbGUgb2YgYgogICAgZnVuY3Rpb24geXVsX2ZpeGVkX3BvaW50X3JvdW5kKHVpbnQyNTYgeCwgdWludDI1NiBiKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zICh1aW50MjU2IHopCiAgICB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICAvLyBiID0gMTAwCiAgICAgICAgICAgIC8vIHggPSA5MAogICAgICAgICAgICAvLyB6ID0gOTAgLyAxMDAgKiAxMDAgPSAwLCB3YW50IHogPSAxMDAKICAgICAgICAgICAgLy8geiA6PSBtdWwoZGl2KHgsIGIpLCBiKQoKICAgICAgICAgICAgbGV0IGhhbGYgOj0gZGl2KGIsIDIpCiAgICAgICAgICAgIHogOj0gYWRkKHgsIGhhbGYpCiAgICAgICAgICAgIHogOj0gbXVsKGRpdih6LCBiKSwgYikKICAgICAgICAgICAgLy8geCA9IDkwCiAgICAgICAgICAgIC8vIGhhbGYgPSA1MAogICAgICAgICAgICAvLyB6ID0gOTAgKyA1MCA9IDE0MAogICAgICAgICAgICAvLyB6ID0gMTQwIC8gMTAwICogMTAwID0gMTAwCiAgICAgICAgfQogICAgfQp9Cg=="}],Fy=`Example of math in assembly
Example of math in assembly
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -4074,7 +4126,7 @@ Each slot in the array can store 32 bytes.
contract E is X, Y {
constructor() Y("Y was called") X("X was called") {}
}
-
`,Wm=({prev:s,next:a})=>i.jsx(A,{version:ym,title:mm,description:bm,cyfrinLink:wm,html:Zm,prev:s,next:a,codes:km}),Gm="0.8.26",Bm="Data Locations - Storage, Memory and Calldata",fm="Data locations - storage, memory and calldata",Vm="https://www.cyfrin.io/glossary/data-locations-storage-memory-and-calldata-code-example",Ym=[{fileName:"DataLocations.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IERhdGFMb2NhdGlvbnMgewogICAgdWludDI1NltdIHB1YmxpYyBhcnI7CiAgICBtYXBwaW5nKHVpbnQyNTYgPT4gYWRkcmVzcykgbWFwOwoKICAgIHN0cnVjdCBNeVN0cnVjdCB7CiAgICAgICAgdWludDI1NiBmb287CiAgICB9CgogICAgbWFwcGluZyh1aW50MjU2ID0+IE15U3RydWN0KSBteVN0cnVjdHM7CgogICAgZnVuY3Rpb24gZigpIHB1YmxpYyB7CiAgICAgICAgLy8gY2FsbCBfZiB3aXRoIHN0YXRlIHZhcmlhYmxlcwogICAgICAgIF9mKGFyciwgbWFwLCBteVN0cnVjdHNbMV0pOwoKICAgICAgICAvLyBnZXQgYSBzdHJ1Y3QgZnJvbSBhIG1hcHBpbmcKICAgICAgICBNeVN0cnVjdCBzdG9yYWdlIG15U3RydWN0ID0gbXlTdHJ1Y3RzWzFdOwogICAgICAgIC8vIGNyZWF0ZSBhIHN0cnVjdCBpbiBtZW1vcnkKICAgICAgICBNeVN0cnVjdCBtZW1vcnkgbXlNZW1TdHJ1Y3QgPSBNeVN0cnVjdCgwKTsKICAgIH0KCiAgICBmdW5jdGlvbiBfZigKICAgICAgICB1aW50MjU2W10gc3RvcmFnZSBfYXJyLAogICAgICAgIG1hcHBpbmcodWludDI1NiA9PiBhZGRyZXNzKSBzdG9yYWdlIF9tYXAsCiAgICAgICAgTXlTdHJ1Y3Qgc3RvcmFnZSBfbXlTdHJ1Y3QKICAgICkgaW50ZXJuYWwgewogICAgICAgIC8vIGRvIHNvbWV0aGluZyB3aXRoIHN0b3JhZ2UgdmFyaWFibGVzCiAgICB9CgogICAgLy8gWW91IGNhbiByZXR1cm4gbWVtb3J5IHZhcmlhYmxlcwogICAgZnVuY3Rpb24gZyh1aW50MjU2W10gbWVtb3J5IF9hcnIpIHB1YmxpYyByZXR1cm5zICh1aW50MjU2W10gbWVtb3J5KSB7CiAgICAgICAgLy8gZG8gc29tZXRoaW5nIHdpdGggbWVtb3J5IGFycmF5CiAgICB9CgogICAgZnVuY3Rpb24gaCh1aW50MjU2W10gY2FsbGRhdGEgX2FycikgZXh0ZXJuYWwgewogICAgICAgIC8vIGRvIHNvbWV0aGluZyB3aXRoIGNhbGxkYXRhIGFycmF5CiAgICB9Cn0K"}],Xm=`Variables are declared as either storage
, memory
or calldata
to explicitly
+`,Wm=({prev:s,next:a})=>i.jsx(A,{version:ym,title:mm,description:bm,cyfrinLink:wm,html:Zm,prev:s,next:a,codes:km}),Bm="0.8.26",Gm="Data Locations - Storage, Memory and Calldata",fm="Data locations - storage, memory and calldata",Vm="https://www.cyfrin.io/glossary/data-locations-storage-memory-and-calldata-code-example",Ym=[{fileName:"DataLocations.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IERhdGFMb2NhdGlvbnMgewogICAgdWludDI1NltdIHB1YmxpYyBhcnI7CiAgICBtYXBwaW5nKHVpbnQyNTYgPT4gYWRkcmVzcykgbWFwOwoKICAgIHN0cnVjdCBNeVN0cnVjdCB7CiAgICAgICAgdWludDI1NiBmb287CiAgICB9CgogICAgbWFwcGluZyh1aW50MjU2ID0+IE15U3RydWN0KSBteVN0cnVjdHM7CgogICAgZnVuY3Rpb24gZigpIHB1YmxpYyB7CiAgICAgICAgLy8gY2FsbCBfZiB3aXRoIHN0YXRlIHZhcmlhYmxlcwogICAgICAgIF9mKGFyciwgbWFwLCBteVN0cnVjdHNbMV0pOwoKICAgICAgICAvLyBnZXQgYSBzdHJ1Y3QgZnJvbSBhIG1hcHBpbmcKICAgICAgICBNeVN0cnVjdCBzdG9yYWdlIG15U3RydWN0ID0gbXlTdHJ1Y3RzWzFdOwogICAgICAgIC8vIGNyZWF0ZSBhIHN0cnVjdCBpbiBtZW1vcnkKICAgICAgICBNeVN0cnVjdCBtZW1vcnkgbXlNZW1TdHJ1Y3QgPSBNeVN0cnVjdCgwKTsKICAgIH0KCiAgICBmdW5jdGlvbiBfZigKICAgICAgICB1aW50MjU2W10gc3RvcmFnZSBfYXJyLAogICAgICAgIG1hcHBpbmcodWludDI1NiA9PiBhZGRyZXNzKSBzdG9yYWdlIF9tYXAsCiAgICAgICAgTXlTdHJ1Y3Qgc3RvcmFnZSBfbXlTdHJ1Y3QKICAgICkgaW50ZXJuYWwgewogICAgICAgIC8vIGRvIHNvbWV0aGluZyB3aXRoIHN0b3JhZ2UgdmFyaWFibGVzCiAgICB9CgogICAgLy8gWW91IGNhbiByZXR1cm4gbWVtb3J5IHZhcmlhYmxlcwogICAgZnVuY3Rpb24gZyh1aW50MjU2W10gbWVtb3J5IF9hcnIpIHB1YmxpYyByZXR1cm5zICh1aW50MjU2W10gbWVtb3J5KSB7CiAgICAgICAgLy8gZG8gc29tZXRoaW5nIHdpdGggbWVtb3J5IGFycmF5CiAgICB9CgogICAgZnVuY3Rpb24gaCh1aW50MjU2W10gY2FsbGRhdGEgX2FycikgZXh0ZXJuYWwgewogICAgICAgIC8vIGRvIHNvbWV0aGluZyB3aXRoIGNhbGxkYXRhIGFycmF5CiAgICB9Cn0K"}],Xm=`
Variables are declared as either storage
, memory
or calldata
to explicitly
specify the location of the data.
storage
- variable is a state variable (store on blockchain)// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -5348,7 +5400,7 @@ Topics
external
returns (bool);
}
-
`,mb=({prev:s,next:a})=>i.jsx(A,{version:db,title:Cb,description:jb,cyfrinLink:Ab,html:yb,prev:s,next:a,codes:ub}),bb="0.8.26",wb="Staking Rewards",kb="Staking rewards contract based on Synthetix StakingRewards.sol",Zb="",Wb=[{fileName:"StakingRewards.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFN0YWtpbmdSZXdhcmRzIHsKICAgIElFUkMyMCBwdWJsaWMgaW1tdXRhYmxlIHN0YWtpbmdUb2tlbjsKICAgIElFUkMyMCBwdWJsaWMgaW1tdXRhYmxlIHJld2FyZHNUb2tlbjsKCiAgICBhZGRyZXNzIHB1YmxpYyBvd25lcjsKCiAgICAvLyBEdXJhdGlvbiBvZiByZXdhcmRzIHRvIGJlIHBhaWQgb3V0IChpbiBzZWNvbmRzKQogICAgdWludDI1NiBwdWJsaWMgZHVyYXRpb247CiAgICAvLyBUaW1lc3RhbXAgb2Ygd2hlbiB0aGUgcmV3YXJkcyBmaW5pc2gKICAgIHVpbnQyNTYgcHVibGljIGZpbmlzaEF0OwogICAgLy8gTWluaW11bSBvZiBsYXN0IHVwZGF0ZWQgdGltZSBhbmQgcmV3YXJkIGZpbmlzaCB0aW1lCiAgICB1aW50MjU2IHB1YmxpYyB1cGRhdGVkQXQ7CiAgICAvLyBSZXdhcmQgdG8gYmUgcGFpZCBvdXQgcGVyIHNlY29uZAogICAgdWludDI1NiBwdWJsaWMgcmV3YXJkUmF0ZTsKICAgIC8vIFN1bSBvZiAocmV3YXJkIHJhdGUgKiBkdCAqIDFlMTggLyB0b3RhbCBzdXBwbHkpCiAgICB1aW50MjU2IHB1YmxpYyByZXdhcmRQZXJUb2tlblN0b3JlZDsKICAgIC8vIFVzZXIgYWRkcmVzcyA9PiByZXdhcmRQZXJUb2tlblN0b3JlZAogICAgbWFwcGluZyhhZGRyZXNzID0+IHVpbnQyNTYpI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CAiYW1vdW50ID0gMCIpOwogICAgICAgIGJhbGFuY2VPZlttc2cuc2VuZGVyXSAtPSBfYW1vdW50OwogICAgICAgIHRvdGFsU3VwcGx5IC09IF9hbW91bnQ7CiAgICAgICAgc3Rha2luZ1Rva2VuLnRyYW5zZmVyKG1zZy5zZW5kZXIsIF9hbW91bnQpOwogICAgfQoKICAgIGZ1bmN0aW9uIGVhcm5lZChhZGRyZXNzIF9hY2NvdW50KSBwdWJsaWMgdmlldyByZXR1cm5zICh1aW50MjU2KSB7CiAgICAgICAgcmV0dXJuICgKICAgICAgICAgICAgKAogICAgICAgICAgICAgICAgYmFsYW5jZU9mW19hY2NvdW50XQogICAgICAgICAgICAgICAgICAgICogKHJld2FyZFBlclRva2VuKCkgLSB1c2VyUmV3YXJkUGVyVG9rZW5QYWlkW19hY2NvdW50XSkKICAgICAgICAgICAgKSAvIDFlMTgKICAgICAgICApICsgcmV3YXJkc1tfYWNjb3VudF07CiAgICB9CgogICAgZnVuY3Rpb24gZ2V0UmV3YXJkKCkgZXh0ZXJuYWwgdXBkYXRlUmV3YXJkKG1zZy5zZW5kZXIpIHsKICAgICAgICB1aW50MjU2IHJld2FyZCA9IHJld2FyZHNbbXNnLnNlbmRlcl07CiAgICAgICAgaWYgKHJld2FyZCA+IDApIHsKICAgICAgICAgICAgcmV3YXJkc1ttc2cuc2VuZGVyXSA9IDA7CiAgICAgICAgICAgIHJld2FyZHNUb2tlbi50cmFuc2Zlcihtc2cuc2VuZGVyLCByZXdhcmQpOwogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiBzZXRSZXdhcmRzRHVyYXRpb24odWludDI1NiBfZHVyYXRpb24pIGV4dGVybmFsIG9ubHlPd25lciB7CiAgICAgICAgcmVxdWlyZShmaW5pc2hBdCA8IGJsb2NrLnRpbWVzdGFtcCwgInJld2FyZCBkdXJhdGlvbiBub3QgZmluaXNoZWQiKTsKICAgICAgICBkdXJhdGlvbiA9IF9kdXJhdGlvbjsKICAgIH0KCiAgICBmdW5jdGlvbiBub3RpZnlSZXdhcmRBbW91bnQodWludDI1NiBfYW1vdW50KQogICAgICAgIGV4dGVybmFsCiAgICAgICAgb25seU93bmVyCiAgICAgICAgdXBkYXRlUmV3YXJkKGFkZHJlc3MoMCkpCiAgICB7CiAgICAgICAgaWYgKGJsb2NrLnRpbWVzdGFtcCA+PSBmaW5pc2hBdCkgewogICAgICAgICAgICByZXdhcmRSYXRlID0gX2Ftb3VudCAvIGR1cmF0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHVpbnQyNTYgcmVtYWluaW5nUmV3YXJkcyA9IChmaW5pc2hBdCAtIGJsb2NrLnRpbWVzdGFtcCkgKiByZXdhcmRSYXRlOwogICAgICAgICAgICByZXdhcmRSYXRlID0gKF9hbW91bnQgKyByZW1haW5pbmdSZXdhcmRzKSAvIGR1cmF0aW9uOwogICAgICAgIH0KCiAgICAgICAgcmVxdWlyZShyZXdhcmRSYXRlID4gMCwgInJld2FyZCByYXRlID0gMCIpOwogICAgICAgIHJlcXVpcmUoCiAgICAgICAgICAgIHJld2FyZFJhdGUgKiBkdXJhdGlvbiA8PSByZXdhcmRzVG9rZW4uYmFsYW5jZU9mKGFkZHJlc3ModGhpcykpLAogICAgICAgICAgICAicmV3YXJkIGFtb3VudCA+IGJhbGFuY2UiCiAgICAgICAgKTsKCiAgICAgICAgZmluaXNoQXQgPSBibG9jay50aW1lc3RhbXAgKyBkdXJhdGlvbjsKICAgICAgICB1cGRhdGVkQXQgPSBibG9jay50aW1lc3RhbXA7CiAgICB9CgogICAgZnVuY3Rpb24gX21pbih1aW50MjU2IHgsIHVpbnQyNTYgeSkgcHJpdmF0ZSBwdXJlIHJldHVybnMgKHVpbnQyNTYpIHsKICAgICAgICByZXR1cm4geCA8PSB5ID8geCA6IHk7CiAgICB9Cn0KCmludGVyZmFjZSBJRVJDMjAgewogICAgZnVuY3Rpb24gdG90YWxTdXBwbHkoKSBleHRlcm5hbCB2aWV3IHJldHVybnMgKHVpbnQyNTYpOwogICAgZnVuY3Rpb24gYmFsYW5jZU9mKGFkZHJlc3MgYWNjb3VudCkgZXh0ZXJuYWwgdmlldyByZXR1cm5zICh1aW50MjU2KTsKICAgIGZ1bmN0aW9uIHRyYW5zZmVyKGFkZHJlc3MgcmVjaXBpZW50LCB1aW50MjU2IGFtb3VudCkKICAgICAgICBleHRlcm5hbAogICAgICAgIHJldHVybnMgKGJvb2wpOwogICAgZnVuY3Rpb24gYWxsb3dhbmNlKGFkZHJlc3Mgb3duZXIsIGFkZHJlc3Mgc3BlbmRlcikKICAgICAgICBleHRlcm5hbAogICAgICAgIHZpZXcKICAgICAgICByZXR1cm5zICh1aW50MjU2KTsKICAgIGZ1bmN0aW9uIGFwcHJvdmUoYWRkcmVzcyBzcGVuZGVyLCB1aW50MjU2IGFtb3VudCkgZXh0ZXJuYWwgcmV0dXJucyAoYm9vbCk7CiAgICBmdW5jdGlvbiB0cmFuc2ZlckZyb20oYWRkcmVzcyBzZW5kZXIsIGFkZHJlc3MgcmVjaXBpZW50LCB1aW50MjU2IGFtb3VudCkKICAgICAgICBleHRlcm5hbAogICAgICAgIHJldHVybnMgKGJvb2wpOwp9Cg=="}],Gb=`This is a minimal example of a contract that rewards users for staking their token.
+`,mb=({prev:s,next:a})=>i.jsx(A,{version:db,title:Cb,description:jb,cyfrinLink:Ab,html:yb,prev:s,next:a,codes:ub}),bb="0.8.26",wb="Staking Rewards",kb="Staking rewards contract based on Synthetix StakingRewards.sol",Zb="",Wb=[{fileName:"StakingRewards.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFN0YWtpbmdSZXdhcmRzIHsKICAgIElFUkMyMCBwdWJsaWMgaW1tdXRhYmxlIHN0YWtpbmdUb2tlbjsKICAgIElFUkMyMCBwdWJsaWMgaW1tdXRhYmxlIHJld2FyZHNUb2tlbjsKCiAgICBhZGR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GRyZXNzIF9yZXdhcmRUb2tlbikgewogICAgICAgIG93bmVyID0gbXNnLnNlbmRlcjsKICAgICAgICBzdGFraW5nVG9rZW4gPSBJRVJDMjAoX3N0YWtpbmdUb2tlbik7CiAgICAgICAgcmV3YXJkc1Rva2VuID0gSUVSQzIwKF9yZXdhcmRUb2tlbik7CiAgICB9CgogICAgbW9kaWZpZXIgb25seU93bmVyKCkgewogICAgICAgIHJlcXVpcmUobXNnLnNlbmRlciA9PSBvd25lciwgIm5vdCBhdXRob3JpemVkIik7CiAgICAgICAgXzsKICAgIH0KCiAgICBtb2RpZmllciB1cGRhdGVSZXdhcmQoYWRkcmVzcyBfYWNjb3VudCkgewogICAgICAgIHJld2FyZFBlclRva2VuU3RvcmVkID0gcmV3YXJkUGVyVG9rZW4oKTsKICAgICAgICB1cGRhdGVkQXQgPSBsYXN0VGltZVJld2FyZEFwcGxpY2FibGUoKTsKCiAgICAgICAgaWYgKF9hY2NvdW50ICE9IGFkZHJlc3MoMCkpIHsKICAgICAgICAgICAgcmV3YXJkc1tfYWNjb3VudF0gPSBlYXJuZWQoX2FjY291bnQpOwogICAgICAgICAgICB1c2VyUmV3YXJkUGVyVG9rZW5QYWlkW19hY2NvdW50XSA9IHJld2FyZFBlclRva2VuU3RvcmVkOwogICAgICAgIH0KCiAgICAgICAgXzsKICAgIH0KCiAgICBmdW5jdGlvbiBsYXN0VGltZVJld2FyZEFwcGxpY2FibGUoKSBwdWJsaWMgdmlldyByZXR1cm5zICh1aW50MjU2KSB7CiAgICAgICAgcmV0dXJuIF9taW4oZmluaXNoQXQsIGJsb2NrLnRpbWVzdGFtcCk7CiAgICB9CgogICAgZnVuY3Rpb24gcmV3YXJkUGVyVG9rZW4oKSBwdWJsaWMgdmlldyByZXR1cm5zICh1aW50MjU2KSB7CiAgICAgICAgaWYgKHRvdGFsU3VwcGx5ID09IDApIHsKICAgICAgICAgICAgcmV0dXJuIHJld2FyZFBlclRva2VuU3RvcmVkOwogICAgICAgIH0KCi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ICAgICByZXdhcmRSYXRlID0gKF9hbW91bnQgKyByZW1haW5pbmdSZXdhcmRzKSAvIGR1cmF0aW9uOwogICAgICAgIH0KCiAgICAgICAgcmVxdWlyZShyZXdhcmRSYXRlID4gMCwgInJld2FyZCByYXRlID0gMCIpOwogICAgICAgIHJlcXVpcmUoCiAgICAgICAgICAgIHJld2FyZFJhdGUgKiBkdXJhdGlvbiA8PSByZXdhcmRzVG9rZW4uYmFsYW5jZU9mKGFkZHJlc3ModGhpcykpLAogICAgICAgICAgICAicmV3YXJkIGFtb3VudCA+IGJhbGFuY2UiCiAgICAgICAgKTsKCiAgICAgICAgZmluaXNoQXQgPSBibG9jay50aW1lc3RhbXAgKyBkdXJhdGlvbjsKICAgICAgICB1cGRhdGVkQXQgPSBibG9jay50aW1lc3RhbXA7CiAgICB9CgogICAgZnVuY3Rpb24gX21pbih1aW50MjU2IHgsIHVpbnQyNTYgeSkgcHJpdmF0ZSBwdXJlIHJldHVybnMgKHVpbnQyNTYpIHsKICAgICAgICByZXR1cm4geCA8PSB5ID8geCA6IHk7CiAgICB9Cn0KCmludGVyZmFjZSBJRVJDMjAgewogICAgZnVuY3Rpb24gdG90YWxTdXBwbHkoKSBleHRlcm5hbCB2aWV3IHJldHVybnMgKHVpbnQyNTYpOwogICAgZnVuY3Rpb24gYmFsYW5jZU9mKGFkZHJlc3MgYWNjb3VudCkgZXh0ZXJuYWwgdmlldyByZXR1cm5zICh1aW50MjU2KTsKICAgIGZ1bmN0aW9uIHRyYW5zZmVyKGFkZHJlc3MgcmVjaXBpZW50LCB1aW50MjU2IGFtb3VudCkKICAgICAgICBleHRlcm5hbAogICAgICAgIHJldHVybnMgKGJvb2wpOwogICAgZnVuY3Rpb24gYWxsb3dhbmNlKGFkZHJlc3Mgb3duZXIsIGFkZHJlc3Mgc3BlbmRlcikKICAgICAgICBleHRlcm5hbAogICAgICAgIHZpZXcKICAgICAgICByZXR1cm5zICh1aW50MjU2KTsKICAgIGZ1bmN0aW9uIGFwcHJvdmUoYWRkcmVzcyBzcGVuZGVyLCB1aW50MjU2IGFtb3VudCkgZXh0ZXJuYWwgcmV0dXJucyAoYm9vbCk7CiAgICBmdW5jdGlvbiB0cmFuc2ZlckZyb20oYWRkcmVzcyBzZW5kZXIsIGFkZHJlc3MgcmVjaXBpZW50LCB1aW50MjU2IGFtb3VudCkKICAgICAgICBleHRlcm5hbAogICAgICAgIHJldHVybnMgKGJvb2wpOwp9Cg=="}],Bb=`This is a minimal example of a contract that rewards users for staking their token.
Code is a stripped down version of Synthetix StakingRewards.sol
// SPDX-License-Identifier: MIT
@@ -5495,7 +5547,7 @@ Topics
external
returns (bool);
}
-
`,Bb=({prev:s,next:a})=>i.jsx(A,{version:bb,title:wb,description:kb,cyfrinLink:Zb,html:Gb,prev:s,next:a,codes:Wb}),fb="0.8.26",Vb="Uniswap V2 Swap",Yb="Uniswap V2 swap",Xb="",vb=[{fileName:"UniswapV2SwapExamples.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFVuaXN3YXBWMlN3YXBFeGFtcGxlcyB7CiAgICBhZGRyZXNzIHByaXZhdGUgY29uc3RhbnQgVU5JU1dBUF9WMl9ST1VURVIgPQogICAgICAgIDB4N2EyNTBkNTYzMEI0Y0Y1Mzk3MzlkRjJDNWRBY2I0YzY1OUYyNDg4RDsKCiAgICBhZGRyZXNzIHByaXZhdGUgY29uc3RhbnQgV0VUSCA9IDB4QzAyYWFBMzliMjIzRkU4RDBBMGU1QzRGMjdlQUQ5MDgzQzc1NkNjMjsKICAgIGFkZHJlc3MgcHJpdmF0ZSBjb25zdGFudCBEQUkgPSAweDZCMTc1NDc0RTg5MDk0QzQ0RGE5OGI5NTRFZWRlQUM0OTUyNzFkMEY7CiAgICBhZGRyZXNzIGNvbnN0YW50IFVTREMgPSAweEEwYjg2OTkxYzYyMThiMzZjMWQxOUQ0YTJlOUViMG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N0aW9uIHN3YXBNdWx0aUhvcEV4YWN0QW1vdW50SW4odWludDI1NiBhbW91bnRJbiwgdWludDI1NiBhbW91bnRPdXRNaW4pCiAgICAgICAgZXh0ZXJuYWwKICAgICAgICByZXR1cm5zICh1aW50MjU2IGFtb3VudE91dCkKICAgIHsKICAgICAgICBkYWkudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICBkYWkuYXBwcm92ZShhZGRyZXNzKHJvdXRlciksIGFtb3VudEluKTsKCiAgICAgICAgYWRkcmVzc1tdIG1lbW9yeSBwYXRoOwogICAgICAgIHBhdGggPSBuZXcgYWRkcmVzc1tdKDMpOwogICAgICAgIHBhdGhbMF0gPSBEQUk7CiAgICAgICAgcGF0aFsxXSA9IFdFVEg7CiAgICAgICAgcGF0aFsyXSA9IFVTREM7CgogICAgICAgIHVpbnQyNTZbXSBtZW1vcnkgYW1vdW50cyA9IHJvdXRlci5zd2FwRXhhY3RUb2tlbnNGb3JUb2tlbnMoCiAgICAgICAgICAgIGFtb3VudEluLCBhbW91bnRPdXRNaW4sIHBhdGgsIG1zZy5zZW5kZXIsIGJsb2NrLnRpbWVzdGFtcAogICAgICAgICk7CgogICAgICAgIC8vIGFtb3VudHNbMF0gPSBEQUkgYW1vdW50CiAgICAgICAgLy8gYW1vdW50c1sxXSA9IFdFVEggYW1vdW50CiAgICAgICAgLy8gYW1vdW50c1syXSA9IFVTREMgYW1vdW50CiAgICAgICAgcmV0dXJuIGFtb3VudHNbMl07CiAgICB9CgogICAgLy8gU3dhcCBXRVRIIHRvIERBSQogICAgZnVuY3Rpb24gc3dhcFNpbmdsZUhvcEV4YWN0QW1vdW50T3V0KAogICAgICAgIHVpbnQyNTYgYW1vdW50T3V0RGVzaXJlZCwKICAgICAgICB1aW50MjU2IGFtb3VudEluTWF4CiAgICApIGV4dGVybmFsIHJldHVybnMgKHVpbnQyNTYgYW1vdW50T3V0KSB7CiAgICAgIC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yhyb3V0ZXIpLCBhbW91bnRJbk1heCk7CgogICAgICAgIGFkZHJlc3NbXSBtZW1vcnkgcGF0aDsKICAgICAgICBwYXRoID0gbmV3IGFkZHJlc3NbXSgzKTsKICAgICAgICBwYXRoWzBdID0gREFJOwogICAgICAgIHBhdGhbMV0gPSBXRVRIOwogICAgICAgIHBhdGhbMl0gPSBVU0RDOwoKICAgICAgICB1aW50MjU2W10gbWVtb3J5IGFtb3VudHMgPSByb3V0ZXIuc3dhcFRva2Vuc0ZvckV4YWN0VG9rZW5zKAogICAgICAgICAgICBhbW91bnRPdXREZXNpcmVkLCBhbW91bnRJbk1heCwgcGF0aCwgbXNnLnNlbmRlciwgYmxvY2sudGltZXN0YW1wCiAgICAgICAgKTsKCiAgICAgICAgLy8gUmVmdW5kIERBSSB0byBtc2cuc2VuZGVyCiAgICAgICAgaWYgKGFtb3VudHNbMF0gPCBhbW91bnRJbk1heCkgewogICAgICAgICAgICBkYWkudHJhbnNmZXIobXNnLnNlbmRlciwgYW1vdW50SW5NYXggLSBhbW91bnRzWzBdKTsKICAgICAgICB9CgogICAgICAgIHJldHVybiBhbW91bnRzWzJdOwogICAgfQp9CgppbnRlcmZhY2UgSVVuaXN3YXBWMlJvdXRlciB7CiAgICBmdW5jdGlvbiBzd2FwRXhhY3RUb2tlbnNGb3JUb2tlbnMoCiAgICAgICAgdWludDI1NiBhbW91bnRJbiwKICAgICAgICB1aW50MjU2IGFtb3VudE91dE1pbiwKICAgICAgICBhZGRyZXNzW10gY2FsbGRhdGEgcGF0aCwKICAgICAgICBhZGRyZXNzIHRvLAogICAgICAgIHVpbnQyNTYgZGVhZGxpbmUKICAgICkgZXh0ZXJuYWwgcmV0dXJucyAodWludDI1NltdIG1lbW9yeSBhbW91bnRzKTsKCiAgICBmdW5jdGlvbiBzd2FwVG9rZW5zRm9yRXhhY3RUb2tlbnMoCiAgICAgICAgdWludDI1NiBhbW91bnRPdXQsCiAgICAgICAgdWludDI1NiBhbW91bnRJbk1heCw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IHsKICAgICAgICAvLyBTd2FwIFdFVEggLT4gREFJCiAgICAgICAgdWludDI1NiB3ZXRoQW1vdW50ID0gMWUxODsKICAgICAgICB3ZXRoLmRlcG9zaXR7dmFsdWU6IHdldGhBbW91bnR9KCk7CiAgICAgICAgd2V0aC5hcHByb3ZlKGFkZHJlc3ModW5pKSwgd2V0aEFtb3VudCk7CgogICAgICAgIC8vIEJ1eSAxMDAgREFJCiAgICAgICAgdWludDI1NiBkYWlBbW91bnRPdXQgPSAxMDAgKiAxZTE4OwogICAgICAgIHVuaS5zd2FwU2luZ2xlSG9wRXhhY3RBbW91bnRPdXQoZGFpQW1vdW50T3V0LCB3ZXRoQW1vdW50KTsKCiAgICAgICAgLy8gU3dhcCBEQUkgLT4gV0VUSCAtPiBVU0RDCiAgICAgICAgZGFpLmFwcHJvdmUoYWRkcmVzcyh1bmkpLCBkYWlBbW91bnRPdXQpOwoKICAgICAgICB1aW50MjU2IGFtb3VudE91dERlc2lyZWQgPSAxZTY7CiAgICAgICAgdWludDI1NiBhbW91bnRPdXQgPQogICAgICAgICAgICB1bmkuc3dhcE11bHRpSG9wRXhhY3RBbW91bnRPdXQoYW1vdW50T3V0RGVzaXJlZCwgZGFpQW1vdW50T3V0KTsKCiAgICAgICAgY29uc29sZTIubG9nKCJVU0RDIiwgYW1vdW50T3V0KTsKICAgICAgICBhc3NlcnRFcSgKICAgICAgICAgICAgYW1vdW50T3V0LCBhbW91bnRPdXREZXNpcmVkLCAiYW1vdW50IG91dCAhPSBhbW91bnQgb3V0IGRlc2lyZWQiCiAgICAgICAgKTsKICAgIH0KfQo="}],Rb=`swapExactTokensForTokens
sells all tokens for another.
swapExactTokensForTokens
sells all tokens for another.
swapTokensForExactTokens
buys specific amount of tokens set by the caller.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -6908,7 +6960,7 @@ IERC20 constant PAIR Uniswap V3
-`,ww=({prev:s,next:a})=>i.jsx(A,{version:jw,title:Aw,description:uw,cyfrinLink:yw,html:bw,prev:s,next:a,codes:mw}),kw="0.8.26",Zw="Uniswap V3 Swap Examples",Ww="Uniswap V3 swap examples",Gw="",Bw=[{fileName:"UniswapV3MultiHopSwap.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmFkZHJlc3MgY29uc3RhbnQgU1dBUF9ST1VURVJfMDIgPSAweDY4YjM0NjU4MzNmYjcyQTcwZWNERjQ4NUUwZTRDN2JEODY2NUZjNDU7CmFkZHJlc3MgY29uc3RhbnQgV0VUSCA9IDB4QzAyYWFBMzliMjIzRkU4RDBBMGU1QzRGMjdlQUQ5MDgzQzc1NkNjMjsKYWRkcmVzcyBjb25zdGFudCBVU0RDID0gMHhBMGI4Njk5MWM2MjE4YjM2YzFkMTlENGEyZTlFYjBjRTM2MDZlQjQ4OwphZGRyZXNzIGNvbnN0YW50IERBSSA9IDB4NkIxNzU0NzRFODkwOTRDNDREYTk4Yjk1NEVlZGVBQzQ5NTI3MWQwRjsKCmNvbnRyYWN0IFVuaXN3YXBWM011bHRpSG9wU3dhcCB7CiAgICBJU3dhcFJvdXRlcjAyIHByaXZhdGUgY29uc3RhbnQgcm91dGVyID0gSVN3YXBSb3V0ZXIwMihTV0FQX1JPVVRFUl8wMik7CiAgICBJRVJDMjAgcHJpdmF0ZSBjb25zdGFudCB3ZXRoID0gSUVSQzIwKFdFVEgpOwogICAgSUVSQzIwIHByaXZhdGUgY29uc3RhbnQgZGFpID0gSUVSQzIwKERBSSk7CgogICAgZnVuY3Rpb24gc3dhcEV4YWN0SW5wdXRNdWx0aUhvcCh1aW50MjU2IGFtb3VudEluLCB1aW50MjU2IGFtb3VudE91dE1pbikKICAgICAgICBleHRlcm5hbAogICAgewogICAgICAgIHdldGgudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICB3ZXRoLmFwcHJvdmUoYW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MoewogICAgICAgICAgICBwYXRoOiBwYXRoLAogICAgICAgICAgICByZWNpcGllbnQ6IG1zZy5zZW5kZXIsCiAgICAgICAgICAgIGFtb3VudE91dDogYW1vdW50T3V0LAogICAgICAgICAgICBhbW91bnRJbk1heGltdW06IGFtb3VudEluTWF4CiAgICAgICAgfSk7CgogICAgICAgIHVpbnQyNTYgYW1vdW50SW4gPSByb3V0ZXIuZXhhY3RPdXRwdXQocGFyYW1zKTsKCiAgICAgICAgaWYgKGFtb3VudEluIDwgYW1vdW50SW5NYXgpIHsKICAgICAgICAgICAgd2V0aC5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgMCk7CiAgICAgICAgICAgIHdldGgudHJhbnNmZXIobXNnLnNlbmRlciwgYW1vdW50SW5NYXggLSBhbW91bnRJbik7CiAgICAgICAgfQogICAgfQp9CgppbnRlcmZhY2UgSVN3YXBSb3V0ZXIwMiB7CiAgICBzdHJ1Y3QgRXhhY3RJbnB1dFBhcmFtcyB7CiAgICAgICAgYnl0ZXMgcGF0aDsKICAgICAgICBhZGRyZXNzIHJlY2lwaWVudDsKICAgICAgICB1aW50MjU2IGFtb3VudEluOwogICAgICAgIHVpbnQyNTYgYW1vdW50T3V0TWluaW11bTsKICAgIH0KCiAgICBmdW5jdGlvbiBleGFjdElucHV0KEV4YWN0SW5wdXRQYXJhbXMgY2FsbGRhdGEgcGFyYW1zKQogICAgICAgIGV4dGVybmFsCiAgICAgICAgcGF5YWJsZQogICAgICAgIHJldHVybnMgKHVpbnQyNTYgYW1vdW50T3V0KTsKCiAgICBzdHJ1Y3QgRXhhY3RPdXRwdXRQYXJhbXMgewogICAgICAgIGJ5dGVzIHBhdGg7CiAgICAgICAgYWRkcmVzcyByZWNpcGllbnQ7CiAgICAgICAgdWludDI1NiBhbW91bnRPdXQ7CiAgICAgICAgdWludDI1NiBhbW91bnRJbk1heGltdW07CiAgICB9CgogICAgZnVuY3Rpb24gZXhhY3RPdXRwdXQoRXhhY3RPdXRwdXRQY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GFtb3VudEluLCB1aW50MjU2IGFtb3VudE91dE1pbikKICAgICAgICBleHRlcm5hbAogICAgewogICAgICAgIHdldGgudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICB3ZXRoLmFwcHJvdmUoYWRkcmVzcyhyb3V0ZXIpLCBhbW91bnRJbik7CgogICAgICAgIElTd2FwUm91dGVyMDIuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyBtZW1vcnkgcGFyYW1zID0gSVN3YXBSb3V0ZXIwMgogICAgICAgICAgICAuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyh7CiAgICAgICAgICAgIHRva2VuSW46IFdFVEgsCiAgICAgICAgICAgIHRva2VuT3V0OiBEQUksCiAgICAgICAgICAgIGZlZTogMzAwMCwKICAgICAgICAgICAgcmVjaXBpZW50OiBtc2cuc2VuZGVyLAogICAgICAgICAgICBhbW91bnRJbjogYW1vdW50SW4sCiAgICAgICAgICAgIGFtb3VudE91dE1pbmltdW06IGFtb3VudE91dE1pbiwKICAgICAgICAgICAgc3FydFByaWNlTGltaXRYOTY6IDAKICAgICAgICB9KTsKCiAgICAgICAgcm91dGVyLmV4YWN0SW5wdXRTaW5nbGUocGFyYW1zKTsKICAgIH0KCiAgICBmdW5jdGlvbiBzd2FwRXhhY3RPdXRwdXRTaW5nbGVIb3AodWludDI1NiBhbW91bnRPdXQsIHVpbnQyNTYgYW1vdW50SW5NYXgpCiAgICAgICAgZXh0ZXJuYWwKICAgIHsKICAgICAgICB3ZXRoLnRyYW5zZmVyRnJvbShtc2cuc2VuZGVyLCBhZGRyZXNzKHRoaXMpLCBhbW91bnRJbk1heCk7CiAgICAgICAgd2V0aC5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgYW1vdW50SW5NYXgpOwoKICAgICAgICBJU3dhcFJvdXRlcjAyLkV4YWN0T3V0cHV0U2luZ2xlUGFyYW1zIG1lbW9yeSBwYXJhbXMgPSBJU3dhcFJvdXRlcjAyCiAgICAgICAgICAgIC5FeGFjdE91dHB1dFNpbmdsZVBhcmFtcyh7CiAgICAgICAgICAgIHRva2VuSW46IFdFVEgsCiAgICAgICAgICAgIHRva2VuT3V0OiBEQUksCiAgICAgICAgICAgIGZlZTogMzAwMCwKICAgICAgICAgICAgcmVjaXBpZW50OiBtc2cuc2VuZGVyLAogICAgICAgICAgICBhbW91bnRPdXQ6IGFtb3VudE91dCwKICAgICAgICAgICAgYW1vdW50SW5NYXhpbXVtOiBhbW91bnRJbk1heCwKICAgICAgICAgICAgc3FydFByaWNlTGltaXRYOTY6IDAKICAgICAgICB9KTsKCiAgICAgICAgdWludDI1NiBhbW91bnRJbiA9IHJvdXRlci5leGFjdE91dHB1dFNpbmdsZShwYXJhbXMpOwoKICAgICAgICBpZiAoYW1vdW50SW4gPCBhbW91bnRJbk1heCkgewogICAgICAgICAgICB3ZXRoLmFwcHJvdmUoYWRkcmVzcyhyb3V0ZXIpLCAwKTsKICAgICAgICAgICAgd2V0aC50cmFuc2Zlcihtc2cuc2VuZGVyLCBhbW91bnRJbk1heCAtIGFtb3VudEluKTsKICAgICAgICB9CiAgICB9Cn0KCmludGVyZmFjZSBJU3dhcFJvdXRlcjAyIHsKICAgIHN0cnVjdCBFeGFjdElucHV0U2luZ2xlUGFyYW1zIHsKICAgICAgICBhZGRyZXNzIHRva2VuSW47CiAgICAgICAgYWRkcmVzcyB0b2tlbk91dDsKICAgICAgICB1aW50MjQgZmVlOwogICAgICAgIGFkZHJlc3MgcmVjaXBpZW50OwogICAgICAgIHVpbnQyNTYgYW1vdW50SW47CiAgICAgICAgdWludDI1NiBhbW91bnRPdXRNaW5pbXVtOwogICAgICAgIHVpbnQxNjAgc3FydFByaWNlTGltaXRYOTY7CiAgICB9CgogICAgZnVuY3Rpb24gZXhhY3RJbnB1dFNpbmdsZShFeGFjdElucHV0U2luZ2xlUGFyYW1zIGNhbGxkYXRhIHBhcmFtcykKICAgICAgICBleHRlcm5hb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dG9rZW5JbiwgYWRkcmVzcyB0b2tlbk91dCwgdWludDI0IHBvb2xGZWUsIHVpbnQyNTYgYW1vdW50SW4pCiAgICAgICAgZXh0ZXJuYWwKICAgICAgICByZXR1cm5zICh1aW50MjU2IGFtb3VudE91dCkKICAgIHsKICAgICAgICBJRVJDMjAodG9rZW5JbikudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICBJRVJDMjAodG9rZW5JbikuYXBwcm92ZShhZGRyZXNzKHJvdXRlciksIGFtb3VudEluKTsKCiAgICAgICAgSVN3YXBSb3V0ZXIuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyBtZW1vcnkgcGFyYW1zID0gSVN3YXBSb3V0ZXIuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyh7CiAgICAgICAgICAgIHRva2VuSW46IHRva2VuSW4sCiAgICAgICAgICAgIHRva2VuT3V0OiB0b2tlbk91dCwKICAgICAgICAgICAgZmVlOiBwb29sRmVlLAogICAgICAgICAgICByZWNpcGllbnQ6IG1zZy5zZW5kZXIsCiAgICAgICAgICAgIGRlYWRsaW5lOiBibG9jay50aW1lc3RhbXAsCiAgICAgICAgICAgIGFtb3VudEluOiBhbW91bnRJbiwKICAgICAgICAgICAgYW1vdW50T3V0TWluaW11bTogMCwKICAgICAgICAgICAgc3FydFByaWNlTGltaXRYOTY6IDAKICAgICAgICB9KTsKCiAgICAgICAgYW1vdW50T3V0ID0gcm91dGVyLmV4YWN0SW5wdXRTaW5nbGUocGFyYW1zKTsKICAgIH0KCiAgICBmdW5jdGlvbiBzd2FwRXhhY3RJbnB1dE11bHRpSG9wKGJ5dGVzIGNhbGxkYXRhIHBhdGgsIGFkZHJlc3MgdG9rZW5JbiwgdWludDI1NiBhbW91bnRJbikKICAgICAgICBleHRlcm5hbAogICAgICAgIHJldHVybnMgKHVpbnQyNTYgYW1vdW50T3V0KQogICAgewogICAgICAgIElFUkMyMCh0b2tlbkluKS50cmFuc2ZlckZyb20obXNnLnNlbmRlciwgYWRkcmVzcyh0aGlzKSwgYW1vdW50SW4pOwogICAgICAgIElFUkMyMCh0b2tlbkluKS5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgYW1vdW50SW4pOwoKICAgICAgICBJU3dhcFJvdXRlci5FeGFjdElucHV0UGFyYW1zIG1lbW9yeSBwYXJhbXMgPSBJU3dhcFJvdXRlci5FeGFjdElucHV0UGFyYW1zKHsKICAgICAgICAgICAgcGF0aDogcGF0aCwKICAgICAgICAgICAgcmVjaXBpZW50OiBtc2cuc2VuZGVyLAogICAgICAgICAgICBkZWFkbGluZTogYmxvY2sudGltZXN0YW1wLAogICAgICAgICAgICBhbW91bnRJbjogYW1vdW50SW4sCiAgICAgICAgICAgIGFtb3VudE91dE1pbmltdW06IDAKICAgICAgICB9KTsKICAgICAgICBhbW91bnRPdXQgPSByb3V0ZXIuZXhhY3RJbnB1dChwYXJhbXMpOwogICAgfQp9CgppbnRlcmZhY2UgSVN3YXBSb3V0ZXIgewogICAgc3RydWN0IEV4YWN0SW5wdXRTaW5nbGVQYXJhbXMgewogICAgICAgIGFkZHJlc3MgdG9rZW5JbjsKICAgICAgICBhZGRyZXNzIHRva2VuT3V0OwogICAgICAgIHVpbnQyNCBmZWU7CiAgICAgICAgYWRkcmVzcyByZWNpcGllbnQ7CiAgICAgICAgdWludDI1NiBkZWFkbGluZTsKICAgICAgICB1aW50MjU2IGFtb3VudEluOwogICAgICAgIHVpbnQyNTYgYW1vdW50T3V0TWluaW11bTsKICAgICAgICB1aW50MTYwIHNxcnRQcmljZUxpbWl0WDk2OwogICAgfQoKICAgIC8vLyBAbm90aWNlIFN3YXBzIGFtb3VudEluIG9mIG9uZSB0b2tlbiBmb3IgYXMgbXVjaCBhcyBwb3NzaWJsZSBvZiBhbm90aGVyIHRva2VuCiAgICAvLy8gQHBhcmFtIHBhcmFtcyBUaGUgcGFyYW1ldGVycyBuZWNlc3NhcnkgZm9yIHR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ieXRlcyBtZW1vcnkgcGF0aCA9IGFiaS5lbmNvZGVQYWNrZWQoV0VUSCwgdWludDI0KDMwMDApLCBVU0RDLCB1aW50MjQoMTAwKSwgREFJKTsKCiAgICAgICAgdWludDI1NiBhbW91bnRPdXQgPSB1bmkuc3dhcEV4YWN0SW5wdXRNdWx0aUhvcChwYXRoLCBXRVRILCAxZTE4KTsKCiAgICAgICAgY29uc29sZTIubG9nKCJEQUkiLCBhbW91bnRPdXQpOwogICAgfQp9Cg=="}],fw=`Uniswap V3 Single Hop Swap
+`,ww=({prev:s,next:a})=>i.jsx(A,{version:jw,title:Aw,description:uw,cyfrinLink:yw,html:bw,prev:s,next:a,codes:mw}),kw="0.8.26",Zw="Uniswap V3 Swap Examples",Ww="Uniswap V3 swap examples",Bw="",Gw=[{fileName:"UniswapV3MultiHopSwap.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmFkZHJlc3MgY29uc3RhbnQgU1dBUF9ST1VURVJfMDIgPSAweDY4YjM0NjU4MzNmYjcyQTcwZWNERjQ4NUUwZTRDN2JEODY2NUZjNDU7CmFkZHJlc3MgY29uc3RhbnQgV0VUSCA9IDB4QzAyYWFBMzliMjIzRkU4RDBBMGU1QzRGMjdlQUQ5MDgzQzc1NkNjMjsKYWRkcmVzcyBjb25zdGFudCBVU0RDID0gMHhBMGI4Njk5MWM2MjE4YjM2YzFkMTlENGEyZTlFYjBjRTM2MDZlQjQ4OwphZGRyZXNzIGNvbnN0YW50IERBSSA9IDB4NkIxNzU0NzRFODkwOTRDNDREYTk4Yjk1NEVlZGVBQzQ5NTI3MWQwRjsKCmNvbnRyYWN0IFVuaXN3YXBWM011bHRpSG9wU3dhcCB7CiAgICBJU3dhcFJvdXRlcjAyIHByaXZhdGUgY29uc3RhbnQgcm91dGVyID0gSVN3YXBSb3V0ZXIwMihTV0FQX1JPVVRFUl8wMik7CiAgICBJRVJDMjAgcHJpdmF0ZSBjb25zdGFudCB3ZXRoID0gSUVSQzIwKFdFVEgpOwogICAgSUVSQzIwIHByaXZhdGUgY29uc3RhbnQgZGFpID0gSUVSQzIwKERBSSk7CgogICAgZnVuY3Rpb24gc3dhcEV4YWN0SW5wdXRNdWx0aUhvcCh1aW50MjU2IGFtb3VudEluLCB1aW50MjU2IGFtb3VudE91dE1pbikKICAgICAgICBleHRlcm5hbAogICAgewogICAgICAgIHdldGgudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICB3ZXRoLmFwcHJvdmUoYWRkcmVzcyhyb3V0ZXIpLCBhbW91bnRJbik7CgogICAgICAgIGJ5dGVzIG1lbW9yeSBwYXRoID0KICAgICAgICAgICAgYWJpLmVuY29kZVBhY2tlZChXRVRILCB1aW50MjQoMzAwMCksIFVTREMsIHVpbnQyNCgxMDApLCBEQUkpOwoKICAgICAgICBJU3dhcFJvdXRlcjAyLkV4YWN0SW5wdXRQYXJhbXMgbWVtb3J5IHBhcmFtcyA9IElTd2FwUm91dGVyMDIKICAgICAgICAgICAgLkV4YWN0SW5wdXRQYXJhbXMoewogICAgICAgICAgICBwYXRoOiBwYXRoLAogICAgICAgICAgICByZWNpcGllbnQ6IG1zZy5zZW5kZXIsCiAgICAgICAgICAgIGFtb3VudEluOiBhbW91bnRJbiwKICAgICAgICAgICAgYW1vdW50T3V0TWluaW11bTogYW1vdW50T3V0TWluCiAgICAgICAgfSk7CgogICAgICAgIHJvdXRlci5leGFjdElucHV0KHBhcmFtcyk7CiAgICB9CgogICAgZnVuY3Rpb24gc3dhcEV4YWN0T3V0cHV0TXVsdGlIb3AodWludDI1NiBhbW91bnRPdXQsIHVpbnQyNTYgYW1vdW50SW5NYXgpCiAgICAgICAgZXh0ZXJuYWwKICAgIHsKICAgICAgICB3ZXRoLnRyYW5zZmVyRnJvbShtc2cuc2VuZGVyLCBhZGRyZXNzKHRoaXMpLCBhbW91bnRJbk1heCk7CiAgICAgICAgd2V0aC5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgYW1vdW50SW5NYXgpOwoKICAgICAgICBieXRlcyBtZW1vcnkgcGF0aCA9CiAgICAgICAgICAgIGFiaS5lbmNvZGVQYWNrZWQoREFJLCB1aW50MjQoMTAwKSwgVVNEQywgdWludDI0KDMwMDApLCBXRVRIKTsKCiAgICAgICAgSVN3YXBSb3V0ZXIwMi5FeGFjdE91dHB1dFBhcmFtcyBtZW1vcnkgcGFyYW1zID0gSVN3YXBSb3V0ZXIwMgogICAgICAgICAgICAuRXhhY3RPdXRwdXRQYXJhbXMoewogICAgICAgICAgICBwYXRoOiBwYXRoLAogICAgICAgICAgICByZWNpcGllbnQ6IG1zZy5zZW5kZXIsCiAgICAgICAgICAgIGFtb3VudE91dDogYW1vdW50T3V0LAogICAgICAgICAgICBhbW91bnRJbk1heGltdW06IGFtb3VudEluTWF4CiAgICAgICAgfSk7CgogICAgICAgIHVpbnQyNTYgYW1vdW50SW4gPSByb3V0ZXIuZXhhY3RPdXRwdXQocGFyYW1zKTsKCiAgICAgICAgaWYgKGFtb3VudEluIDwgYW1vdW50SW5NYXgpIHsKICAgICAgICAgICAgd2V0aC5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgMCk7CiAgICAgICAgICAgIHdldGgudHJhbnNmZXIobXNnLnNlbmRlciwgYW1vdW50SW5NYXggLSBhbW91bnRJbik7CiAgICAgICAgfQogICAgfQp9CgppbnRlcmZhY2UgSVN3YXBSb3V0ZXIwMiB7CiAgICBzdHJ1Y3QgRXhhY3RJbnB1dFBhcmFtcyB7CiAgICAgICAgYnl0ZXMgcGF0aDsKICAgICAgICBhZGRyZXNzIHJlY2lwaWVudDsKICAgICAgICB1aW50MjU2IGFtb3VudEluOwogICAgICAgIHVpbnQyNTYgYW1vdW50T3V0TWluaW11bTsKICAgIH0KCiAgICBmdW5jdGlvbiBleGFjdElucHV0KEV4YWN0SW5wdXRQYXJhbXM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yNzFkMEY7Cgpjb250cmFjdCBVbmlzd2FwVjNTaW5nbGVIb3BTd2FwIHsKICAgIElTd2FwUm91dGVyMDIgcHJpdmF0ZSBjb25zdGFudCByb3V0ZXIgPSBJU3dhcFJvdXRlcjAyKFNXQVBfUk9VVEVSXzAyKTsKICAgIElFUkMyMCBwcml2YXRlIGNvbnN0YW50IHdldGggPSBJRVJDMjAoV0VUSCk7CiAgICBJRVJDMjAgcHJpdmF0ZSBjb25zdGFudCBkYWkgPSBJRVJDMjAoREFJKTsKCiAgICBmdW5jdGlvbiBzd2FwRXhhY3RJbnB1dFNpbmdsZUhvcCh1aW50MjU2IGFtb3VudEluLCB1aW50MjU2IGFtb3VudE91dE1pbikKICAgICAgICBleHRlcm5hbAogICAgewogICAgICAgIHdldGgudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICB3ZXRoLmFwcHJvdmUoYWRkcmVzcyhyb3V0ZXIpLCBhbW91bnRJbik7CgogICAgICAgIElTd2FwUm91dGVyMDIuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyBtZW1vcnkgcGFyYW1zID0gSVN3YXBSb3V0ZXIwMgogICAgICAgICAgICAuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyh7CiAgICAgICAgICAgIHRva2VuSW46IFdFVEgsCiAgICAgICAgICAgIHRva2VuT3V0OiBEQUksCiAgICAgICAgICAgIGZlZTogMzAwMCwKICAgICAgICAgICAgcmVjaXBpZW50OiBtc2cuc2VuZGVyLAogICAgICAgICAgICBhbW91bnRJbjogYW1vdW50SW4sCiAgICAgICAgICAgIGFtb3VudE91dE1pbmltdW06IGFtb3VudE91dE1pbiwKICAgICAgICAgICAgc3FydFByaWNlTGltaXRYOTY6IDAKICAgICAgICB9KTsKCiAgICAgICAgcm91dGVyLmV4YWN0SW5wdXRTaW5nbGUocGFyYW1zKTsKICAgIH0KCiAgICBmdW5jdGlvbiBzd2FwRXhhY3RPdXRwdXRTaW5nbGVIb3AodWludDI1NiBhbW91bnRPdXQsIHVpbnQyNTYgYW1vdW50SW5NYXgpCiAgICAgICAgZXh0ZXJuYWwKICAgIHsKICAgICAgICB3ZXRoLnRyYW5zZmVyRnJvbShtc2cuc2VuZGVyLCBhZGRyZXNzKHRoaXMpLCBhbW91bnRJbk1heCk7CiAgICAgICAgd2V0aC5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgYW1vdW50SW5NYXgpOwoKICAgICAgICBJU3dhcFJvdXRlcjAyLkV4YWN0T3V0cHV0U2luZ2xlUGFyYW1zIG1lbW9yeSBwYXJhbXMgPSBJU3dhcFJvdXRlcjAyCiAgICAgICAgICAgIC5FeGFjdE91dHB1dFNpbmdsZVBhcmFtcyh7CiAgICAgICAgICAgIHRva2VuSW46IFdFVEgsCiAgICAgICAgICAgIHRva2VuT3V0OiBEQUksCiAgICAgICAgICAgIGZlZTogMzAwMCwKICAgICAgICAgICAgcmVjaXBpZW50OiBtc2cuc2VuZGVyLAogICAgICAgICAgICBhbW91bnRPdXQ6IGFtb3VudE91dCwKICAgICAgICAgICAgYW1vdW50SW5NYXhpbXVtOiBhbW91bnRJbk1heCwKICAgICAgICAgICAgc3FydFByaWNlTGltaXRYOTY6IDAKICAgICAgICB9KTsKCiAgICAgICAgdWludDI1NiBhbW91bnRJbiA9IHJvdXRlci5leGFjdE91dHB1dFNpbmdsZShwYXJhbXMpOwoKICAgICAgICBpZiAoYW1vdW50SW4gPCBhbW91bnRJbk1heCkgewogICAgICAgICAgICB3ZXRoLmFwcHJvdmUoYWRkcmVzcyhyb3V0ZXIpLCAwKTsKICAgICAgICAgICAgd2V0aC50cmFuc2Zlcihtc2cuc2VuZGVyLCBhbW91bnRJbk1heCAtIGFtb3VudEluKTsKICAgICAgICB9CiAgICB9Cn0KCmludGVyZmFjZSBJU3dhcFJvdXRlcjAyIHsKICAgIHN0cnVjdCBFeGFjdElucHV0U2luZ2xlUGFyYW1zIHsKICAgICAgICBhZGRyZXNzIHRva2VuSW47CiAgICAgICAgYWRkcmVzcyB0b2tlbk91dDsKICAgICAgICB1aW50MjQgZmVlOwogICAgICAgIGFkZHJlc3MgcmVjaXBpZW50OwogICAgICAgIHVpbnQyNTYgYW1vdW50SW47CiAgICAgICAgdWludDI1NiBhbW91bnRPdXRNaW5pbXVtOwogICAgICAgIHVpbnQxNjAgc3FydFByaWNlTGltaXRYOTY7CiAgICB9CgogICAgZnVuY3Rpb24gZXhhY3RJbnB1dFNpbmdsZShFeGFjdElucHV0U2luZ2xlUGFyYW1zIGNhbGxkYXRhIHBhcmFtcykKICAgICAgICBleHRlcm5hbAogICAgICAgIHBheWFibGUKICAgICAgICByZXR1cm5zICh1aW50MjU2IGFtb3VudE91dCk7CgogICAgc3RydWN0IEV4YWN0T3V0cHV0U2luZ2xlUGFyYW1zIHsKICAgICAgICBhZGRyZXNzIHRva2VuSW47CiAgICAgICAgYWRkcmVzcyB0b2tlbk91dDsKICAgICAgICB1aW50MjQgZmVlOwogICAgICAgIGFkZHJlc3MgcmVjaXBpZW50OwogICAgICAgIHVpbnQyNTYgYW1vdW50T3V0OwogICAgICAgIHVpbnQyNTYgYW1vdW50SW5NYXhpbXVtOwogICAgICAgIHVpbnQxNjAgc3FydFByaWNlTGltaXRYOTY7CiAgICB9CgogICAgZnVuY3Rpb24gZXhhY3RPdXRwdXRTaW5nbGUoRXhhY3RPdXRwdXRTaW5nbGVQYXJhbXMgY2FsbGRhdGEgcGFyYW1zKQogICAgICAgIGV4dGVybmFsCiAgICAgICAgcGF5YWJsZQogICAgICAgIHJldHVybnMgKHVpbnQyNTYgYW1vdW50SW4pOwp9CgppbnRlcmZhY2UgSUVSQzIwIHsKICAgIGZ1bmN0aW9uIHRvdGFsU3VwcGx5KCkgZXh0ZXJuYWwgdmlldyByZXR1cm5zICh1aW50MjU2KTsKICAgIGZ1bmN0aW9uIGJhbGFuY2VPZihhZGRyZXNzIGFjY291bnQpIGV4dGVybmFsIHZpZXcgcmV0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ICAgIH0KfQo="},{fileName:"UniswapV3SwapExamples.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFVuaXN3YXBWM1N3YXBFeGFtcGxlcyB7CiAgICBJU3dhcFJvdXRlciBjb25zdGFudCByb3V0ZXIgPSBJU3dhcFJvdXRlcigweEU1OTI0MjdBMEFFY2U5MkRlM0VkZWUxRjE4RTAxNTdDMDU4NjE1NjQpOwoKICAgIGZ1bmN0aW9uIHN3YXBFeGFjdElucHV0U2luZ2xlSG9wKGFkZHJlc3MgdG9rZW5JbiwgYWRkcmVzcyB0b2tlbk91dCwgdWludDI0IHBvb2xGZWUsIHVpbnQyNTYgYW1vdW50SW4pCiAgICAgICAgZXh0ZXJuYWwKICAgICAgICByZXR1cm5zICh1aW50MjU2IGFtb3VudE91dCkKICAgIHsKICAgICAgICBJRVJDMjAodG9rZW5JbikudHJhbnNmZXJGcm9tKG1zZy5zZW5kZXIsIGFkZHJlc3ModGhpcyksIGFtb3VudEluKTsKICAgICAgICBJRVJDMjAodG9rZW5JbikuYXBwcm92ZShhZGRyZXNzKHJvdXRlciksIGFtb3VudEluKTsKCiAgICAgICAgSVN3YXBSb3V0ZXIuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyBtZW1vcnkgcGFyYW1zID0gSVN3YXBSb3V0ZXIuRXhhY3RJbnB1dFNpbmdsZVBhcmFtcyh7CiAgICAgICAgICAgIHRva2VuSW46IHRva2VuSW4sCiAgICAgICAgICAgIHRva2VuT3V0OiB0b2tlbk91dCwKICAgICAgICAgICAgZmVlOiBwb29sRmVlLAogICAgICAgICAgICByZWNpcGllbnQ6IG1zZy5zZW5kZXIsCiAgICAgICAgICAgIGRlYWRsaW5lOiBibG9jay50aW1lc3RhbXAsCiAgICAgICAgICAgIGFtb3VudEluOiBhbW91bnRJbiwKICAgICAgICAgICAgYW1vdW50T3V0TWluaW11bTogMCwKICAgICAgICAgICAgc3FydFByaWNlTGltaXRYOTY6IDAKICAgICAgICB9KTsKCiAgICAgICAgYW1vdW50T3V0ID0gcm91dGVyLmV4YWN0SW5wdXRTaW5nbGUocGFyYW1zKTsKICAgIH0KCiAgICBmdW5jdGlvbiBzd2FwRXhhY3RJbnB1dE11bHRpSG9wKGJ5dGVzIGNhbGxkYXRhIHBhdGgsIGFkZHJlc3MgdG9rZW5JbiwgdWludDI1NiBhbW91bnRJbikKICAgICAgICBleHRlcm5hbAogICAgICAgIHJldHVybnMgKHVpbnQyNTYgYW1vdW50T3V0KQogICAgewogICAgICAgIElFUkMyMCh0b2tlbkluKS50cmFuc2ZlckZyb20obXNnLnNlbmRlciwgYWRkcmVzcyh0aGlzKSwgYW1vdW50SW4pOwogICAgICAgIElFUkMyMCh0b2tlbkluKS5hcHByb3ZlKGFkZHJlc3Mocm91dGVyKSwgYW1vdW50SW4pOwoKICAgICAgICBJU3dhcFJvdXRlci5FeGFjdElucHV0UGFyYW1zIG1lbW9yeSBwYXJhbXMgPSBJU3dhcFJvdXRlci5FeGFjdElucHV0UGFyYW1zKHsKICAgICAgICAgICAgcGF0aDogcGF0aCwKICAgICAgICAgICAgcmVjaXBpZW50OiBtc2cuc2VuZGVyLAogICAgICAgICAgICBkZWFkbGluZTogYmxvY2sudGltZXN0YW1wLAogICAgICAgICAgICBhbW91bnRJbjogYW1vdW50SW4sCiAgICAgICAgICAgIGFtb3VudE91dE1pbmltdW06IDAKICAgICAgICB9KTsKICAgICAgICBhbW91bnRPdXQgPSByb3V0ZXIuZXhhY3RJbnB1dChwYXJhbXMpOwogICAgfQp9CgppbnRlcmZhY2UgSVN3YXBSb3V0ZXIgewogICAgc3RydWN0IEV4YWN0SW5wdXRTaW5nbGVQYXJhbXMgewogICAgICAgIGFkZHJlc3MgdG9rZW5JbjsKICAgICAgICBhZGRyZXNzIHRva2VuT3V0OwogICAgICAgIHVpbnQyNCBmZWU7CiAgICAgICAgYWRkcmVzcyByZWNpc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bmkpLCAxZTE4KTsKCiAgICAgICAgdWludDI1NiBhbW91bnRPdXQgPSB1bmkuc3dhcEV4YWN0SW5wdXRTaW5nbGVIb3AoV0VUSCwgREFJLCAzMDAwLCAxZTE4KTsKCiAgICAgICAgY29uc29sZTIubG9nKCJEQUkiLCBhbW91bnRPdXQpOwogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3RNdWx0aUhvcCgpIHB1YmxpYyB7CiAgICAgICAgd2V0aC5kZXBvc2l0e3ZhbHVlOiAxZTE4fSgpOwogICAgICAgIHdldGguYXBwcm92ZShhZGRyZXNzKHVuaSksIDFlMTgpOwoKICAgICAgICBieXRlcyBtZW1vcnkgcGF0aCA9IGFiaS5lbmNvZGVQYWNrZWQoV0VUSCwgdWludDI0KDMwMDApLCBVU0RDLCB1aW50MjQoMTAwKSwgREFJKTsKCiAgICAgICAgdWludDI1NiBhbW91bnRPdXQgPSB1bmkuc3dhcEV4YWN0SW5wdXRNdWx0aUhvcChwYXRoLCBXRVRILCAxZTE4KTsKCiAgICAgICAgY29uc29sZTIubG9nKCJEQUkiLCBhbW91bnRPdXQpOwogICAgfQp9Cg=="}],fw=`Uniswap V3 Single Hop Swap
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -7224,7 +7276,7 @@ IERC20 constant PAIR address(swap)), 0, "DAI balance of swap != 0");
}
}
-
`,Vw=({prev:s,next:a})=>i.jsx(A,{version:kw,title:Zw,description:Ww,cyfrinLink:Gw,html:fw,prev:s,next:a,codes:Bw}),Yw="0.8.26",Xw="Vault",vw="Vault",Rw="",Nw=[{fileName:"Vault.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFZhdWx0IHsKICAgIElFUkMyMCBwdWJsaWMgaW1tdXRhYmxlIHRva2VuOwoKICAgIHVpbnQyNTYgcHVibGljIHRvdGFsU3VwcGx5OwogICAgbWFwcGluZyhhZGRyZXNzID0+IHVpbnQyNTYpIHB1YmxpYyBiYWxhbmNlT2Y7CgogICAgY29uc3RydWN0b3IoYWRkcmVzcyBfdG9rZW4pIHsKICAgICAgICB0b2tlbiA9IElFUkMyMChfdG9rZW4pOwogICAgfQoKICAgIGZ1bmN0aW9uIF9taW50KGFkZHJlc3MgX3RvLCB1aW50MjU2IF9zaGFyZXMpIHByaXZhdGUgewogICAgICAgIHRvdGFsU3VwcGx5ICs9IF9zaGFyZXM7CiAgICAgICAgYmFsYW5jZU9mW190b10gKz0gX3NoYXJlczsKICAgIH0KCiAgICBmdW5jdGlvbiBfYnVybihhZGRyZXNzIF9mcm9tLCB1aW50MjU2IF9zaGFyZXMpIHByaXZhdGUgewogICAgICAgIHRvdGFsU3VwcGx5IC09IF9zaGFyZXM7CiAgICAgICAgYmFsYW5jZU9mW19mcm9tXSAtPSBfc2hhcmVzOwogICAgfQoKICAgIGZ1bmN0aW9uIGRlcG9zaXQodWludDI1NiBfYW1vdW50KSBleHRlcm5hbCB7CiAgICAgICAgLyoKICAgICAgICBhID0gYW1vdW50CiAgICAgICAgQiA9IGJhbGFuY2Ugb2YgdG9rZW4gYmVmb3JlIGRlcG9zaXQKICAgICAgICBUID0gdG90YWwgc3VwcGx5CiAgICAgICAgcyA9IHNoYXJlcyB0byBtaW50CgogICAgICAgIChUICsgcykgLyBUID0gKGEgKyBCKSAvIEIgCgogICAgICAgIHMgPSBhVCAvIEIKICAgICAgICAqLwogICAgICAgIHVpbnQyNTYgc2hhcmVzOwogICAgICAgIGlmICh0b3RhbFN1cHBseSA9PSAwKSB7CiAgICAgICAgICAgIHNoYXJlcyA9IF9hbW91bnQ7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc2hhcmVzID0gKF9hbW91bnQgKiB0b3RhbFN1cHBseSkgLyB0b2tlbi5iYWxhbmNlT2YoYWRkcmVzcyh0aGlzKSk7CiAgICAgICAgfQoKICAgICAgICBfbWludChtc2cuc2VuZGVyLCBzaGF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ogICAgICAgIHJldHVybnMgKHVpbnQyNTYpOwoKICAgIGZ1bmN0aW9uIGFwcHJvdmUoYWRkcmVzcyBzcGVuZGVyLCB1aW50MjU2IGFtb3VudCkgZXh0ZXJuYWwgcmV0dXJucyAoYm9vbCk7CgogICAgZnVuY3Rpb24gdHJhbnNmZXJGcm9tKGFkZHJlc3Mgc2VuZGVyLCBhZGRyZXNzIHJlY2lwaWVudCwgdWludDI1NiBhbW91bnQpCiAgICAgICAgZXh0ZXJuYWwKICAgICAgICByZXR1cm5zIChib29sKTsKCiAgICBldmVudCBUcmFuc2ZlcihhZGRyZXNzIGluZGV4ZWQgZnJvbSwgYWRkcmVzcyBpbmRleGVkIHRvLCB1aW50MjU2IGFtb3VudCk7CiAgICBldmVudCBBcHByb3ZhbCgKICAgICAgICBhZGRyZXNzIGluZGV4ZWQgb3duZXIsIGFkZHJlc3MgaW5kZXhlZCBzcGVuZGVyLCB1aW50MjU2IGFtb3VudAogICAgKTsKfQo="}],Hw=`Simple example of vault contract, commonly used in DeFi protocols.
+
`,Vw=({prev:s,next:a})=>i.jsx(A,{version:kw,title:Zw,description:Ww,cyfrinLink:Bw,html:fw,prev:s,next:a,codes:Gw}),Yw="0.8.26",Xw="Vault",vw="Vault",Rw="",Nw=[{fileName:"Vault.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFZhdWx0IHsKICAgIElFUkMyMCBwdWJsaWMgaW1tdXRhYmxlIHRva2VuOwoKICAgIHVpbnQyNTYgcHVibGljIHRvdGFsU3VwcGx5OwogICAgbWFwcGluZyhhZGRyZXNzID0+IHVpbnQyNTYpIHB1YmxpYyBiYWxhbmNlT2Y7CgogICAgY29uc3RydWN0b3IoYWRkcmVzcyBfdG9rZW4pIHsKICAgICAgICB0b2tlbiA9IElFUkMyMChfdG9rZW4pOwogICAgfQoKICAgIGZ1bmN0aW9uIF9taW50KG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XJGcm9tKGFkZHJlc3Mgc2VuZGVyLCBhZGRyZXNzIHJlY2lwaWVudCwgdWludDI1NiBhbW91bnQpCiAgICAgICAgZXh0ZXJuYWwKICAgICAgICByZXR1cm5zIChib29sKTsKCiAgICBldmVudCBUcmFuc2ZlcihhZGRyZXNzIGluZGV4ZWQgZnJvbSwgYWRkcmVzcyBpbmRleGVkIHRvLCB1aW50MjU2IGFtb3VudCk7CiAgICBldmVudCBBcHByb3ZhbCgKICAgICAgICBhZGRyZXNzIGluZGV4ZWQgb3duZXIsIGFkZHJlc3MgaW5kZXhlZCBzcGVuZGVyLCB1aW50MjU2IGFtb3VudAogICAgKTsKfQo="}],Hw=`Simple example of vault contract, commonly used in DeFi protocols.
Most vaults on the mainnet are more complex. Here we will focus on the math for calculating shares to mint on deposit and the amount of token to withdraw.
view
or pure
functions, as they alter the state of the blockchain by storing logs.Examples of
+`,Zk=({prev:s,next:a})=>i.jsx(A,{version:uk,title:yk,description:mk,cyfrinLink:bk,html:kk,prev:s,next:a,codes:wk}),Wk="0.8.26",Bk="EVM Memory Layout in Solidity",Gk="Example of EVM memory in Solidity",fk="",Vk=[{fileName:"YulMem.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgMC44LjI2OwoKLy8gTWVtb3J5IGxheW91dAovLyBhcnJheSBvZiBsZW5ndGggMioqMjU2ICgzMiBieXRlcyksIGVhY2ggZWxlbWVudCBzdG9yZXMgMSBieXRlICgweDAwIHRvIDB4ZmYpCi8vIGluZGV4ICAgICAwICAgIDEgICAgMiAgIC4uLiAgIDB4ZmZmLi4uZmZmID0gMioqMjU2IC0gMQovLyBtZW1vcnkgfCAwMCB8IDAwIHwgMDAgfCAuLi4gfCAwMCB8CgovLyBSZXNlcnZlZCBzbG90cwovLyAweDAwIC0gMHgzZiAoNjQgYnl0ZXMpOiBzY3JhdGNoIHNwYWNlIGZvciBoYXNoaW5nIG1ldGhvZHMKLy8g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AwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAogICAgICAgIH0KICAgIH0KfQoKY29udHJhY3QgTWVtU3RydWN0IHsKICAgIC8vIE1lbW9yeSBkYXRhIGlzIG5vdCBwYWNrZWQgLSBhbGwgZGF0YSBzdG9yZWQgaW4gY2h1bmtzIG9mIDMyIGJ5dGVzCiAgICBzdHJ1Y3QgUG9pbnQgewogICAgICAgIHVpbnQyNTYgeDsKICAgICAgICB1aW50MzIgeTsKICAgICAgICB1aW50MzIgejsKICAgIH0KCiAgICBmdW5jdGlvbiB0ZXN0X3JlYWQoKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zICh1aW50MjU2IHgsIHVpbnQyNTYgeSwgdWludDI1NiB6KQogICAgewogICAgICAgIC8vIFBvaW50IGlzIGxvYWRlZCB0byBtZW1vcnkgc3RhcnRpbmcgYXQgMHg4MAogICAgICAgIC8vIDB4ODAgPSBpbml0aWFsIGZyZWUgbWVtb3J5CiAgICAgICAgUG9pbnQgbWVtb3J5IHAgPSBQb2ludCgxLCAyLCAzKTsKCiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICAvLyBsb2FkIDMyIGJ5dGVzIHN0YXJ0aW5nIGZyb20gMHg4MAogICAgICAgICAgICB4IDo9IG1sb2FkKDB4ODApCiAgICAgICAgICAgIC8vIGxvYWQgMzIgYnl0ZXMgc3RhcnRpbmcgZnJvbSAweGEwICgweDgwICsgMzIgPSAweGEwKQogICAgICAgICAgICB5IDo9IG1sb2FkKDB4YTApCiAgICAgICAgICAgIC8vIGxvYWQgMzIgYnl0ZXMgc3RhcnRpbmcgZnJvbSAweGMwICgweGEwICsgMzIgPSAweGMwKQogICAgICAgICAgICB6IDo9IG1sb2FkKDB4YzApCiAgICAgICAgfQogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3Rfd3JpdGUoKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zIChieXRlczMyIGZyZWVfbWVtX3B0ciwgdWludDI1NiB4LCB1aW50MjU2IHksIHVpbnQyNTYgeikKICAgIHsKICAgICAgICAvLyBBbGxvY2F0ZXMgbWVtb3J5IDB4ODAgdG8gMHhkZiB0byBQb2ludAogICAgICAgIC8vIEZyZWUgbWVtb3J5IHBvaW50ZXIgPSAweGRmICsgMSA9IDB4ZTAKICAgICAgICBQb2ludCBtZW1vcnkgcDsKCiAgICAgICAgLy8gV3JpdGUKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIC8vIHN0b3JlIHRvIDB4ODAKICAgICAgICAgICAgbXN0b3JlKHAsIDExKQogICAgICAgICAgICAvLyBzdG9yZSB0byAweGEwCiAgICAgICAgICAgIG1zdG9yZShhZGQocCwgMHgyMCksIDIyKQogICAgICAgICAgICAvLyBzdG9yZSB0byAweGMwCiAgICAgICAgICAgIG1zdG9yZShhZGQocCwgMHg0MCksIDMzKQogICAgICAgICAgICAvLyAweGUwCiAgICAgICAgICAgIGZyZWVfbWVtX3B0ciA6PSBtbG9hZCgweDQwKQogICAgICAgIH0KCiAgICAgICAgeCA9IHAueDsKICAgICAgICB5ID0gcC55OwogICAgICAgIHogPSBwLno7CiAgICB9Cn0KCmNvbnRyYWN0IE1lbUZpeGVkQXJyYXkgewogICAgZnVuY3Rpb24gdGVzdF9yZWFkKCkKICAgICAgICBwdWJsaWMKICAgICAgICBwdXJlCiAgICAgICAgcmV0dXJucyAodWludDI1NiBhMCwgdWludDI1NiBhMSwgdWludDI1NiBhMikKICAgIHsKICAgICAgICAvLyBhcnIgaXMgbG9hZGVkIHRvIG1lbW9yeSBzdGFydGluZyBhdCAweDgwCiAgICAgICAgLy8gRWFjaCBhcnJheSBlbGVtZW50IGlzIHN0b3JlZCBhcyAzMiBieXRlcwogICAgICAgIHVpbnQzMlszXSBtZW1vcnkgYXJyID0gW3VpbnQzMigxKSwgdWludDMyKDIpLCB1aW50MzIoMyldOwoKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIGEwIDo9IG1sb2FkKDB4ODApCiAgICAgICAgICAgIGExIDo9IG1sb2FkKDB4YTApCiAgICAgICAgICAgIGEyIDo9IG1sb2FkKDB4YzApCiAgICAgICAgfQogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3Rfd3JpdGUoKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zICh1aW50MjU2IGEwLCB1aW50MjU2IGExLCB1aW50MjU2IGEyKQogICAgewogICAgICAgIHVpbnQzMlszXSBtZW1vcnkgYXJyOwoKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIC8vIDB4ODAKICAgICAgICAgICAgbXN0b3JlKGFyciwgMTEpCiAgICAgICAgICAgIC8vIDB4YTAKICAgICAgICAgICAgbXN0b3JlKGFkZChhcnIsIDB4MjApLCAyMikKICAgICAgICAgICAgLy8gMHhjMAogICAgICAgICAgICBtc3RvcmUoYWRkKGFyciwgMHg0MCksIDMzKQogICAgICAgIH0KCiAgICAgICAgYTAgPSBhcnJbMF07CiAgICAgICAgYTEgPSBhcnJbMV07CiAgICAgICAgYTIgPSBhcnJbMl07CiAgICB9Cn0KCmNvbnRyYWN0IE1lbUR5bmFtaWNBcnJheSB7CiAgICBmdW5jdGlvbiB0ZXN0X3JlYWQoKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zIChieXRlczMyIHAsIHVpbnQyNTYgbGVuLCB1aW50MjU2IGEwLCB1aW50MjU2IGExLCB1aW50MjU2IGEyKQogICAgewogICAgICAgIHVpbnQyNTZbXSBtZW1vcnkgYXJyID0gbmV3IHVpbnQyNTZbXSg1KTsKICAgICAgICBhcnJbMF0gPSB1aW50MjU2KDExKTsKICAgICAgICBhcnJbMV0gPSB1aW50MjU2KDIyKTsKICAgICAgICBhcnJbMl0gPSB1aW50MjU2KDMzKTsKICAgICAgICBhcnJbM10gPSB1aW50MjU2KDQ0KTsKICAgICAgICBhcnJbNF0gPSB1aW50MjU2KDU1KTsKCiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBwIDo9IGFycgogICAgICAgICAgICAvLyAweDgwCiAgICAgICAgICAgIGxlbiA6PSBtbG9hZChhcnIpCiAgICAgICAgICAgIC8vIDB4YTAKICAgICAgICAgICAgYTAgOj0gbWxvYWQoYWRkKGFyciwgMHgyMCkpCiAgICAgICAgICAgIC8vIDB4YzAKICAgICAgICAgICAgYTEgOj0gbWxvYWQoYWRkKGFyciwgMHg0MCkpCiAgICAgICAgICAgIC8vIDB4ZTAKICAgICAgICAgICAgYTIgOj0gbWxvYWQoYWRkKGFyciwgMHg2MCkpCiAgICAgICAgfQogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3Rfd3JpdGUoKSBwdWJsaWMgcHVyZSByZXR1cm5zIChieXRlczMyIHAsIHVpbnQyNTZbXSBtZW1vcnkpIHsKICAgICAgICB1aW50MjU2W10gbWVtb3J5IGFyciA9IG5ldyB1aW50MjU2W10oMCk7CgogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgcCA6PSBhcnIKICAgICAgICAgICAgLy8gU3RvcmUgbGVuZ3RoIG9mIGFycgogICAgICAgICAgICBtc3RvcmUoYXJyLCAzKQogICAgICAgICAgICAvLyBTdG9yZSAxLCAyLCAzCiAgICAgICAgICAgIG1zdG9yZShhZGQoYXJyLCAweDIwKSwgMTEpCiAgICAgICAgICAgIG1zdG9yZShhZGQoYXJyLCAweDQwKSwgMjIpCiAgICAgICAgICAgIG1zdG9yZShhZGQoYXJyLCAweDYwKSwgMzMpCiAgICAgICAgICAgIC8vIFVwZGF0ZSBmcmVlIG1lbW9yeSBwb2ludGVyCiAgICAgICAgICAgIG1zdG9yZSgweDQwLCBhZGQoYXJyLCAweDgwKSkKICAgICAgICB9CgogICAgICAgIC8vIERhdGEgd2lsbCBiZSBBQkkgZW5jb2RlZCB3aGVuIGFyciBpcyByZXR1cm5lZCB0byBjYWxsZXIKICAgICAgICByZXR1cm4gKHAsIGFycik7CiAgICB9Cn0KCmNvbnRyYWN0IE1lbUludGVybmFsRnVuY1JldHVybiB7CiAgICBmdW5jdGlvbiBpbnRlcm5hbF9mdW5jX3JldHVybl92YWwoKSBwcml2YXRlIHB1cmUgcmV0dXJucyAodWludDI1NikgewogICAgICAgIHJldHVybiB1aW50MjU2KDB4YWJhYmFiKTsKICAgIH0KCiAgICBmdW5jdGlvbiB0ZXN0X3ZhbCgpIHB1YmxpYyBwdXJlIHsKICAgICAgICAvLyAweGFiYWJhYiB3aWxsIGJlIHN0b3JlZCBpbiB0b3Agb2YgdGhlIHN0YWNrCiAgICAgICAgaW50ZXJuYWxfZnVuY19yZXR1cm5fdmFsKCk7CiAgICB9CgogICAgZnVuY3Rpb24gaW50ZXJuYWxfZnVuY19yZXR1cm5fbWVtKCkKICAgICAgICBwcml2YXRlCiAgICAgICAgcHVyZQogICAgICAgIHJldHVybnMgKGJ5dGVzMzJbXSBtZW1vcnkpCiAgICB7CiAgICAgICAgYnl0ZXMzMltdIG1lbW9yeSBhcnIgPSBuZXcgYnl0ZXMzMltdKDMpOwogICAgICAgIGFyclswXSA9IGJ5dGVzMzIodWludDI1NigweGFhYSkpOwogICAgICAgIGFyclsxXSA9IGJ5dGVzMzIodWludDI1NigweGJiYikpOwogICAgICAgIGFyclsyXSA9IGJ5dGVzMzIodWludDI1NigweGNjYykpOwogICAgICAgIHJldHVybiBhcnI7CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9tZW0oKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zICh1aW50MjU2IGxlbiwgYnl0ZXMzMiBhMCwgYnl0ZXMzMiBhMSwgYnl0ZXMzMiBhMikKICAgIHsKICAgICAgICAvLyBTdG9yZXMgMHg4MCB0byB0b3Agb2YgdGhlIHN0YWNrCiAgICAgICAgLy8gMHg4MCA9IG1lbW9yeSBwb2ludGVyIHRvIGJlZ2lubmluZyBvZiBhcnIKICAgICAgICBpbnRlcm5hbF9m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MpOwogICAgICAgIGFyclswXSA9IFBvaW50KDEsIDIsIDMpOwogICAgICAgIGFyclsxXSA9IFBvaW50KDQsIDUsIDYpOwogICAgICAgIGFyclsyXSA9IFBvaW50KDcsIDgsIDkpOwogICAgICAgIHJldHVybiBhYmkuZW5jb2RlKGFycik7CiAgICB9Cn0KCmNvbnRyYWN0IE1lbVJldHVybiB7CiAgICBmdW5jdGlvbiB0ZXN0X3JldHVybl92YWxzKCkgcHVibGljIHB1cmUgcmV0dXJucyAodWludDI1NiwgdWludDI1NikgewogICAgICAgIC8vIHJldHVybihzdGFydCwgbGVuKSAtIEhhbHQgZXhlY3V0aW9uIGFuZCByZXR1cm4gZGF0YSBzdG9yZWQgaW4gbWVtb3J5IGZyb20gc3RhcnQgdG8gc3RhcnQgKyBsZW4KICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIG1zdG9yZSgweDgwLCAxMSkKICAgICAgICAgICAgbXN0b3JlKDB4YTAsIDIyKQogICAgICAgICAgICByZXR1cm4oMHg4MCwgMHg0MCkKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9yZXR1cm5fZHluX2FycigpIHB1YmxpYyBwdXJlIHJldHVybnMgKHVpbnQyNTZbXSBtZW1vcnkpIHsKICAgICAgICAvLyBBQkkgZW5jb2RlIHVpbnQyNTZbXSBhcnJheSB3aXRoIDMgZWxlbWVudHMgMTEsIDIyIGFuZCAzMwogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgLy8gb2Zmc2V0CiAgICAgICAgICAgIG1zdG9yZSgweDgwLCAweDIwKQogICAgICAgICAgICAvLyBsZW5ndGgKICAgICAgICAgICAgbXN0b3JlKGFkZCgweDgwLCAweDIwKSwgMykKICAgICAgICAgICAgLy8gYXJyYXkgZWxlbWVudHMKICAgICAgICAgICAgbXN0b3JlKGFkZCgweDgwLCAweDQwKSwgMTEpCiAgICAgICAgICAgIG1zdG9yZShhZGQoMHg4MCwgMHg2MCksIDIyKQogICAg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QogICAgICAgICAgICBtc3RvcmUoMHhhMCwgMikKCiAgICAgICAgICAgIGxldCBoIDo9IGtlY2NhazI1NigweDgwLCAweDQwKQogICAgICAgICAgICBtc3RvcmUoMHhjMCwgaCkKCiAgICAgICAgICAgIHJldHVybigweGMwLCAweDIwKQogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiBrZWNjYWsoKSBwdWJsaWMgcHVyZSByZXR1cm5zIChieXRlczMyKSB7CiAgICAgICAgcmV0dXJuIGtlY2NhazI1NihhYmkuZW5jb2RlUGFja2VkKHVpbnQyNTYoMSksIHVpbnQyNTYoMikpKTsKICAgIH0KfQoKY29udHJhY3QgVGFyZ2V0IHsKICAgIGZ1bmN0aW9uIHJldHVybl91aW50MjU2KHVpbnQyNTYgeCkgcHVibGljIHB1cmUgcmV0dXJucyAodWludDI1NikgewogICAgICAgIHJldHVybiB4OwogICAgfQoKICAgIGZ1bmN0aW9uIHJldHVybl9ieXRlcyh1aW50MjU2IG4pIHB1YmxpYyBwdXJlIHJldHVybnMgKGJ5dGVzIG1lbW9yeSkgewogICAgICAgIGJ5dGVzIG1lbW9yeSBvdXQgPSBuZXcgYnl0ZXMobik7CiAgICAgICAgZm9yICh1aW50MjU2IGk7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgb3V0W2ldID0gMHhhYjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG91dDsKICAgIH0KCiAgICBmdW5jdGlvbiByZXR1cm5fdWludDI1Nl9hcnIodWludDI1NiBuKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zICh1aW50MjU2W10gbWVtb3J5KQogICAgewogICAgICAgIHVpbnQyNTZbXSBtZW1vcnkgb3V0ID0gbmV3IHVpbnQyNTZbXShuKTsKICAgICAgICBmb3IgKHVpbnQyNTYgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgb3V0W2ldID0gaSArIDE7CiAgICAgICAgfQogICAgICAgIHJldHVyb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MjUxCi8vICAgICAgMTgwIHwgICAxMzE4Ci8vICAgICAgMTkwIHwgICAxMzg2Ci8vICAgICAgMjAwIHwgICAxNDU0CgovLyAgICAgMTAwMCB8ICAgODE0NAovLyAgICAgMjAwMCB8ICAyMDAyMwovLyAgICAgMzAwMCB8ICAzNTgwOAovLyAgICAgNDAwMCB8ICA1NTUwMAovLyAgICAgNTAwMCB8ICA3OTA5NwovLyAgICAgNjAwMCB8IDEwNjYwMQovLyAgICAgNzAwMCB8IDEzODAxMQovLyAgICAgODAwMCB8IDE3MzMyOAovLyAgICAgOTAwMCB8IDIxMjU1MAovLyAgICAxMDAwMCB8IDI1NTY3OQovLyAgICAxMTAwMCB8IDMwMjcxNQovLyAgICAxMjAwMCB8IDM1MzY1NgovLyAgICAxMzAwMCB8IDQwODUwNAovLyAgICAxNDAwMCB8IDQ2NzI1NwovLyAgICAxNTAwMCB8IDUyOTkxOAovLyAgICAxNjAwMCB8IDU5NjQ4NAovLyAgICAxNzAwMCB8IDY2Njk1NwovLyAgICAxODAwMCB8IDc0MTMzNgovLyAgICAxOTAwMCB8IDgxOTYyMQovLyAgICAyMDAwMCB8IDkwMTgxMgo="}],Yk=`Examples of
assembly
Examples of
+`,Xk=({prev:s,next:a})=>i.jsx(A,{version:Wk,title:Bk,description:Gk,cyfrinLink:fk,html:Yk,prev:s,next:a,codes:Vk}),vk="0.8.26",Rk="EVM Storage",Nk="Example of EVM storage in Solidity",Hk="",Fk=[{fileName:"EVMStorage.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8vIFl1bCAtIGxhbmd1YWdlIHVzZWQgZm9yIFNvbGlkaXR5IGlubGluZSBhc3NlbWJseQpjb250cmFjdCBZdWxJbnRybyB7CiAgICAvLyBZdWwgYXNzaWdubWVudAogICAgZnVuY3Rpb24gdGVzdF95dWxfdmFyKCkgcHVibGljIHB1cmUgcmV0dXJucyAodWludDI1NikgewogICAgICAgIHVpbnQyNTYgcyA9IDA7CgogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgLy8gRGVjbGFyZSB2YXJpYWJsZQogICAgICAgICAgICBsZXQgeCA6PSAxCiAgICAgICAgICAgIC8vIFJlYXNzaWduCiAgICAgICAgICAgIHggOj0gMgogICAgICAgICAgICAvLyBBc3NpZ24gdG8gU29saWRpdHkgdmFyaWFibGUKICAgICAgICAgICAgcyA6PSAyCiAgICAgICAgfQoKICAgICAgICByZXR1cm4gczsKICAgIH0KCiAgICAvLyBZdWwgdHlwZXMgKGV2ZXJ5dGhpbmcgaXMgYnl0ZXMzMikKICAgIGZ1bmN0aW9uIHRlc3RfeXVsX3R5cGVzKCkKICAgICAgICBwdWJsaWMKICAgICAgICBwdXJlCiAgICAgICAgcmV0dXJucyAoYm9vbCB4LCB1aW50MjU2IHksIGJ5dGVzMzIgeikKICAgIHsKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIHggOj0gMQogICAgICAgICAgICB5IDo9IDB4YWFhCiAgICAgICAgICAgIHogOj0gIkhlbGxvIFl1bCIKICAgICAgICB9CgogICAgICAgIHJldHVybiAoeCwgeSwgeik7CiAgICB9Cn0KCmNvbnRyYWN0IEVWTVN0b3JhZ2VTaW5nbGVTbG90IHsKICAgIC8vIEVWTSBzdG9yYWdlCiAgICAvLyAyKioyNTYgc2xvdHMsIGVhY2ggc2xvdCBjYW4gc3RvcmUgdXAgdG8gMzIgYnl0ZXMKICAgIC8vIFNsb3RzIGFyZSBhc3NpZ25lZCBpbiB0aGUgb3JkZXIgdGhlIHN0YXRlIHZhcmlhYmxlcyBhcmUgZGVjbGFyZWQKICAgIC8vIERhdGEgPCAzMiBieXRlcyBhcmUgcGFja2VkIGludG8gYSBzbG90IChyaWdodCB0byBsZWZ0KQogICAgLy8gc3N0b3JlKGssIHYpID0gc3RvcmUgdiB0byBzbG90IGsKICAgIC8vIHNsb2FkKGspID0gbG9hZCAzMiBieXRlcyBmcm9tIHNsb3QgawoKICAgIC8vIFNpbmdsZSB2YXJpYWJsZSBzdG9yZWQgaW4gb25lIHNsb3QKICAgIC8vIHNsb3QgMAogICAgdWludDI1NiBwdWJsaWMgc194OwogICAgLy8gc2xvdCAxCiAgICB1aW50MjU2IHB1YmxpYyBzX3k7CiAgICAvLyBzbG90IDIKICAgIGJ5dGVzMzIgcHVibGljIHNfejsKCiAgICBmdW5jdGlvbiB0ZXN0X3NzdG9yZSgpIHB1YmxpYyB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBzc3RvcmUoMCwgMTExKQogICAgICAgICAgICBzc3RvcmUoMSwgMjIyKQogICAgICAgICAgICBzc3RvcmUoMiwgMHhhYmFiYWIpCiAgICAgICAgfQogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3Rfc3N0b3JlX2FnYWluKCkgcHVibGljIHsKICAgICAgICAvLyBBY2Nlc3Mgc2xvdCB1c2luZyAuc2xvdAogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgc3N0b3JlKHNfeC5zbG90LCAxMjMpCiAgICAgICAgICAgIHNzdG9yZShzX3kuc2xvdCwgNDU2KQogICAgICAgICAgICBzc3RvcmUoc196LnNsb3QsIDB4Y2RjZGNkKQogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiB0ZXN0X3Nsb2FkKCkKICAgICAgICBwdWJsaWMKICAgICAgICB2aWV3CiAgICAgICAgcmV0dXJucyAodWludDI1NiB4LCB1aW50MjU2IHksIGJ5dGVzMzIgeikKICAgIHsKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIHggOj0gc2xvYWQoMCkKICAgICAgICAgICAgeSA6PSBzbG9hZCgxKQogICAgICAgICAgICB6IDo9IHNsb2FkKDIpCiAgICAgICAgfQoKICAgICAgICByZXR1cm4gKHgsIHksIHopOwogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3Rfc2xvYWRfYWdhaW4oKQogICAgICAgIHB1YmxpYwogICAgICAgIHZpZXcKICAgICAgICByZXR1cm5zICh1aW50MjU2IHgsIHVpbnQyNTYgeSwgYnl0ZXMzMiB6KQogICAgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgeCA6PSBzbG9hZChzX3guc2xvdCkKICAgICAgICAgICAgeSA6PSBzbG9hZChzX3kuc2xvdCkKICAgICAgICAgICAgeiA6PSBzbG9hZChzX3ouc2xvdCkKICAgICAgICB9CgogICAgICAgIHJldHVybiAoeCwgeSwgeik7CiAgICB9Cn0KCmNvbnRyYWN0IEVWTVN0b3JhdGVQYWNrZWRTbG90Qnl0ZXMgewogICAgLy8gc2xvdCAwIChwYWNrZWQgcmlnaHQgdG8gbGVmdCkKICAgIGJ5dGVzNCBwdWJsaWMgYjQgPSAweGFiYWJhYmFiOwogICAgYnl0ZXMyIHB1YmxpYyBiMiA9IDB4Y2RjZDsKCiAgICBmdW5jdGlvbiBnZXQoKSBwdWJsaWMgdmlldyByZXR1cm5zIChieXRlczMyIGIzMikgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgYjMyIDo9IHNsb2FkKDApCiAgICAgICAgfQogICAgfQp9Cgpjb250cmFjdCBCaXRNYXNraW5nIHsKICAgIGZ1bmN0aW9uIHRlc3RfbWFzaygpIHB1YmxpYyBwdXJlIHJldHVybnMgKGJ5dGVzMzIgbWFzaykgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgLy8gfCAgICAgICAyNTYgYml0cyAgICAgICAgfAogICAgICAgICAgICAvLyAwMDAgLi4uIDAwMCB8IDExMSAuLi4gMTExCiAgICAgICAgICAgIC8vICAgICAgICAgICAgIHwgMTYgYml0cwogICAgICAgICAgICAvLyAweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMGZmZmYKICAgICAgICAgICAgbWFzayA6PSBzdWIoc2hsKDE2LCAxKSwgMSkKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9zaGlmdF9tYXNrKCkgcHVibGljIHB1cmUgcmV0dXJucyAoYnl0ZXMzMiBtYXNrKSB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICAvLyB8ICAgICAgICAgICAgICAgMjU2IGJpdHMgICAgICAgICAgICAgICAgfAogICAgICAgICAgICAvLyAwMDAgLi4uIDAwMCB8IDExMSAuLi4gMTExIHwgMDAwIC4uLiAwMDAgfAogICAgICAgICAgICAvLyAgICAgICAgICAgICB8IDE2IGJpdHMgICAgIHwgMzIgYml0cwogICAgICAgICAgICAvLyAweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDBmZmZmMDAwMDAwMDAKICAgICAgICAgICAgbWFzayA6PSBzaGwoMzIsIHN1YihzaGwoMTYsIDEpLCAxKSkKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9ub3RfbWFzaygpIHB1YmxpYyBwdXJlIHJldHVybnMgKGJ5dGVzMzIgbWFzaykgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgLy8gfCAgICAgICAgICAgICAgIDI1NiBiaXRzICAgICAgICAgICAgICAgIHwKICAgICAgICAgICAgLy8gMTExIC4uLiAxMTEgfCAwMDAgLi4uIDAwMCB8IDExMSAuLi4gMTExIHwKICAgICAgICAgICAgLy8gICAgICAgICAgICAgfCAxNiBiaXRzICAgICB8IDMyIGJpdHMKICAgICAgICAgICAgLy8gMHhmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmMDAwMGZmZmZmZmZmCiAgICAgICAgICAgIG1hc2sgOj0gbm90KHNobCgzMiwgc3ViKHNobCgxNiwgMSksIDEpKSkKICAgICAgICB9CiAgICB9Cn0KCmNvbnRyYWN0IEVWTVN0b3JhZ2VQYWNrZWRTbG90IHsKICAgIC8vIERhdGEgPCAzMiBieXRlcyBhcmUgcGFja2VkIGludG8gYSBzbG90CiAgICAvLyBCaXQgbWFza2luZyAoaG93IHRvIGNyZWF0ZSAxMTEuLi4xMTEpCiAgICAvLyBzbG90LCBvZmZzZXQKCiAgICAvLyBzbG90IDAKICAgIHVpbnQxMjggcHVibGljIHNfYTsKICAgIHVpbnQ2NCBwdWJsaWMgc19iOwogICAgdWludDMyIHB1YmxpYyBzX2M7CiAgICB1aW50MzIgcHVibGljIHNfZDsKICAgIC8vIHNsb3QgMQogICAgLy8gMjAgYnl0ZXMgPSAxNjAgYml0cwogICAgYWRkcmVzcyBwdWJsaWMgc19hZGRyOwogICAgLy8gOTYgYml0cwogICAgdWludDY0IHB1YmxpYyBzX3g7CiAgICB1aW50MzIgcHVibGljIHNfeTsKCiAgICBmdW5jdGlvbiB0ZXN0X3NzdG9yZSgpIHB1YmxpYyB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICAvLyBMb2FkIDMyIGJ5dGVzIGZyb20gc2xvdDAKICAgICAgICAgICAgbGV0IHYgOj0gc2xvYWQoMCkKCiAgICAgICAgICAgIC8vIHNfZCB8IHNfYyB8IHNfYiB8IHNfYQogICAgICAgICAgICAvLyAzMiAgfCAzMiAgfCA2NCAgfCAxMjggYml0cwoKICAgICAgICAgICAgLy8gU2V0IHNfYSA9IDExCiAgICAgICAgICAgIC8vIG1hc2sgPSBhbGwgMXMgYXQgYW5kIHRvIHRoZSBsZWZ0IG9mIDEyOCBiaXQgY291bnRpbmcgZnJvbSByaWdodAogICAgICAgICAgICAvLyAgICAgICAgMTExIC4uLiAxMTEgfCAwMDAgLi4uIDAwMAogICAgICAgICAgICAvLyAgICAgICAgICAgICAgICAgICAgfCAgICAxMjggYml0cwogICAgICAgICAgICBsZXQgbWFza19hIDo9IG5vdChzdWIoc2hsKDEyOCwgMSksIDEpKQogICAgICAgICAgICAvLyBTZXQgbGVmdCBtb3N0IDEyOCBiaXRzIHRvIDAKICAgICAgICAgICAgdiA6PSBhbmQodiwgbWFza19hKQogICAgICAgICAgICAvLyBTZXQgc19hID0gMTEKICAgICAgICAgICAgdiA6PSBvcih2LCAxMSkKCiAgICAgICAgICAgIC8vIFNldCBzX2IgPSAyMgogICAgICAgICAgICAvLyBtYXNrID0gMTExLi4uMTExIHwgMDAwIC4uLiAwMDAgfCAxMTEgLi4uIDExMQogICAgICAgICAgICAvLyAgICAgICAgICAgICAgICAgIHwgICAgIDY0IGJpdHMgfCAgICAxMjggYml0cwogICAgICAgICAgICBsZXQgbWFza19iIDo9IG5vdChzaGwoMTI4LCBzdWIoc2hsKDY0LCAxKSwgMSkpKQogICAgICAgICAgICAvLyBDbGVhciBwcmV2aW91cyB2YWx1ZSBvZiBzX2IgYnkgc2V0dGluZyBiaXRzICgxMjggdG8gMTkxIGJpdHMpIHRvIDAKICAgICAgICAgICAgdiA6PSBhbmQodiwgbWFza19iKQogICAgICAgICAgICB2IDo9IG9yKHYsIHNobCgxMjgsIDIyKSkKCiAgICAgICAgICAgIC8vIFNldCBzX2MgPSAzMwogICAgICAgICAgICAvLyBtYXNrID0gMTExLi4uMTExIHwgMDAwLi4uMDAwIHwgMTExIC4uLiAxMTEgfCAxMTEgLi4uIDExMQogICAgICAgICAgICAvLyAgICAgICAgICAgICAgICAgIHwgICAzMiBiaXRzIHwgICAgIDY0IGJpdHMgfCAgICAxMjggYml0cwogICAgICAgICAgICBsZXQgbWFza19jIDo9IG5vdChzaGwoMTkyLCBzdWIoc2hsKDMyLCAxKSwgMSkpKQogICAgICAgICAgICAvLyBDbGVhciBwcmV2aW91cyB2YWx1ZSBvZiBzX2MgYnkgc2V0dGluZyBiaXRzICgxOTIgdG8gMjIzIGJpdHMpIHRvIDAKICAgICAgICAgICAgdiA6PSBhbmQodiwgbWFza19jKQogICAgICAgICAgICB2IDo9IG9yKHYsIHNobCgxOTIsIDMzKSkKCiAgICAgICAgICAgIC8vIFNldCBzX2QgPSA0NAogICAgICAgICAgICAvLyBtYXNrID0gMDAwLi4uMDAwIHwgMTExLi4uMTExIHwgMTExIC4uLiAxMTEgfCAxMTEgLi4uIDExMQogICAgICAgICAgICAvLyAgICAgICAgICAgICAgICAgIHwgICAzMiBiaXRzIHwgICAgIDY0IGJpdHMgfCAgICAxMjggYml0cwogICAgICAgICAgICBsZXQgbWFza19kIDo9IG5vdChzaGwoMjI0LCBzdWIoc2hsKDMyLCAxKSwgMSkpKQogICAgICAgICAgICAvLyBDbGVhciBwcmV2aW91cyB2YWx1ZSBvZiBzX2QgYnkgc2V0dGluZyBiaXRzICgyMjQgdG8gMjU1IGJpdHMpIHRvIDAKICAgICAgICAgICAgdiA6PSBhbmQodiwgbWFza19kKQogICAgICAgICAgICB2IDo9IG9yKHYsIHNobCgyMjQsIDQ0KSkKCiAgICAgICAgICAgIC8vIFN0b3JlIG5ldyB2YWx1ZSB0byBzbG90MAogICAgICAgICAgICBzc3RvcmUoMCwgdikKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9zbG90XzBfb2Zmc2V0KCkKICAgICAgICBwdWJsaWMKICAgICAgICBwdXJlCiAgICAgICAgcmV0dXJucyAoCiAgICAgICAgICAgIHVpbnQyNTYgYV9vZmZzZXQsCiAgICAgICAgICAgIHVpbnQyNTYgYl9vZmZzZXQsCiAgICAgICAgICAgIHVpbnQyNTYgY19vZmZzZXQsCiAgICAgICAgICAgIHVpbnQyNTYgZF9vZmZzZXQKICAgICAgICApCiAgICB7CiAgICAgICAgLy8gYV9vZmZzZXQgPSAgMCA9ICAwICogOCA9ICAgMCBiaXRzCiAgICAgICAgLy8gYl9vZmZzZXQgPSAxNiA9IDE2ICogOCA9IDEyOCBiaXRzCiAgICAgICAgLy8gY19vZmZzZXQgPSAyNCA9IDI0ICogOCA9IDE5MiBiaXRzCiAgICAgICAgLy8gZF9vZmZzZXQgPSAyOCA9IDI4ICogOCA9IDIyNCBiaXRzCiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBhX29mZnNldCA6PSBzX2Eub2Zmc2V0CiAgICAgICAgICAgIGJfb2Zmc2V0IDo9IHNfYi5vZmZzZXQKICAgICAgICAgICAgY19vZmZzZXQgOj0gc19jLm9mZnNldAogICAgICAgICAgICBkX29mZnNldCA6PSBzX2Qub2Zmc2V0CiAgICAgICAgfQogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3Rfc2xvdF8xX29mZnNldCgpCiAgICAgICAgcHVibGljCiAgICAgICAgcHVyZQogICAgICAgIHJldHVybnMgKHVpbnQyNTYgYWRkcl9vZmZzZXQsIHVpbnQyNTYgeF9vZmZzZXQsIHVpbnQyNTYgeV9vZmZzZXQpCiAgICB7CiAgICAgICAgLy8gYWRkcl9vZmZzZXQgPSAwCiAgICAgICAgLy8geF9vZmZzZXQgPSAyMAogICAgICAgIC8vIHlfb2Zmc2V0ID0gMjgKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIGFkZHJfb2Zmc2V0IDo9IHNfYWRkci5vZmZzZXQKICAgICAgICAgICAgeF9vZmZzZXQgOj0gc194Lm9mZnNldAogICAgICAgICAgICB5X29mZnNldCA6PSBzX3kub2Zmc2V0CiAgICAgICAgfQogICAgfQoKICAgIC8vIHNsb3QgYW5kIG9mZnNldAogICAgZnVuY3Rpb24gdGVzdF9zc3RvcmVfdXNpbmdfb2Zmc2V0KCkgcHVibGljIHsKICAgICAgICAvLyBhX29mZnNldCA9ICAwID0gIDAgKiA4ID0gICAwIGJpdHMKICAgICAgICAvLyBiX29mZnNldCA9IDE2ID0gMTYgKiA4ID0gMTI4IGJpdHMKICAgICAgICAvLyBjX29mZnNldCA9IDI0ID0gMjQgKiA4ID0gMTkyIGJpdHMKICAgICAgICAvLyBkX29mZnNldCA9IDI4ID0gMjggKiA4ID0gMjI0IGJpdHMKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIC8vIExvYWQgMzIgYnl0ZXMgZnJvbSBzbG90MAogICAgICAgICAgICBsZXQgdiA6PSBzbG9hZChzX2Euc2xvdCkKCiAgICAgICAgICAgIC8vIHNfZCB8IHNfYyB8IHNfYiB8IHNfYQogICAgICAgICAgICAvLyAzMiAgfCAzMiAgfCA2NCAgfCAxMjggYml0cwoKICAgICAgICAgICAgLy8gU2V0IHNfYSA9IDExMQogICAgICAgICAgICAvLyBtYXNrID0gYWxsIDFzIGF0IGFuZCB0byB0aGUgbGVmdCBvZiAxMjggYml0IGNvdW50aW5nIGZyb20gcmlnaHQKICAgICAgICAgICAgLy8gICAgICAgIDExMSAuLi4gMTExIHwgMDAwIC4uLiAwMDAKICAgICAgICAgICAgLy8gICAgICAgICAgICAgICAgICAgIHwgICAgMTI4IGJpdHMKICAgICAgICAgICAgbGV0IG1hc2tfYSA6PSBub3Qoc3ViKHNobCgxMjgsIDEpLCAxKSkKICAgICAgICAgICAgLy8gU2V0IGxlZnQgbW9zdCAxMjggYml0cyB0byAwCiAgICAgICAgICAgIHYgOj0gYW5kKHYsIG1hc2tfYSkKICAgICAgICAgICAgLy8gU2V0IHNfYSA9IDEKICAgICAgICAgICAgdiA6PSBvcih2LCAxMTEpCgogICAgICAgICAgICAvLyBTZXQgc19iID0gMjIyCiAgICAgICAgICAgIC8vIG1hc2sgPSAxMTEuLi4xMTEgfCAwMDAgLi4uIDAwMCB8IDExMSAuLi4gMTExCiAgICAgICAgICAgIC8vICAgICAgICAgICAgICAgICAgfCAgICAgNjQgYml0cyB8ICAgIDEyOCBiaXRzCiAgICAgICAgICAgIGxldCBtYXNrX2IgOj0gbm90KHNobChtdWwoc19iLm9mZnNldCwgOCksIHN1YihzaGwoNjQsIDEpLCAxKSkpCiAgICAgICAgICAgIC8vIENsZWFyIHByZXZpb3VzIHZhbHVlIG9mIHNfYiBieSBzZXR0aW5nIGJpdHMgKDEyOCB0byAxOTEgYml0cykgdG8gMAogICAgICAgICAgICB2IDo9IGFuZCh2LCBtYXNrX2IpCiAgICAgICAgICAgIHYgOj0gb3Iodiwgc2hsKG11bChzX2Iub2Zmc2V0LCA4KSwgMjIyKSkKCiAgICAgICAgICAgIC8vIFNldCBzX2MgPSAzMzMKICAgICAgICAgICAgLy8gbWFzayA9IDExMS4uLjExMSB8IDAwMC4uLjAwMCB8IDExMSAuLi4gMTExIHwgMTExIC4uLiAxMTEKICAgICAgICAgICAgLy8gICAgICAgICAgICAgICAgICB8ICAgMzIgYml0cyB8ICAgICA2NCBiaXRzIHwgICAgMTI4IGJpdHMKICAgICAgICAgICAgbGV0IG1hc2tfYyA6PSBub3Qoc2hsKG11bChzX2Mub2Zmc2V0LCA4KSwgc3ViKHNobCgzMiwgMSksIDEpKSkKICAgICAgICAgICAgLy8gQ2xlYXIgcHJldmlvdXMgdmFsdWUgb2Ygc19jIGJ5IHNldHRpbmcgYml0cyAoMTkyIHRvIDIyMyBiaXRzKSB0byAwCiAgICAgICAgICAgIHYgOj0gYW5kKHYsIG1hc2tfYykKICAgICAgICAgICAgdiA6PSBvcih2LCBzaGwobXVsKHNfYy5vZmZzZXQsIDgpLCAzMzMpKQoKICAgICAgICAgICAgLy8gU2V0IHNfZCA9IDQ0NAogICAgICAgICAgICAvLyBtYXNrID0gMDAwLi4uMDAwIHwgMTExLi4uMTExIHwgMTExIC4uLiAxMTEgfCAxMTEgLi4uIDExMQogICAgICAgICAgICAvLyAgICAgICAgICAgICAgICAgIHwgICAzMiBiaXRzIHwgICAgIDY0IGJpdHMgfCAgICAxMjggYml0cwogICAgICAgICAgICBsZXQgbWFza19kIDo9IG5vdChzaGwobXVsKHNfZC5vZmZzZXQsIDgpLCBzdWIoc2hsKDMyLCAxKSwgMSkpKQogICAgICAgICAgICAvLyBDbGVhciBwcmV2aW91cyB2YWx1ZSBvZiBzX2QgYnkgc2V0dGluZyBiaXRzICgyMjQgdG8gMjU1IGJpdHMpIHRvIDAKICAgICAgICAgICAgdiA6PSBhbmQodiwgbWFza19kKQogICAgICAgICAgICB2IDo9IG9yKHYsIHNobChtdWwoc19kLm9mZnNldCwgOCksIDQ0NCkpCgogICAgICAgICAgICAvLyBTdG9yZSBuZXcgdmFsdWUgdG8gc2xvdDAKICAgICAgICAgICAgc3N0b3JlKHNfYS5zbG90LCB2KQogICAgICAgIH0KICAgIH0KfQoKY29udHJhY3QgRVZNU3RvcmFnZVN0cnVjdCB7CiAgICBzdHJ1Y3QgU2luZ2xlU2xvdCB7CiAgICAgICAgdWludDEyOCB4OwogICAgICAgIHVpbnQ2NCB5OwogICAgICAgIHVpbnQ2NCB6OwogICAgfQoKICAgIHN0cnVjdCBNdWx0aXBsZVNsb3RzIHsKICAgICAgICB1aW50MjU2IGE7CiAgICAgICAgdWludDI1NiBiOwogICAgICAgIHVpbnQyNTYgYzsKICAgIH0KCiAgICAvLyBzbG90IDAKICAgIFNpbmdsZVNsb3QgcHVibGljIHNpbmdsZSA9IFNpbmdsZVNsb3Qoe3g6IDEsIHk6IDIsIHo6IDN9KTsKICAgIC8vIHNsb3QgMSwgMiwgMwogICAgTXVsdGlwbGVTbG90cyBwdWJsaWMgbXVsdGkgPSBNdWx0aXBsZVNsb3RzKHthOiAxMSwgYjogMjIsIGM6IDMzfSk7CgogICAgZnVuY3Rpb24gdGVzdF9nZXRfc2luZ2xlX3Nsb3Rfc3RydWN0KCkKICAgICAgICBwdWJsaWMKICAgICAgICB2aWV3CiAgICAgICAgcmV0dXJucyAodWludDEyOCB4LCB1aW50NjQgeSwgdWludDY0IHopCiAgICB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBsZXQgcyA6PSBzbG9hZCgwKQogICAgICAgICAgICAvLyAgeiB8ICB5IHwgeAogICAgICAgICAgICAvLyA2NCB8IDY0IHwgMTI4IGJpdHMKICAgICAgICAgICAgLy8gQ2FzdGluZyBjdXRzIG9mZiBiaXRzIHRvIHRoZSBsZWZ0CiAgICAgICAgICAgIHggOj0gcwogICAgICAgICAgICB5IDo9IHNocigxMjgsIHMpCiAgICAgICAgICAgIHogOj0gc2hyKDE5MiwgcykKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9nZXRfbXVsdGlwbGVfc2xvdHNfc3RydWN0KCkKICAgICAgICBwdWJsaWMKICAgICAgICB2aWV3CiAgICAgICAgcmV0dXJucyAodWludDI1NiBhLCB1aW50MjU2IGIsIHVpbnQyNTYgYykKICAgIHsKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIGEgOj0gc2xvYWQoMSkKICAgICAgICAgICAgYiA6PSBzbG9hZCgyKQogICAgICAgICAgICBjIDo9IHNsb2FkKDMpCiAgICAgICAgfQogICAgfQp9Cgpjb250cmFjdCBFVk1TdG9yYWdlQ29uc3RhbnRzIHsKICAgIC8vIHNsb3QgMAogICAgdWludDI1NiBwdWJsaWMgczAgPSAxOwogICAgLy8gQ29uc3RhbnRzIGFuZCBpbW11dGFibGVzIGRvbid0IHVzZSBzdG9yYWdlCiAgICB1aW50MjU2IHB1YmxpYyBjb25zdGFudCBYID0gMTIzOwogICAgYWRkcmVzcyBwdWJsaWMgaW1tdXRhYmxlIG93bmVyOwogICAgLy8gc2xvdCAxCiAgICB1aW50MjU2IHB1YmxpYyBzMSA9IDI7CgogICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgb3duZXIgPSBtc2cuc2VuZGVyOwogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3RfZ2V0X3Nsb3RzKCkgcHVibGljIHZpZXcgcmV0dXJucyAodWludDI1NiB2MCwgdWludDI1NiB2MSkgewogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgdjAgOj0gc2xvYWQoMCkKICAgICAgICAgICAgdjEgOj0gc2xvYWQoMSkKICAgICAgICB9CiAgICB9Cn0KCmNvbnRyYWN0IEVWTVN0b3JhZ2VGaXhlZEFycmF5IHsKICAgIC8vIEZpeGVkIGFycmF5IHdpdGggZWxlbWVudHMgPSAzMiBieXRlcywgc2xvdCBvZiBlbGVtZW50ID0gc2xvdCB3aGVyZSBhcnJheSBpcyBkZWNsYXJlZCArIGluZGV4IG9mIGFycmF5IGVsZW1lbnQKICAgIC8vIHNsb3RzIDAsIDEsIDIKICAg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AgICAvLyBzbG90IG9mIGFycmF5IGVsZW1lbnQgPSBrZWNjYWsyNTYoc2xvdCkgKyBpbmRleAogICAgLy8gbWFwcGluZyAtPiBhcnJheSAtPiBrZWNjYWsyNTYoa2VjY2FrMjU2KGtleSwgc2xvdCBvZiBtYXAgZGVjbGFyYXRpb24pKSArIGluZGV4CiAgICBtYXBwaW5nKGFkZHJlc3MgPT4gdWludDI1NltdKSBwdWJsaWMgbWFwOwoKICAgIGFkZHJlc3MgcHVibGljIGNvbnN0YW50IEFERFJfMSA9IGFkZHJlc3MoMSk7CiAgICBhZGRyZXNzIHB1YmxpYyBjb25zdGFudCBBRERSXzIgPSBhZGRyZXNzKDIpOwoKICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgIG1hcFtBRERSXzFdLnB1c2goMTEpOwogICAgICAgIG1hcFtBRERSXzFdLnB1c2goMjIpOwogICAgICAgIG1hcFtBRERSXzFdLnB1c2goMzMpOwogICAgICAgIG1hcFtBRERSXzJdLnB1c2goNDQpOwogICAgICAgIG1hcFtBRERSXzJdLnB1c2goNTUpOwogICAgICAgIG1hcFtBRERSXzJdLnB1c2goNjYpOwogICAgfQoKICAgIGZ1bmN0aW9uIHRlc3RfbWFwX2FycihhZGRyZXNzIGFkZHIsIHVpbnQyNTYgaSkKICAgICAgICBwdWJsaWMKICAgICAgICB2aWV3CiAgICAgICAgcmV0dXJucyAodWludDI1NiB2LCB1aW50MjU2IGxlbikKICAgIHsKICAgICAgICB1aW50MjU2IG1hcF9zbG90ID0gMDsKICAgICAgICBieXRlczMyIG1hcF9oYXNoID0ga2VjY2FrMjU2KGFiaS5lbmNvZGUoYWRkciwgbWFwX3Nsb3QpKTsKICAgICAgICBieXRlczMyIGFycl9oYXNoID0ga2VjY2FrMjU2KGFiaS5lbmNvZGUobWFwX2hhc2gpKTsKCiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBsZW4gOj0gc2xvYWQobWFwX2hhc2gpCiAgICAgICAgICAgIHYgOj0gc2xvYWQoYWRkKGFycl9oYXNoLCBpKSkKICAgICAgICB9CiAgICB9Cn0KCmNvbnRyYWN0IEVWTVN0b3JhZ2VEeW5hbWljQXJyYXlTdHJ1Y3QgewogICAgc3RydWN0IFBvaW50IHsKICAgICAgICB1aW50MjU2IHg7CiAgICAgICAgdWludDEyOCB5OwogICAgICAgIHVpbnQxMjggejsKICAgIH0KCiAgICAvLyBzbG90IG9mIGVsZW1lbnQgPSBrZWNjYWsyNTYoc2xvdCB3aGVyZSB0aGlzIGFycmF5IGlzIGRlY2xhcmVkKSArIGluZGV4IG9mIGVsZW1lbnQKICAgIC8vIGtlY2NhazI1NigwKSArIGluZGV4ICogc2l6ZSBvZiBzdHJ1Y3QKICAgIFBvaW50W10gcHJpdmF0ZSBhcnI7CgogICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgYXJyLnB1c2goUG9pbnQoMTEsIDIyLCAzMykpOwogICAgICAgIGFyci5wdXNoKFBvaW50KDQ0LCA1NSwgNjYpKTsKICAgICAgICBhcnIucHVzaChQb2ludCg3NywgODgsIDk5KSk7CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9zdHJ1Y3RfYXJyKHVpbnQyNTYgaSkKICAgICAgICBwdWJsaWMKICAgICAgICB2aWV3CiAgICAgICAgcmV0dXJucyAodWludDI1NiB4LCB1aW50MTI4IHksIHVpbnQxMjggeiwgdWludDI1NiBsZW4pCiAgICB7CiAgICAgICAgdWludDI1NiBzbG90ID0gMDsKICAgICAgICBieXRlczMyIHN0YXJ0ID0ga2VjY2FrMjU2KGFiaS5lbmNvZGUoc2xvdCkpOwoKICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgIGxlbiA6PSBzbG9hZChzbG90KQogICAgICAgICAgICAvLyBzMCA9IGtlY2NhazI1NigwKQogICAgICAgICAgICAvLyBpbmRleCB8IHNsb3QgICAgICAgIHwgdmFsdWVzCiAgICAgICAgICAgIC8vICAgICAwIHwgc2xvdCBzMCArIDAgfCBhcnJbMF0ueAogICAgICAgICAgICAvLyAgICAgMCB8IHNsb3QgczAgKyAxIHwgYXJyWzBdLnogfCBhcnJbMF0ueQogICAgICAgICAgICAvLyAgICAgMSB8IHNsb3QgczAgKyAyIHwgYXJyWzFdLngKICAgICAgICAgICAgLy8gICAgIDEgfCBzbG90IHMwICsgMyB8IGFyclsxXS56IHwgYXJyWzFdLnkKICAgICAgICAgICAgLy8gICAgIDIgfCBzbG90IHMwICsgNCB8IGFyclsyXS54CiAgICAgICAgICAgIC8vICAgICAyIHwgc2xvdCBzMCArIDUgfCBhcnJbMl0ueiB8IGFyclsyXS55CiAgICAgICAgICAgIHggOj0gc2xvYWQoYWRkKHN0YXJ0LCBtdWwoaSwgMikpKQogICAgICAgICAgICBsZXQgenkgOj0gc2xvYWQoYWRkKHN0YXJ0LCBhZGQobXVsKGksIDIpLCAxKSkpCiAgICAgICAgICAgIC8vIHVpbnQxMjggY3V0cyBvZmYgbGVmdCBtb3N0IDEyOCBiaXRzIGZyb20gMzIgYnl0ZXMKICAgICAgICAgICAgeSA6PSB6eQogICAgICAgICAgICB6IDo9IHNocigxMjgsIHp5KQogICAgICAgIH0KICAgIH0KfQo="}],Kk=`Examples of
assembly
Some gas saving techniques.
+`,B0=({prev:s,next:a})=>i.jsx(A,{version:m0,title:b0,description:w0,cyfrinLink:k0,html:W0,prev:s,next:a,codes:Z0}),G0="0.8.26",f0="Gas Saving Techniques",V0="Some gas saving techniques",Y0="https://www.cyfrin.io/glossary/gas-saving-techniques-code-example",X0=[{fileName:"GasGolf.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8vIGdhcyBnb2xmCmNvbnRyYWN0IEdhc0dvbGYgewogICAgLy8gc3RhcnQgLSA1MDkwOCBnYXMKICAgIC8vIHVzZSBjYWxsZGF0YSAtIDQ5MTYzIGdhcwogICAgLy8gbG9hZCBzdGF0ZSB2YXJpYWJsZXMgdG8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1NiBpID0gMDsgaSA8IGxlbjspIHsKICAgICAgICAgICAgdWludDI1NiBudW0gPSBudW1zW2ldOwogICAgICAgICAgICBpZiAobnVtICUgMiA9PSAwICYmIG51bSA8IDk5KSB7CiAgICAgICAgICAgICAgICBfdG90YWwgKz0gbnVtOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHVuY2hlY2tlZCB7CiAgICAgICAgICAgICAgICArK2k7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHRvdGFsID0gX3RvdGFsOwogICAgfQp9Cg=="}],v0=`Some gas saving techniques.
memory
with calldata
All data on a smart contract can be read.
Let's see how we can read private
data. In the process you will learn how Solidity stores state variables.
// SPDX-License-Identifier: MIT
@@ -9750,7 +9802,7 @@ DeployerDeployer -- create2 --> Deployer -- create --> Attack
selfdestruct(payable(address(0)));
}
}
-
`,bZ=({prev:s,next:a})=>i.jsx(A,{version:CZ,title:jZ,description:AZ,cyfrinLink:uZ,html:mZ,prev:s,next:a,codes:yZ}),wZ="0.8.26",kZ="Front Running",ZZ="An example of a Solidity contract vulnerable to front running",WZ="",GZ=[{fileName:"FrontRunning.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8qCkFsaWNlIGNyZWF0ZXMgYSBndWVzc2luZyBnYW1lLgpZb3Ugd2luIDEwIGV0aGVyIGlmIHlvdSBjYW4gZmluZCB0aGUgY29ycmVjdCBzdHJpbmcgdGhhdCBoYXNoZXMgdG8gdGhlIHRhcmdldApoYXNoLiBMZXQncyBzZWUgaG93IHRoaXMgY29udHJhY3QgaXMgdnVsbmVyYWJsZSB0byBmcm9udCBydW5uaW5nLgoqLwoKLyoKMS4gQWxpY2UgZGVwbG95cyBGaW5kVGhpc0hhc2ggd2l0aCAxMCBFdGhlci4KMi4gQm9iIGZpbmRzIHRoZSBjb3JyZWN0IHN0cmluZyB0aGF0IHdpbGwgaGFzaCB0byB0aG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gICAgIGlmICghc2VudCkgewogICAgICAgICAgICB3aW5uZXIgPSBhZGRyZXNzKDApOwogICAgICAgICAgICBlbmRlZCA9IGZhbHNlOwogICAgICAgICAgICByZXZlcnQoIkZhaWxlZCB0byBzZW5kIGV0aGVyLiIpOwogICAgICAgIH0KICAgIH0KfQo="}],BZ=`Transactions take some time before they are mined. An attacker can watch the transaction pool and send a transaction, have it included in a block before the original transaction. This mechanism can be abused to re-order transactions to the attacker's advantage.
@@ -9783,12 +9835,15 @@ before the original. */ contract FindThisHash { - bytes32 public constant hash = 0x564ccaf7594d66b1eaaea24fe01f0585bf52ee70852af4eac0cc4b04711cd0e2; + bytes32 public constant hash = + 0x564ccaf7594d66b1eaaea24fe01f0585bf52ee70852af4eac0cc4b04711cd0e2; constructor() payable {} function solve(string memory solution) public { - require(hash == keccak256(abi.encodePacked(solution)), "Incorrect answer"); + require( + hash == keccak256(abi.encodePacked(solution)), "Incorrect answer" + ); (bool sent,) = msg.sender.call{value: 10 ether}(""); require(sent, "Failed to send Ether"); @@ -9841,7 +9896,8 @@ before the original. } // The hash that is needed to be solved - bytes32 public hash = 0x564ccaf7594d66b1eaaea24fe01f0585bf52ee70852af4eac0cc4b04711cd0e2; + bytes32 public hash = + 0x564ccaf7594d66b1eaaea24fe01f0585bf52ee70852af4eac0cc4b04711cd0e2; // Address of the winner address public winner; @@ -9881,7 +9937,12 @@ before the original. Function to get the commit details. It returns a tuple of (solutionHash, commitTime, revealStatus); Users can get solution only if the game is active and they have committed a solutionHash */ - function getMySolution() public view gameActive returns (bytes32, uint256, bool) { + function getMySolution() + public + view + gameActive + returns (bytes32, uint256, bool) + { Commit storage commit = commits[msg.sender]; require(commit.commitTime != 0, "Not committed yet"); return (commit.solutionHash, commit.commitTime, commit.revealed); @@ -9895,16 +9956,25 @@ before the original. the game is ended and the reward amount is sent to the winner. */ - function revealSolution(string memory _solution, string memory _secret) public gameActive { + function revealSolution(string memory _solution, string memory _secret) + public + gameActive + { Commit storage commit = commits[msg.sender]; require(commit.commitTime != 0, "Not committed yet"); - require(commit.commitTime < block.timestamp, "Cannot reveal in the same block"); + require( + commit.commitTime < block.timestamp, + "Cannot reveal in the same block" + ); require(!commit.revealed, "Already commited and revealed"); - bytes32 solutionHash = keccak256(abi.encodePacked(msg.sender, _solution, _secret)); + bytes32 solutionHash = + keccak256(abi.encodePacked(msg.sender, _solution, _secret)); require(solutionHash == commit.solutionHash, "Hash doesn't match"); - require(keccak256(abi.encodePacked(_solution)) == hash, "Incorrect answer"); + require( + keccak256(abi.encodePacked(_solution)) == hash, "Incorrect answer" + ); winner = msg.sender; ended = true; @@ -9917,7 +9987,7 @@ before the original. } } } -`,fZ=({prev:s,next:a})=>i.jsx(A,{version:wZ,title:kZ,description:ZZ,cyfrinLink:WZ,html:BZ,prev:s,next:a,codes:GZ}),VZ="0.8.26",YZ="Hiding Malicious Code with External Contract",XZ="An example of exploit where malicious code is hidden in an external contract in Solidity",vZ="",RZ=[{fileName:"ExternalContract.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8qCkxldCdzIHNheSBBbGljZSBjYW4gc2VlIHRoZSBjb2RlIG9mIEZvbyBhbmQgQmFyIGJ1dCBub3QgTWFsLgpJdCBpcyBvYnZpb3VzIHRvIEFsaWNlIHRoYXQgRm9vLmNhbGxCYXIoKSBleGVjdXRlcyB0aGUgY29kZSBpbnNpZGUgQmFyLmxvZygpLgpIb3dldmVyIEV2ZSBkZXBsb3lzIEZvbyB3aXRoIHRoZSBhZGRyZXNzIG9mIE1hbCwgc28gdGhhdCBjYWxsaW5nIEZvby5jYWxsQmFyKCkKd2lsbCBhY3R1YWxseSBleGVjdXRlIHRoZSBjb2RlIGF0IE1hbC4KKi8KCi8qCjEuIEV2ZSBkZXBsb3lzIE1hbAoyLiBFdmUgZGVwbG95cyBGb28gd2l0aCB0aGUgYWRkcmVzcyBvZiBNYWwKMy4gQWxp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ific contract, even if the contract at the address is not the one being casted.
This can be exploited to hide malicious code. Let's see how.
@@ -10400,7 +10470,7 @@ Here is how the functions were called locked = false; } } -`,jW=({prev:s,next:a})=>i.jsx(A,{version:iW,title:gW,description:hW,cyfrinLink:IW,html:CW,prev:s,next:a,codes:dW}),AW="0.8.26",uW="Self Destruct",yW="An example of how to delete your smart contract by calling seldestruct in Solidity",mW="",bW=[{fileName:"ForceEther.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8vIFRoZSBnb2FsIG9mIHRoaXMgZ2FtZSBpcyB0byBiZSB0aGUgN3RoIHBsYXllciB0byBkZXBvc2l0IDEgRXRoZXIuCi8vIFBsYXllcnMgY2FuIGRlcG9zaXQgb25seSAxIEV0aGVyIGF0IGEgdGltZS4KLy8gV2lubmVyIHdpbGwgYmUgYWJsZSB0byB3aXRoZHJhdyBhbGwgRXRoZXIuCgovKgoxLiBEZXBsb3kgRXRoZXJHYW1lCjIuIFBsYXllcnMgKHNheSBBbGljZSBhbmQgQm9iKSBkZWNpZGVzIHRvIHBsYXksIGRlcG9zaXRzIDEgRXRoZXIgZWFjaC4KMi4gRGVwbG95IEF0dGFjayB3aXRoIGFkZHJlc3Mgb2YgRXRoZXJHYW1lCjMuIENhbGwgQXR0YWNrLmF0dGFjayBzZW5kaW5nIDUgZXRoZXIuIFRoaXMgd2lsbCBicmVhayB0aGUgZ2FtZQogICBObyBvbmUgY2FuIGJlY29tZSB0aGUgd2lubmVyLgoKV2hhdCBoYXBwZW5lZD8KQXR0YWNrIGZvcmNlZCB0aGUgYmFsYW5jZSBvZiBFdGhlckdhbWUgdG8gZXF1YWwgNyBldGhlci4KTm93IG5vIG9uZSBjYW4gZGVwb3NpdCBhbmQgdGhlIHdpbm5lciBjYW5ub3QgYmUgc2V0LgoqLwoKY29udHJhY3QgRXRoZXJHYW1lIHsKICAgIHVpbnQyNTYgcHVibGljIHRh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lciIpOwogICAgfQp9Cg=="}],wW=`Contracts can be deleted from the blockchain by calling selfdestruct
.
Contracts can be deleted from the blockchain by calling selfdestruct
.
selfdestruct
sends all remaining Ether stored in the contract to a
designated address.
Signing messages off-chain and having a contract that requires that signature before executing +`,kW=({prev:s,next:a})=>i.jsx(A,{version:AW,title:uW,description:yW,cyfrinLink:mW,html:wW,prev:s,next:a,codes:bW}),ZW="0.8.26",WW="Signature Replay",BW="An example of a contract vulnerable to signature replay attack",GW="",fW=[{fileName:"ECDSA.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8vIE9wZW5aZXBwZWxpbiBDb250cmFjdHMgKGxhc3QgdXBkYXRlZCB2NC41LjApICh1dGlscy9jcnlwdG9ncmFwaHkvRUNEU0Euc29sKQoKbGlicmFyeSBFQ0RTQSB7CiAgICBlbnVtIFJlY292ZXJFcnJvciB7CiAgICAgICAgTm9FcnJvciwKICAgICAgICBJbnZhbGlkU2lnbmF0dXJlLAogICAgICAgIEludmFsaWRTaWduYXR1cmVMZW5ndGgsCiAgICAgICAgSW52YWxpZFNpZ25hdHVyZVMsCiAgICAgICAgSW52YWxpZFNpZ25hdHVyZVYKICAgIH0KCiAgICBmdW5jdGlvbiBfdGhyb3dFcnJvcihSZWNvdmVyRXJyb3IgZXJyb3IpIHByaXZhdGUgcHVyZSB7CiAgICAgICAgaWYgKGVycm9yID09IFJlY292ZXJFcnJvci5Ob0Vycm9yKSB7CiAgICAgICAgICAgIHJldHVybjsgLy8gbm8gZXJyb3I6IGRvIG5vdGhpbmcKICAgICAgICB9IGVsc2UgaWYgKGVycm9yID09IFJlY292ZXJFcnJvci5JbnZhbGlkU2lnbmF0dXJlKSB7CiAgICAgICAgICAgIHJldmVydCgiRUNEU0E6IGludmFsaWQgc2lnbmF0dXJlIik7CiAgICAgICAgfSBlbHNlIGlmIChlcnJvciA9PSBSZWNvdmVyRXJyb3IuSW52YWxpZFNpZ25hdHVyZUxlbmd0aCkgewogICAgICAgICAgICByZXZlcnQoIkVDRFNBOiBpbnZhbGlkIHNpZ25hdHVyZSBsZW5ndGgiKTsKICAgICAgICB9IGVsc2UgaWYgKGVycm9yID09IFJlY292ZXJFcnJvci5JbnZhbGlkU2lnbmF0dXJlUykgewogICAgICAgICAgICByZXZlcnQoIkVDRFNBOiBpbnZhbGlkIHNpZ25hdHVyZSAncycgdmFsdWUiKTsKICAgICAgICB9IGVsc2UgaWYgKGVycm9yID09IFJlY292ZXJFcnJvci5JbnZhbGlkU2lnbmF0dXJlVikgewogICAgICAgICAgICByZXZlcnQoIkVDRFNBOiBpbnZhbGlkIHNpZ25hdHVyZSAndicgdmFsdWUiKTsKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gdHJ5UmVjb3ZlcihieXRlczMyIGhhc2gsIGJ5dGVzIG1lbW9yeSBzaWduYXR1cmUpCiAgICAgICAgaW50ZXJuYWwKICAgICAgICBwdXJlCiAgICAgICAgcmV0dXJucyAoYWRkcmVzcywgUmVjb3ZlckVycm9yKQogICAgewogICAgICAgIC8vIENoZWNrIHRoZSBzaWduYXR1cmUgbGVuZ3RoCiAgICAgICAgLy8gLSBjYXNlIDY1OiByLHMsdiBzaWduYXR1cmUgKHN0YW5kYXJkKQogICAgICAgIC8vIC0gY2FzZSA2NDogcix2cyBzaWduYXR1cmUgKGNmIGh0dHBzOi8vZWlwcy5ldGhlcmV1bS5vcmcvRUlQUy9laXAtMjA5OCkgX0F2YWlsYWJsZSBzaW5jZSB2NC4xLl8KICAgICAgICBpZiAoc2lnbmF0dXJlLmxlbmd0aCA9PSA2NSkgewogICAgICAgICAgICBieXRlczMyIHI7CiAgICAgICAgICAgIGJ5dGVzMzIgczsKICAgICAgICAgICAgdWludDggdjsKICAgICAgICAgICAgLy8gZWNyZWNvdmVyIHRha2VzIHRoZSBzaWduYXR1cmUgcGFyYW1ldGVycywgYW5kIHRoZSBvbmx5IHdheSB0byBnZXQgdGhlbQogICAgICAgICAgICAvLyBjdXJyZW50bHkgaXMgdG8gdXNlIGFzc2VtYmx5LgogICAgICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgICAgICByIDo9IG1sb2FkKGFkZChzaWduYXR1cmUsIDB4MjApKQogICAgICAgICAgICAgICAgcyA6PSBtbG9hZChhZGQoc2lnbmF0dXJlLCAweDQwKSkKICAgICAgICAgICAgICAgIHYgOj0gYnl0ZSgwLCBtbG9hZChhZGQoc2lnbmF0dXJlLCAweDYwKSkpCiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHRyeVJlY292ZXIoaGFzaCwgdiwgciwgcyk7CiAgICAgICAgfSBlbHNlIGlmIChzaWduYXR1cmUubGVuZ3RoID09IDY0KSB7CiAgICAgICAgICAgIGJ5dGVzMzIgcjsKICAgICAgICAgICAgYnl0ZXMzMiB2czsKICAgICAgICAgICAgLy8gZWNyZWNvdmVyIHRha2VzIHRoZSBzaWduYXR1cmUgcGFyYW1ldGVycywgYW5kIHRoZSBvbmx5IHdheSB0byBnZXQgdGhlbQogICAgICAgICAgICAvLyBjdXJyZW50bHkgaXMgdG8gdXNlIGFzc2VtYmx5LgogICAgICAgICAgICBhc3NlbWJseSB7CiAgICAgICAgICAgICAgICByIDo9IG1sb2FkKGFkZChzaWduYXR1cmUsIDB4MjApKQogICAgICAgICAgICAgICAgdnMgOj0gbWxvYWQoYWRkKHNpZ25hdHVyZSwgMHg0MCkpCiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHRyeVJlY292ZXIoaGFzaCwgciwgdnMpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiAoYWRkcmVzcygwKSwgUmVjb3ZlckVycm9yLkludmFsaWRTaWduYXR1cmVMZW5ndGgpOwogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiByZWNvdmVyKGJ5dGVzMzIgaGFzaCwgYnl0ZXMgbWVtb3J5IHNpZ25hdHVyZSkKICAgICAgICBpbnRlcm5hbAogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zIChhZGRyZXNzKQogICAgewogICAgICAgIChhZGRyZXNzIHJlY292ZXJlZCwgUmVjb3ZlckVycm9yIGVycm9yKSA9IHRyeVJlY292ZXIoaGFzaCwgc2lnbmF0dXJlKTsKICAgICAgICBfdGhyb3dFcnJvcihlcnJvcik7CiAgICAgICAgcmV0dXJuIHJlY292ZXJlZDsKICAgIH0KCiAgICBmdW5jdGlvbiB0cnlSZWNvdmVyKGJ5dGVzMzIgaGFzaCwgYnl0ZXMzMiByLCBieXRlczMyIHZzKQogICAgICAgIGludGVybmFsCiAgICAgICAgcHVyZQogICAgICAgIHJldHVybnMgKGFkZHJlc3MsIFJlY292ZXJFcnJvcikKICAgIHsKICAgICAgICBieXRlczMyIHMgPSB2cwogICAgICAgICAgICAmIGJ5dGVzMzIoCiAgICAgICAgICAgICAgICAweDdmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmYKICAgICAgICAgICAgKTsKICAgICAgICB1aW50OCB2ID0gdWludDgoKHVpbnQyNTYodnMpID4+IDI1NSkgKyAyNyk7CiAgICAgICAgcmV0dXJuIHRyeVJlY292ZXIoaGFzaCwgdiwgciwgcyk7CiAgICB9CgogICAgZnVuY3Rpb24gcmVjb3ZlcihieXRlczMyIGhhc2gsIGJ5dGVzMzIgciwgYnl0ZXMzMiB2cykKICAgICAgICBpbnRlcm5hbAogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zIChhZGRyZXNzKQogICAgewogICAgICAgIChhZGRyZXNzIHJlY292ZXJlZCwgUmVjb3ZlckVycm9yIGVycm9yKSA9IHRyeVJlY292ZXIoaGFzaCwgciwgdnMpOwogICAgICAgIF90aHJvd0Vycm9yKGVycm9yKTsKICAgICAgICByZXR1cm4gcmVjb3ZlcmVkOwogICAgfQoKICAgIGZ1bmN0aW9uIHR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2aWV3CiAgICAgICAgcmV0dXJucyAoYnl0ZXMzMikKICAgIHsKICAgICAgICByZXR1cm4ga2VjY2FrMjU2KGFiaS5lbmNvZGVQYWNrZWQoX3RvLCBfYW1vdW50KSk7CiAgICB9CgogICAgZnVuY3Rpb24gX2NoZWNrU2lncyhieXRlc1syXSBtZW1vcnkgX3NpZ3MsIGJ5dGVzMzIgX3R4SGFzaCkKICAgICAgICBwcml2YXRlCiAgICAgICAgdmlldwogICAgICAgIHJldHVybnMgKGJvb2wpCiAgICB7CiAgICAgICAgYnl0ZXMzMiBldGhTaWduZWRIYXNoID0gX3R4SGFzaC50b0V0aFNpZ25lZE1lc3NhZ2VIYXNoKCk7CgogICAgICAgIGZvciAodWludDI1NiBpID0gMDsgaSA8IF9zaWdzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIGFkZHJlc3Mgc2lnbmVyID0gZXRoU2lnbmVkSGFzaC5yZWNvdmVyKF9zaWdzW2ldKTsKICAgICAgICAgICAgYm9vbCB2YWxpZCA9IHNpZ25lciA9PSBvd25lcnNbaV07CgogICAgICAgICAgICBpZiAoIXZhbGlkKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHJldHVybiB0cnVlOwogICAgfQp9Cg=="}],VW=`
Signing messages off-chain and having a contract that requires that signature before executing a function is a useful technique.
For example this technique is used to:
Vault shares can be inflated by donating ERC20 token to the vault.
Attacker can exploit this behavior to steal other user's deposits.
Solidity supports multiple inheritance. Contracts can inherit other contract by using the is
keyword.
Solidity supports multiple inheritance. Contracts can inherit other contract by using the is
keyword.
Function that is going to be overridden by a child contract must be declared as virtual
.
Function that is going to override a parent function must use the keyword override
.
Order of inheritance is important.
@@ -11304,7 +11374,7 @@ F D,E return super.foo(); } } -`,v2=({prev:s,next:a})=>i.jsx(A,{version:G2,title:B2,description:f2,cyfrinLink:V2,html:X2,prev:s,next:a,codes:Y2}),R2="0.8.26",N2="Interface",H2="An example of interface in Solidity",F2="https://www.cyfrin.io/glossary/interface-code-example",K2=[{fileName:"Interface.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IENvdW50ZXIgewogICAgdWludDI1NiBwdWJsaWMgY291bnQ7CgogICAgZnVuY3Rpb24gaW5jcmVtZW50KCkgZXh0ZXJuYWwgewogICAgICAgIGNvdW50ICs9IDE7CiAgICB9Cn0KCmludGVyZmFjZSBJQ291bnRlciB7CiAgICBmdW5jdGlvbiBjb3VudCgpIGV4dGVybmFsIHZpZXcgcmV0dXJucyAodWludDI1Nik7CgogICAgZnVuY3Rpb24gaW5jcmVtZW50KCkgZXh0ZXJuYWw7Cn0KCmNvbnRyYWN0IE15Q29udHJhY3QgewogICAgZnVuY3Rpb24gaW5jcmVtZW50Q291bnRlcihhZGRyZXNzIF9jb3VudGVyKSBleHRlcm5hbCB7CiAgICAgICAgSUNvdW50ZXIoX2NvdW50ZXIpLmluY3JlbWVudCgpOwogICAgfQoKICAgIGZ1bmN0aW9uIGdldENvdW50KGFkZHJlc3MgX2NvdW50ZXIpIGV4dGVybmFsIHZpZXcgcmV0dXJucyAodWludDI1NikgewogICAgICAgIHJldHVybiBJQ291bnRlcihfY291bnRlcikuY291bnQoKTsKICAgIH0KfQoKLy8gVW5pc3dhcCBleGFtcGxlCmludGVyZmFjZSBVbmlzd2FwVjJGYWN0b3J5IHsKICAgIGZ1bmN0aW9uIGdldFBhaXIoYWRkcmVzcyB0b2tlbkEsIGFkZHJlc3MgdG9rZW5CKQogICAgICAgIGV4dGVybmFsCiAgICAgICAgdmlldwogICAgICAgIHJldHVybnMgKGFkZHJlc3MgcGFpcik7Cn0KCmludGVyZmFjZSBVbmlzd2FwVjJQYWlyIHsKICAgIGZ1bmN0aW9uIGdldFJlc2VydmVzKCkKICAgICAgICBleHRlcm5hbAogICAgICAgIHZpZXcKICAgICAgICByZXR1cm5zICh1aW50MTEyIHJlc2VydmUwLCB1aW50MTEyIHJlc2VydmUxLCB1aW50MzIgYmxvY2tUaW1lc3RhbXBMYXN0KTsKfQoKY29udHJhY3QgVW5pc3dhcEV4YW1wbGUgewogICAgYWRkcmVzcyBwcml2YXRlIGZhY3RvcnkgPSAweDVDNjliRWU3MDFlZjgxNGEyQjZhM0VERDRCMTY1MkNCOWNjNWFBNmY7CiAgICBhZGRyZXNzIHByaXZhdGUgZGFpID0gMHg2QjE3NTQ3NEU4OTA5NEM0NERhOThiOTU0RWVkZUFDNDk1MjcxZDBGOwogICAgYWRkcmVzcyBwcml2YXRlIHdldGggPSAweEMwMmFhQTM5YjIyM0ZFOEQwQTBlNUM0RjI3ZUFEOTA4M0M3NTZDYzI7CgogICAgZnVuY3Rpb24gZ2V0VG9rZW5SZXNlcnZlcygpIGV4dGVybmFsIHZpZXcgcmV0dXJucyAodWludDI1NiwgdWludDI1NikgewogICAgICAgIGFkZHJlc3MgcGFpciA9IFVuaXN3YXBWMkZhY3RvcnkoZmFjdG9yeSkuZ2V0UGFpcihkYWksIHdldGgpOwogICAgICAgICh1aW50MjU2IHJlc2VydmUwLCB1aW50MjU2IHJlc2VydmUxLCkgPQogICAgICAgICAgICBVbmlzd2FwVjJQYWlyKHBhaXIpLmdldFJlc2VydmVzKCk7CiAgICAgICAgcmV0dXJuIChyZXNlcnZlMCwgcmVzZXJ2ZTEpOwogICAgfQp9Cg=="}],M2=`You can interact with other contracts by declaring an Interface
.
You can interact with other contracts by declaring an Interface
.
Interface
Maps are created with the syntax mapping(keyType => valueType)
.
Maps are created with the syntax mapping(keyType => valueType)
.
The keyType
can be any built-in value type, bytes, string, or any contract.
valueType
can be any type including another mapping or an array.
Mappings are not iterable.
@@ -11497,7 +11567,7 @@ you can't send ether. delete nested[_addr1][_i]; } } -`,cG=({prev:s,next:a})=>i.jsx(A,{version:sG,title:aG,description:nG,cyfrinLink:lG,html:eG,prev:s,next:a,codes:pG}),tG="0.8.26",oG="Contract that Creates other Contracts",rG="Learn how to create new contracts from inside of a contract with Solidity",iG="https://www.cyfrin.io/glossary/contract-that-creates-other-contracts-code-example",gG=[{fileName:"NewContract.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IENhciB7CiAgICBhZGRyZXNzIHB1YmxpYyBvd25lcjsKICAgIHN0cmluZyBwdWJsaWMgbW9kZWw7CiAgICBhZGRyZXNzIHB1YmxpYyBjYXJBZGRyOwoKICAgIGNvbnN0cnVjdG9yKGFkZHJlc3MgX293bmVyLCBzdHJpbmcgbWVtb3J5IF9tb2RlbCkgcGF5YWJsZSB7CiAgICAgICAgb3duZXIgPSBfb3duZXI7CiAgICAgICAgbW9kZWwgPSBfbW9kZWw7CiAgICAgICAgY2FyQWRkciA9IGFkZHJlc3ModGhpcyk7CiAgICB9Cn0KCmNvbnRyYWN0IENhckZhY3RvcnkgewogICAgQ2FyW10gcHVibGljIGNhcnM7CgogICAgZnVuY3Rpb24gY3JlYXRlKGFkZHJlc3MgX293bmVyLCBzdHJpbmcgbWVtb3J5IF9tb2RlbCkgcHVibGljIHsKICAgICAgICBDYXIgY2FyID0gbmV3IENhcihfb3duZXIsIF9tb2RlbCk7CiAgICAgICAgY2Fycy5wdXNoKGNhcik7CiAgICB9CgogICAgZnVuY3Rpb24gY3JlYXRlQW5kU2VuZEV0aGVyKGFkZHJlc3MgX293bmVyLCBzdHJpbmcgbWVtb3J5IF9tb2RlbCkKICAgICAgICBwdWJsaWMKICAgICAgICBwYXlhYmxlCiAgICB7CiAgICAgICAgQ2FyIGNhciA9IChuZXcgQ2FyKXt2YWx1ZTogbXNnLnZhbHVlfShfb3duZXIsIF9tb2RlbCk7CiAgICAgICAgY2Fycy5wdXNoKGNhcik7CiAgICB9CgogICAgZnVuY3Rpb24gY3JlYXRlMihhZGRyZXNzIF9vd25lciwgc3RyaW5nIG1lbW9yeSBfbW9kZWwsIGJ5dGVzMzIgX3NhbHQpCiAgICAgICAgcHVibGljCiAgICB7CiAgICAgICAgQ2FyIGNhciA9IChuZXcgQ2FyKXtzYWx0OiBfc2FsdH0oX293bmVyLCBfbW9kZWwpOwogICAgICAgIGNhcnMucHVzaChjYXIpOwogICAgfQoKICAgIGZ1bmN0aW9uIGNyZWF0ZTJBbmRTZW5kRXRoZXIoCiAgICAgICAgYWRkcmVzcyBfb3duZXIsCiAgICAgICAgc3RyaW5nIG1lbW9yeSBfbW9kZWwsCiAgICAgICAgYnl0ZXMzMiBfc2FsdAogICAgKSBwdWJsaWMgcGF5YWJsZSB7CiAgICAgICAgQ2FyIGNhciA9IChuZXcgQ2FyKXt2YWx1ZTogbXNnLnZhbHVlLCBzYWx0OiBfc2FsdH0oX293bmVyLCBfbW9kZWwpOwogICAgICAgIGNhcnMucHVzaChjYXIpOwogICAgfQoKICAgIGZ1bmN0aW9uIGdldENhcih1aW50MjU2IF9pbmRleCkKICAgICAgICBwdWJsaWMKICAgICAgICB2aWV3CiAgICAgICAgcmV0dXJucyAoCiAgICAgICAgICAgIGFkZHJlc3Mgb3duZXIsCiAgICAgICAgICAgIHN0cmluZyBtZW1vcnkgbW9kZWwsCiAgICAgICAgICAgIGFkZHJlc3MgY2FyQWRkciwKICAgICAgICAgICAgdWludDI1NiBiYWxhbmNlCiAgICAgICAgKQogICAgewogICAgICAgIENhciBjYXIgPSBjYXJzW19pbmRleF07CgogICAgICAgIHJldHVybiAoY2FyLm93bmVyKCksIGNhci5tb2RlbCgpLCBjYXIuY2FyQWRkcigpLCBhZGRyZXNzKGNhcikuYmFsYW5jZSk7CiAgICB9Cn0K"}],hG=`Contracts can be created by other contracts using the new
keyword. Since 0.8.0, new
keyword supports create2
feature by specifying salt
options.
Contracts can be created by other contracts using the new
keyword. Since 0.8.0, new
keyword supports create2
feature by specifying salt
options.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -11560,7 +11630,7 @@ you can't send ether.
return (car.owner(), car.model(), car.carAddr(), address(car).balance);
}
}
-
`,IG=({prev:s,next:a})=>i.jsx(A,{version:tG,title:oG,description:rG,cyfrinLink:iG,html:hG,prev:s,next:a,codes:gG}),dG="0.8.26",CG="Payable",jG="An example of how to use the keyword payable in Solidity",AG="https://www.cyfrin.io/glossary/payable-code-example",uG=[{fileName:"Payable.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFBheWFibGUgewogICAgLy8gUGF5YWJsZSBhZGRyZXNzIGNhbiBzZW5kIEV0aGVyIHZpYSB0cmFuc2ZlciBvciBzZW5kCiAgICBhZGRyZXNzIHBheWFibGUgcHVibGljIG93bmVyOwoKICAgIC8vIFBheWFibGUgY29uc3RydWN0b3IgY2FuIHJlY2VpdmUgRXRoZXIKICAgIGNvbnN0cnVjdG9yKCkgcGF5YWJsZSB7CiAgICAgICAgb3duZXIgPSBwYXlhYmxlKG1zZy5zZW5kZXIpOwogICAgfQoKICAgIC8vIEZ1bmN0aW9uIHRvIGRlcG9zaXQgRXRoZXIgaW50byB0aGlzIGNvbnRyYWN0LgogICAgLy8gQ2FsbCB0aGlzIGZ1bmN0aW9uIGFsb25nIHdpdGggc29tZSBFdGhlci4KICAgIC8vIFRoZSBiYWxhbmNlIG9mIHRoaXMgY29udHJhY3Qgd2lsbCBiZSBhdXRvbWF0aWNhbGx5IHVwZGF0ZWQuCiAgICBmdW5jdGlvbiBkZXBvc2l0KCkgcHVibGljIHBheWFibGUge30KCiAgICAvLyBDYWxsIHRoaXMgZnVuY3Rpb24gYWxvbmcgd2l0aCBzb21lIEV0aGVyLgogICAgLy8gVGhlIGZ1bmN0aW9uIHdpbGwgdGhyb3cgYW4gZXJyb3Igc2luY2UgdGhpcyBmdW5jdGlvbiBpcyBub3QgcGF5YWJsZS4KICAgIGZ1bmN0aW9uIG5vdFBheWFibGUoKSBwdWJsaWMge30KCiAgICAvLyBGdW5jdGlvbiB0byB3aXRoZHJhdyBhbGwgRXRoZXIgZnJvbSB0aGlzIGNvbnRyYWN0LgogICAgZnVuY3Rpb24gd2l0aGRyYXcoKSBwdWJsaWMgewogICAgICAgIC8vIGdldCB0aGUgYW1vdW50IG9mIEV0aGVyIHN0b3JlZCBpbiB0aGlzIGNvbnRyYWN0CiAgICAgICAgdWludDI1NiBhbW91bnQgPSBhZGRyZXNzKHRoaXMpLmJhbGFuY2U7CgogICAgICAgIC8vIHNlbmQgYWxsIEV0aGVyIHRvIG93bmVyCiAgICAgICAgKGJvb2wgc3VjY2VzcywpID0gb3duZXIuY2FsbHt2YWx1ZTogYW1vdW50fSgiIik7CiAgICAgICAgcmVxdWlyZShzdWNjZXNzLCAiRmFpbGVkIHRvIHNlbmQgRXRoZXIiKTsKICAgIH0KCiAgICAvLyBGdW5jdGlvbiB0byB0cmFuc2ZlciBFdGhlciBmcm9tIHRoaXMgY29udHJhY3QgdG8gYWRkcmVzcyBmcm9tIGlucHV0CiAgICBmdW5jdGlvbiB0cmFuc2ZlcihhZGRyZXNzIHBheWFibGUgX3RvLCB1aW50MjU2IF9hbW91bnQpIHB1YmxpYyB7CiAgICAgICAgLy8gTm90ZSB0aGF0ICJ0byIgaXMgZGVjbGFyZWQgYXMgcGF5YWJsZQogICAgICAgIChib29sIHN1Y2Nlc3MsKSA9IF90by5jYWxse3ZhbHVlOiBfYW1vdW50fSgiIik7CiAgICAgICAgcmVxdWlyZShzdWNjZXNzLCAiRmFpbGVkIHRvIHNlbmQgRXRoZXIiKTsKICAgIH0KfQo="}],yG=`Functions and addresses declared payable
can receive ether
into the contract.
Functions and addresses declared payable
can receive ether
into the contract.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -11599,7 +11669,7 @@ you can't send ether.
require(success, "Failed to send Ether");
}
}
-
`,mG=({prev:s,next:a})=>i.jsx(A,{version:dG,title:CG,description:jG,cyfrinLink:AG,html:yG,prev:s,next:a,codes:uG}),bG="0.8.26",wG="Primitive Data Types",kG="Primitive data types",ZG="https://www.cyfrin.io/glossary/primitive-data-types-code-example",WG=[{fileName:"Primitives.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFByaW1pdGl2ZXMgewogICAgYm9vbCBwdWJsaWMgYm9vID0gdHJ1ZTsKCiAgICAvKgogICAgdWludCBzdGFuZHMgZm9yIHVuc2lnbmVkIGludGVnZXIsIG1lYW5pbmcgbm9uIG5lZ2F0aXZlIGludGVnZXJzCiAgICBkaWZmZXJlbnQgc2l6ZXMgYXJlIGF2YWlsYWJsZQogICAgICAgIHVpbnQ4ICAgcmFuZ2VzIGZyb20gMCB0byAyICoqIDggLSAxCiAgICAgICAgdWludDE2ICByYW5nZXMgZnJvbSAwIHRvIDIgKiogMTYgLSAxCiAgICAgICAgLi4uCiAgICAgICAgdWludDI1NiByYW5nZXMgZnJvbSAwIHRvIDIgKiogMjU2IC0gMQogICAgKi8KICAgIHVpbnQ4IHB1YmxpYyB1OCA9IDE7CiAgICB1aW50MjU2IHB1YmxpYyB1MjU2ID0gNDU2OwogICAgdWludDI1NiBwdWJsaWMgdSA9IDEyMzsgLy8gdWludCBpcyBhbiBhbGlhcyBmb3IgdWludDI1NgoKICAgIC8qCiAgICBOZWdhdGl2ZSBudW1iZXJzIGFyZSBhbGxvd2VkIGZvciBpbnQgdHlwZXMuCiAgICBMaWtlIHVpbnQsIGRpZmZlcmVudCByYW5nZXMgYXJlIGF2YWlsYWJsZSBmcm9tIGludDggdG8gaW50MjU2CiAgICAKICAgIGludDI1NiByYW5nZXMgZnJvbSAtMiAqKiAyNTUgdG8gMiAqKiAyNTUgLSAxCiAgICBpbnQxMjggcmFuZ2VzIGZyb20gLTIgKiogMTI3IHRvIDIgKiogMTI3IC0gMQogICAgKi8KICAgIGludDggcHVibGljIGk4ID0gLTE7CiAgICBpbnQyN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50OyAvLyAwCiAgICBhZGRyZXNzIHB1YmxpYyBkZWZhdWx0QWRkcjsgLy8gMHgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCn0K"}],GG=`Here we introduce you to some primitive data types available in Solidity.
+`,mB=({prev:s,next:a})=>i.jsx(A,{version:dB,title:CB,description:jB,cyfrinLink:AB,html:yB,prev:s,next:a,codes:uB}),bB="0.8.26",wB="Primitive Data Types",kB="Primitive data types",ZB="https://www.cyfrin.io/glossary/primitive-data-types-code-example",WB=[{fileName:"Primitives.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFByaW1pdGl2ZXMgewogICAgYm9vbCBwdWJsaWMgYm9vID0gdHJ1ZTsKCiAgICAvKgogICAgdWludCBzdGFuZHMgZm9yIHVuc2lnbmVkIGludGVnZXIsIG1lYW5pbmcgbm9uIG5lZ2F0aXZlIGludGVnZXJzCiAgICBkaWZmZXJlbnQgc2l6ZXMgYXJlIGF2YWlsYWJsZQogICAgICAgIHVpbnQ4ICAgcmFuZ2VzIGZyb20gMCB0byAyICoqIDggLSAxCiAgICAgICAgdWludDE2ICByYW5nZXMgZnJvbSAwIHRvIDIgKiogMTYgLSAxCiAgICAgICAgLi4uCiAgICAgICAgdWludDI1NiByYW5nZXMgZnJvbSAwIHRvIDIgKiogMjU2IC0gMQogICAgKi8KICAgIHVpbnQ4IHB1YmxpYyB1OCA9IDE7CiAgICB1aW50MjU2IHB1YmxpYyB1MjU2ID0gNDU2OwogICAgdWludDI1NiBwdWJsaWMgdSA9IDEyMzsgLy8gdWludCBpcyBhbiBhbGlhcyBmb3IgdWludDI1NgoKICAgIC8qCiAgICBOZWdhdGl2ZSBudW1iZXJzIGFyZSBhbGxvd2VkIGZvciBpbnQgdHlwZXMuCiAgICBMaWtlIHVpbnQsIGRpZmZlcmVudCByYW5nZXMgYXJ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ICAvLyBEZWZhdWx0IHZhbHVlcwogICAgLy8gVW5hc3NpZ25lZCB2YXJpYWJsZXMgaGF2ZSBhIGRlZmF1bHQgdmFsdWUKICAgIGJvb2wgcHVibGljIGRlZmF1bHRCb287IC8vIGZhbHNlCiAgICB1aW50MjU2IHB1YmxpYyBkZWZhdWx0VWludDsgLy8gMAogICAgaW50MjU2IHB1YmxpYyBkZWZhdWx0SW50OyAvLyAwCiAgICBhZGRyZXNzIHB1YmxpYyBkZWZhdWx0QWRkcjsgLy8gMHgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCn0K"}],BB=`Here we introduce you to some primitive data types available in Solidity.
boolean
uint256
You can send Ether to other contracts by
transfer
(2300 gas, throws error)Unlike functions, state variables cannot be overridden by re-declaring it +`,NB=({prev:s,next:a})=>i.jsx(A,{version:fB,title:VB,description:YB,cyfrinLink:XB,html:RB,prev:s,next:a,codes:vB}),HB="0.8.26",FB="Shadowing Inherited State Variables",KB="An example of shadowing state variables by inheritance",MB="https://www.cyfrin.io/glossary/shadowing-inherited-state-variables-code-example",SB=[{fileName:"Shadow.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IEEgewogICAgc3RyaW5nIHB1YmxpYyBuYW1lID0gIkNvbnRyYWN0IEEiOwoKICAgIGZ1bmN0aW9uIGdldE5hbWUoKSBwdWJsaWMgdmlldyByZXR1cm5zIChzdHJpbmcgbWVtb3J5KSB7CiAgICAgICAgcmV0dXJuIG5hbWU7CiAgICB9Cn0KCi8vIFNoYWRvd2luZyBpcyBkaXNhbGxvd2VkIGluIFNvbGlkaXR5IDAuNgovLyBUaGlzIHdpbGwgbm90IGNvbXBpbGUKLy8gY29udHJhY3QgQiBpcyBBIHsKLy8gICAgIHN0cmluZyBwdWJsaWMgbmFtZSA9ICJDb250cmFjdCBCIjsKLy8gfQoKY29udHJhY3QgQyBpcyBBIHsKICAgIC8vIFRoaXMgaXMgdGhlIGNvcnJlY3Qgd2F5IHRvIG92ZXJyaWRlIGluaGVyaXRlZCBzdGF0ZSB2YXJpYWJsZXMuCiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICBuYW1lID0gIkNvbnRyYWN0IEMiOwogICAgfQoKICAgIC8vIEMuZ2V0TmFtZSByZXR1cm5zICJDb250cmFjdCBDIgp9Cg=="}],xB=`
Unlike functions, state variables cannot be overridden by re-declaring it in the child contract.
Let's learn how to correctly override inherited state variables.
// SPDX-License-Identifier: MIT
@@ -11761,7 +11831,7 @@ in the child contract.
// C.getName returns "Contract C"
}
-
`,JG=({prev:s,next:a})=>i.jsx(A,{version:HG,title:FG,description:KG,cyfrinLink:MG,html:xG,prev:s,next:a,codes:SG}),zG="0.8.26",DG="Verifying Signature",EG="An example of how to verify signatures in Solidity",QG="https://www.cyfrin.io/glossary/verifying-signature-code-example",TG=[{fileName:"Signature.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8qIFNpZ25hdHVyZSBWZXJpZmljYXRpb24KCkhvdyB0byBTaWduIGFuZCBWZXJpZnkKIyBTaWduaW5nCjEuIENyZWF0ZSBtZXNzYWdlIHRvIHNpZ24KMi4gSGFzaCB0aGUgbWVzc2FnZQozLiBTaWduIHRoZSBoYXNoIChvZmYgY2hhaW4sIGtlZXAgeW91ciBwcml2YXRlIGtleSBzZWNyZXQpCgojIFZlcmlmeQoxLiBSZWNyZWF0ZSBoYXNoIGZyb20gdGhlIG9yaWdpbmFsIG1lc3NhZ2UKMi4gUmVjb3ZlciBzaWduZXIgZnJvbSBzaWduYXR1cmUgYW5kIGhhc2gKMy4gQ29tcGFyZSByZWNvdmVyZWQgc2lnbmVyIHRvIGNsYWltZWQgc2lnbmVyCiovCgpjb250cmFjdCBWZXJpZnlTaWduYXR1cmUgewogICAgLyog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dHVyZSk7CgogICAgICAgIHJldHVybiBlY3JlY292ZXIoX2V0aFNpZ25lZE1lc3NhZ2VIYXNoLCB2LCByLCBzKTsKICAgIH0KCiAgICBmdW5jdGlvbiBzcGxpdFNpZ25hdHVyZShieXRlcyBtZW1vcnkgc2lnKQogICAgICAgIHB1YmxpYwogICAgICAgIHB1cmUKICAgICAgICByZXR1cm5zIChieXRlczMyIHIsIGJ5dGVzMzIgcywgdWludDggdikKICAgIHsKICAgICAgICByZXF1aXJlKHNpZy5sZW5ndGggPT0gNjUsICJpbnZhbGlkIHNpZ25hdHVyZSBsZW5ndGgiKTsKCiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICAvKgogICAgICAgICAgICBGaXJzdCAzMiBieXRlcyBzdG9yZXMgdGhlIGxlbmd0aCBvZiB0aGUgc2lnbmF0dXJlCgogICAgICAgICAgICBhZGQoc2lnLCAzMikgPSBwb2ludGVyIG9mIHNpZyArIDMyCiAgICAgICAgICAgIGVmZmVjdGl2ZWx5LCBza2lwcyBmaXJzdCAzMiBieXRlcyBvZiBzaWduYXR1cmUKCiAgICAgICAgICAgIG1sb2FkKHApIGxvYWRzIG5leHQgMzIgYnl0ZXMgc3RhcnRpbmcgYXQgdGhlIG1lbW9yeSBhZGRyZXNzIHAgaW50byBtZW1vcnkKICAgICAgICAgICAgKi8KCiAgICAgICAgICAgIC8vIGZpcnN0IDMyIGJ5dGVzLCBhZnRlciB0aGUgbGVuZ3RoIHByZWZpeAogICAgICAgICAgICByIDo9IG1sb2FkKGFkZChzaWcsIDMyKSkKICAgICAgICAgICAgLy8gc2Vjb25kIDMyIGJ5dGVzCiAgICAgICAgICAgIHMgOj0gbWxvYWQoYWRkKHNpZywgNjQpKQogICAgICAgICAgICAvLyBmaW5hbCBieXRlIChmaXJzdCBieXRlIG9mIHRoZSBuZXh0IDMyIGJ5dGVzKQogICAgICAgICAgICB2IDo9IGJ5dGUoMCwgbWxvYWQoYWRkKHNpZywgOTYpKSkKICAgICAgICB9CgogICAgICAgIC8vIGltcGxpY2l0bHkgcmV0dXJuIChyLCBzLCB2KQogICAgfQp9Cg=="}],UG=`Messages can be signed off chain and then verified on chain using a smart contract.
+`,JB=({prev:s,next:a})=>i.jsx(A,{version:HB,title:FB,description:KB,cyfrinLink:MB,html:xB,prev:s,next:a,codes:SB}),zB="0.8.26",DB="Verifying Signature",EB="An example of how to verify signatures in Solidity",QB="https://www.cyfrin.io/glossary/verifying-signature-code-example",TB=[{fileName:"Signature.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8qIFNpZ25hdHVyZSBWZXJpZmljYXRpb24KCkhvdyB0byBTaWduIGFuZCBWZXJpZnkKIyBTaWduaW5nCjEuIENyZWF0ZSBtZXNzYWdlIHRvIHNpZ24KMi4gSGFzaCB0aGUgbWVzc2FnZQozLiBTaWduIHRoZSBoYXNoIChvZmYgY2hhaW4sIGtlZXAgeW91ciBwcml2YXRlIGtleSBzZWNyZXQpCgojIFZlcmlmeQoxLiBSZWNyZWF0ZSBoYXNoIGZyb20gdGhlIG9yaWdpbmFsIG1lc3NhZ2UKMi4gUmVjb3ZlciBzaWduZXIgZnJvbSBzaWduYXR1cmUgYW5kIGhhc2gKMy4gQ29tcGFyZSByZWNvdmVyZWQgc2lnbmVyIHRvIGNsYWltZWQgc2lnbmVyCiovCgpjb250cmFjdCBWZXJpZnlTaWduYXR1cmUgewogICAgLyogMS4gVW5sb2NrIE1ldGFNYXNrIGFjY291bnQKICAgIGV0aGVyZXVtLmVuYWJsZSgpCiAgICAqLwoKICAgIC8qIDIuIEdldCBtZXNzYWdlIGhhc2ggdG8gc2lnbgogICAgZ2V0TWVzc2FnZUhhc2goCiAgICAgICAgMHgxNDcyM0EwOUFDZmY2RDJBNjBEY2RGN2FBNEFGZjMwOEZEREMxNjBDLAogICAgICAgIDEyMywKICAgICAgICAiY29mZmVlIGFuZCBkb251dHMiLAogICAg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HNpZy5sZW5ndGggPT0gNjUsICJpbnZhbGlkIHNpZ25hdHVyZSBsZW5ndGgiKTsKCiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICAvKgogICAgICAgICAgICBGaXJzdCAzMiBieXRlcyBzdG9yZXMgdGhlIGxlbmd0aCBvZiB0aGUgc2lnbmF0dXJlCgogICAgICAgICAgICBhZGQoc2lnLCAzMikgPSBwb2ludGVyIG9mIHNpZyArIDMyCiAgICAgICAgICAgIGVmZmVjdGl2ZWx5LCBza2lwcyBmaXJzdCAzMiBieXRlcyBvZiBzaWduYXR1cmUKCiAgICAgICAgICAgIG1sb2FkKHApIGxvYWRzIG5leHQgMzIgYnl0ZXMgc3RhcnRpbmcgYXQgdGhlIG1lbW9yeSBhZGRyZXNzIHAgaW50byBtZW1vcnkKICAgICAgICAgICAgKi8KCiAgICAgICAgICAgIC8vIGZpcnN0IDMyIGJ5dGVzLCBhZnRlciB0aGUgbGVuZ3RoIHByZWZpeAogICAgICAgICAgICByIDo9IG1sb2FkKGFkZChzaWcsIDMyKSkKICAgICAgICAgICAgLy8gc2Vjb25kIDMyIGJ5dGVzCiAgICAgICAgICAgIHMgOj0gbWxvYWQoYWRkKHNpZywgNjQpKQogICAgICAgICAgICAvLyBmaW5hbCBieXRlIChmaXJzdCBieXRlIG9mIHRoZSBuZXh0IDMyIGJ5dGVzKQogICAgICAgICAgICB2IDo9IGJ5dGUoMCwgbWxvYWQoYWRkKHNpZywgOTYpKSkKICAgICAgICB9CgogICAgICAgIC8vIGltcGxpY2l0bHkgcmV0dXJuIChyLCBzLCB2KQogICAgfQp9Cg=="}],UB=`Messages can be signed off chain and then verified on chain using a smart contract.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -11889,7 +11959,7 @@ How to Sign and Verify
// implicitly return (r, s, v)
}
}
-
`,_G=({prev:s,next:a})=>i.jsx(A,{version:zG,title:DG,description:EG,cyfrinLink:QG,html:UG,prev:s,next:a,codes:TG}),LG="0.8.26",OG="Reading and Writing to a State Variable",PG="Reading and Writing to a State Variable",$G="https://www.cyfrin.io/glossary/reading-and-writing-to-a-state-variable-code-example",qG=[{fileName:"SimpleStorage.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFNpbXBsZVN0b3JhZ2UgewogICAgLy8gU3RhdGUgdmFyaWFibGUgdG8gc3RvcmUgYSBudW1iZXIKICAgIHVpbnQyNTYgcHVibGljIG51bTsKCiAgICAvLyBZb3UgbmVlZCB0byBzZW5kIGEgdHJhbnNhY3Rpb24gdG8gd3JpdGUgdG8gYSBzdGF0ZSB2YXJpYWJsZS4KICAgIGZ1bmN0aW9uIHNldCh1aW50MjU2IF9udW0pIHB1YmxpYyB7CiAgICAgICAgbnVtID0gX251bTsKICAgIH0KCiAgICAvLyBZb3UgY2FuIHJlYWQgZnJvbSBhIHN0YXRlIHZhcmlhYmxlIHdpdGhvdXQgc2VuZGluZyBhIHRyYW5zYWN0aW9uLgogICAgZnVuY3Rpb24gZ2V0KCkgcHVibGljIHZpZXcgcmV0dXJucyAodWludDI1NikgewogICAgICAgIHJldHVybiBudW07CiAgICB9Cn0K"}],sB=`To write or update a state variable you need to send a transaction.
+`,_B=({prev:s,next:a})=>i.jsx(A,{version:zB,title:DB,description:EB,cyfrinLink:QB,html:UB,prev:s,next:a,codes:TB}),LB="0.8.26",OB="Reading and Writing to a State Variable",PB="Reading and Writing to a State Variable",$B="https://www.cyfrin.io/glossary/reading-and-writing-to-a-state-variable-code-example",qB=[{fileName:"SimpleStorage.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFNpbXBsZVN0b3JhZ2UgewogICAgLy8gU3RhdGUgdmFyaWFibGUgdG8gc3RvcmUgYSBudW1iZXIKICAgIHVpbnQyNTYgcHVibGljIG51bTsKCiAgICAvLyBZb3UgbmVlZCB0byBzZW5kIGEgdHJhbnNhY3Rpb24gdG8gd3JpdGUgdG8gYSBzdGF0ZSB2YXJpYWJsZS4KICAgIGZ1bmN0aW9uIHNldCh1aW50MjU2IF9udW0pIHB1YmxpYyB7CiAgICAgICAgbnVtID0gX251bTsKICAgIH0KCiAgICAvLyBZb3UgY2FuIHJlYWQgZnJvbSBhIHN0YXRlIHZhcmlhYmxlIHdpdGhvdXQgc2VuZGluZyBhIHRyYW5zYWN0aW9uLgogICAgZnVuY3Rpb24gZ2V0KCkgcHVibGljIHZpZXcgcmV0dXJucyAodWludDI1NikgewogICAgICAgIHJldHVybiBudW07CiAgICB9Cn0K"}],sG=`To write or update a state variable you need to send a transaction.
On the other hand, you can read state variables, for free, without any transaction fee.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -11908,7 +11978,7 @@ How to Sign and Verify
return num;
}
}
-
`,aB=({prev:s,next:a})=>i.jsx(A,{version:LG,title:OG,description:PG,cyfrinLink:$G,html:sB,prev:s,next:a,codes:qG}),nB="0.8.26",lB="Structs",pB="An example of how to use structs in Solidity",eB="https://www.cyfrin.io/glossary/structs-code-example",cB=[{fileName:"StructDeclaration.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKLy8gVGhpcyBpcyBzYXZlZCAnU3RydWN0RGVjbGFyYXRpb24uc29sJwoKc3RydWN0IFRvZG8gewogICAgc3RyaW5nIHRleHQ7CiAgICBib29sIGNvbXBsZXRlZDsKfQo="},{fileName:"StructImport.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmltcG9ydCAiLi9TdHJ1Y3REZWNsYXJhdGlvbi5zb2wiOwoKY29udHJhY3QgVG9kb3MgewogICAgLy8gQW4gYXJyYXkgb2YgJ1RvZG8nIHN0c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rpb24gZ2V0KHVpbnQyNTYgX2luZGV4KQogICAgICAgIHB1YmxpYwogICAgICAgIHZpZXcKICAgICAgICByZXR1cm5zIChzdHJpbmcgbWVtb3J5IHRleHQsIGJvb2wgY29tcGxldGVkKQogICAgewogICAgICAgIFRvZG8gc3RvcmFnZSB0b2RvID0gdG9kb3NbX2luZGV4XTsKICAgICAgICByZXR1cm4gKHRvZG8udGV4dCwgdG9kby5jb21wbGV0ZWQpOwogICAgfQoKICAgIC8vIHVwZGF0ZSB0ZXh0CiAgICBmdW5jdGlvbiB1cGRhdGVUZXh0KHVpbnQyNTYgX2luZGV4LCBzdHJpbmcgY2FsbGRhdGEgX3RleHQpIHB1YmxpYyB7CiAgICAgICAgVG9kbyBzdG9yYWdlIHRvZG8gPSB0b2Rvc1tfaW5kZXhdOwogICAgICAgIHRvZG8udGV4dCA9IF90ZXh0OwogICAgfQoKICAgIC8vIHVwZGF0ZSBjb21wbGV0ZWQKICAgIGZ1bmN0aW9uIHRvZ2dsZUNvbXBsZXRlZCh1aW50MjU2IF9pbmRleCkgcHVibGljIHsKICAgICAgICBUb2RvIHN0b3JhZ2UgdG9kbyA9IHRvZG9zW19pbmRleF07CiAgICAgICAgdG9kby5jb21wbGV0ZWQgPSAhdG9kby5jb21wbGV0ZWQ7CiAgICB9Cn0K"}],tB=`You can define your own type by creating a struct
.
You can define your own type by creating a struct
.
They are useful for grouping together related data.
Structs can be declared outside of a contract and imported in another contract.
// SPDX-License-Identifier: MIT
@@ -11982,7 +12052,7 @@ How to Sign and Verify
// An array of 'Todo' structs
Todo[] public todos;
}
-
`,oB=({prev:s,next:a})=>i.jsx(A,{version:nB,title:lB,description:pB,cyfrinLink:eB,html:tB,prev:s,next:a,codes:cB}),rB="0.8.26",iB="Calling Parent Contracts",gB="An example of calling parent contracts in Solidity",hB="https://www.cyfrin.io/glossary/calling-parent-contracts-code-example",IB=[{fileName:"Super.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE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1bmN0aW9uIGJhcigpIHB1YmxpYyB2aXJ0dWFsIG92ZXJyaWRlIHsKICAgICAgICBlbWl0IExvZygiQy5iYXIgY2FsbGVkIik7CiAgICAgICAgc3VwZXIuYmFyKCk7CiAgICB9Cn0KCmNvbnRyYWN0IEQgaXMgQiwgQyB7CiAgICAvLyBUcnk6CiAgICAvLyAtIENhbGwgRC5mb28gYW5kIGNoZWNrIHRoZSB0cmFuc2FjdGlvbiBsb2dzLgogICAgLy8gICBBbHRob3VnaCBEIGluaGVyaXRzIEEsIEIgYW5kIEMsIGl0IG9ubHkgY2FsbGVkIEMgYW5kIHRoZW4gQS4KICAgIC8vIC0gQ2FsbCBELmJhciBhbmQgY2hlY2sgdGhlIHRyYW5zYWN0aW9uIGxvZ3MKICAgIC8vICAgRCBjYWxsZWQgQywgdGhlbiBCLCBhbmQgZmluYWxseSBBLgogICAgLy8gICBBbHRob3VnaCBzdXBlciB3YXMgY2FsbGVkIHR3aWNlIChieSBCIGFuZCBDKSBpdCBvbmx5IGNhbGxlZCBBIG9uY2UuCgogICAgZnVuY3Rpb24gZm9vKCkgcHVibGljIG92ZXJyaWRlKEIsIEMpIHsKICAgICAgICBzdXBlci5mb28oKTsKICAgIH0KCiAgICBmdW5jdGlvbiBiYXIoKSBwdWJsaWMgb3ZlcnJpZGUoQiwgQykgewogICAgICAgIHN1cGVyLmJhcigpOwogICAgfQp9Cg=="}],dB=`Parent contracts can be called directly, or by using the keyword super
.
Parent contracts can be called directly, or by using the keyword super
.
By using the keyword super
, all of the immediate parent contracts will be called.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -12050,7 +12120,7 @@ B C
super.bar();
}
}
-
`,CB=({prev:s,next:a})=>i.jsx(A,{version:rB,title:iB,description:gB,cyfrinLink:hB,html:dB,prev:s,next:a,codes:IB}),jB="0.8.26",AB="Echidna",uB="An example of testing contracts with Echidna",yB="",mB=[{fileName:"EchidnaTestTimeAndCaller.sol",code:"Ly8gU1BEWC1MaWNl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vZGUgYXNzZXJ0aW9uCiovCmNvbnRyYWN0IFRlc3RBc3NlcnQgewogICAgZnVuY3Rpb24gdGVzdF9hc3NlcnQodWludDI1NiBfaSkgZXh0ZXJuYWwgewogICAgICAgIGFzc2VydChfaSA8IDEwKTsKICAgIH0KCiAgICAvLyBNb3JlIGNvbXBsZXggZXhhbXBsZQogICAgZnVuY3Rpb24gYWJzKHVpbnQyNTYgeCwgdWludDI1NiB5KSBwcml2YXRlIHB1cmUgcmV0dXJucyAodWludDI1NikgewogICAgICAgIGlmICh4ID49IHkpIHsKICAgICAgICAgICAgcmV0dXJuIHggLSB5OwogICAgICAgIH0KICAgICAgICByZXR1cm4geSAtIHg7CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9hYnModWludDI1NiB4LCB1aW50MjU2IHkpIGV4dGVybmFsIHsKICAgICAgICB1aW50MjU2IHogPSBhYnMoeCwgeSk7CiAgICAgICAgaWYgKHggPj0geSkgewogICAgICAgICAgICBhc3NlcnQoeiA8PSB4KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBhc3NlcnQoeiA8PSB5KTsKICAgICAgICB9CiAgICB9Cn0K"}],bB=`Examples of fuzzing with Echidna.
+`,CG=({prev:s,next:a})=>i.jsx(A,{version:rG,title:iG,description:gG,cyfrinLink:hG,html:dG,prev:s,next:a,codes:IG}),jG="0.8.26",AG="Echidna",uG="An example of testing contracts with Echidna",yG="",mG=[{fileName:"EchidnaTestTimeAndCaller.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8qCmRvY2tlciBydW4gLWl0IC0tcm0gLXYgJFBXRDovY29kZSB0cmFpbG9mYml0cy9ldGgtc2VjdXJpdHktdG9vbGJveAplY2hpZG5hIEVjaGlkbmFUZXN0VGltZUFuZENhbGxlci5zb2wgLS1jb250cmFjdCBFY2hpZG5hVGVzdFRpbWVBbmRDYWxsZXIKKi8KY29udHJhY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cmV0dXJucyAodWludDI1NikgewogICAgICAgIGlmICh4ID49IHkpIHsKICAgICAgICAgICAgcmV0dXJuIHggLSB5OwogICAgICAgIH0KICAgICAgICByZXR1cm4geSAtIHg7CiAgICB9CgogICAgZnVuY3Rpb24gdGVzdF9hYnModWludDI1NiB4LCB1aW50MjU2IHkpIGV4dGVybmFsIHsKICAgICAgICB1aW50MjU2IHogPSBhYnMoeCwgeSk7CiAgICAgICAgaWYgKHggPj0geSkgewogICAgICAgICAgICBhc3NlcnQoeiA8PSB4KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBhc3NlcnQoeiA8PSB5KTsKICAgICAgICB9CiAgICB9Cn0K"}],bG=`Examples of fuzzing with Echidna.
TestEchidna.sol
Data stored in transient storage is cleared out after transaction.
+`,wG=({prev:s,next:a})=>i.jsx(A,{version:jG,title:AG,description:uG,cyfrinLink:yG,html:bG,prev:s,next:a,codes:mG}),kG="0.8.26",ZG="Transient Storage",WG="transient storage",BG="https://www.cyfrin.io/glossary/transient-storage-code-example",GG=[{fileName:"TransientStorage.sol",code:"cHJhZ21hIHNvbGlkaXR5IF4wLjguMjY7CgovLyBNYWtlIHN1cmUgRVZNIHZlcnNpb24gYW5kIFZNIHNldCB0byBDYW5jdW4KCi8vIFN0b3JhZ2UgLSBkYXRhIGlzIHN0b3JlZCBvbiB0aGUgYmxvY2tjaGFpbgovLyBNZW1vcnkgLSBkYXRhIGlzIGNsZWFyZWQgb3V0IGFmdGVyIGEgZnVuY3Rpb24gY2FsbAovLyBUcmFuc2llbnQgc3RvcmFnZSAtIGRhdGEgaXMgY2xlYXJlZCBvdXQgYWZ0ZXIgYSB0cmFuc2FjdGlvbgoKaW50ZXJmYWNlIElUZXN0IHsKICAgIGZ1bmN0aW9uIHZhbCgpIGV4dGVybmFsIHZpZXcgcmV0dXJucyAodWludDI1Nik7CiAgICBmdW5jdGlvbiB0ZXN0KCkgZXh0ZXJuYWw7Cn0KCmNvbnRyYWN0IENhbGxiYWNrIHs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mFsc2U7CiAgICB9CgogICAgLy8gMzUzMTMgZ2FzCiAgICBmdW5jdGlvbiB0ZXN0KCkgcHVibGljIGxvY2sgewogICAgICAgIC8vIElnbm9yZSBjYWxsIGVycm9yCiAgICAgICAgYnl0ZXMgbWVtb3J5IGIgPSAiIjsKICAgICAgICBtc2cuc2VuZGVyLmNhbGwoYik7CiAgICB9Cn0KCmNvbnRyYWN0IFJlZW50cmFuY3lHdWFyZFRyYW5zaWVudCB7CiAgICBieXRlczMyIGNvbnN0YW50IFNMT1QgPSAwOwoKICAgIG1vZGlmaWVyIGxvY2soKSB7CiAgICAgICAgYXNzZW1ibHkgewogICAgICAgICAgICBpZiB0bG9hZChTTE9UKSB7IHJldmVydCgwLCAwKSB9CiAgICAgICAgICAgIHRzdG9yZShTTE9ULCAxKQogICAgICAgIH0KICAgICAgICBfOwogICAgICAgIGFzc2VtYmx5IHsKICAgICAgICAgICAgdHN0b3JlKFNMT1QsIDApCiAgICAgICAgfQogICAgfQoKICAgIC8vIDIxODg3IGdhcwogICAgZnVuY3Rpb24gdGVzdCgpIGV4dGVybmFsIGxvY2sgewogICAgICAgIC8vIElnbm9yZSBjYWxsIGVycm9yCiAgICAgICAgYnl0ZXMgbWVtb3J5IGIgPSAiIjsKICAgICAgICBtc2cuc2VuZGVyLmNhbGwoYik7CiAgICB9Cn0K"}],fG=`Data stored in transient storage is cleared out after transaction.
pragma solidity ^0.8.26;
// Make sure EVM version and VM set to Cancun
@@ -12275,7 +12345,7 @@ echidna EchidnaTestTimeAndCaller.sol --contract EchidnaTestTimeAndCaller
msg.sender.call(b);
}
}
-
`,VB=({prev:s,next:a})=>i.jsx(A,{version:kB,title:ZB,description:WB,cyfrinLink:GB,html:fB,prev:s,next:a,codes:BB}),YB="0.8.26",XB="Try Catch",vB="An example of try / catch in Solidity",RB="https://www.cyfrin.io/glossary/try-catch-code-example",NB=[{fileName:"TryCatch.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1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AgfSBjYXRjaCBFcnJvcihzdHJpbmcgbWVtb3J5IHJlYXNvbikgewogICAgICAgICAgICAvLyBjYXRjaCBmYWlsaW5nIHJldmVydCgpIGFuZCByZXF1aXJlKCkKICAgICAgICAgICAgZW1pdCBMb2cocmVhc29uKTsKICAgICAgICB9IGNhdGNoIChieXRlcyBtZW1vcnkgcmVhc29uKSB7CiAgICAgICAgICAgIC8vIGNhdGNoIGZhaWxpbmcgYXNzZXJ0KCkKICAgICAgICAgICAgZW1pdCBMb2dCeXRlcyhyZWFzb24pOwogICAgICAgIH0KICAgIH0KfQo="}],HB=`try / catch
can only catch errors from external function calls and contract creation.
try / catch
can only catch errors from external function calls and contract creation.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -12334,7 +12404,7 @@ echidna EchidnaTestTimeAndCaller.sol --contract EchidnaTestTimeAndCaller
}
}
}
-
`,FB=({prev:s,next:a})=>i.jsx(A,{version:YB,title:XB,description:vB,cyfrinLink:RB,html:HB,prev:s,next:a,codes:NB}),KB="0.8.26",MB="Unchecked Math",SB="An example of unchecked math in Solidity",xB="https://www.cyfrin.io/glossary/unchecked-math-code-example",JB=[{fileName:"UncheckedMath.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFVuY2hlY2tlZE1hdGggewogICAgZnVuY3Rpb24gYWRkKHVpbnQyNTYgeCwgdWludDI1NiB5KSBleHRlcm5hbCBwdXJlIHJldHVybnMgKHVpbnQyNTYpIHsKICAgICAgICAvLyAyMjI5MSBnYXMKICAgICAgICAvLyByZXR1cm4geCArIHk7CgogICAgICAgIC8vIDIyMTAzIGdhcwogICAgICAgIHVuY2hlY2tlZCB7CiAgICAgICAgICAgIHJldHVybiB4ICsgeTsKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gc3ViKHVpbnQyNTYgeCwgdWludDI1NiB5KSBleHRlcm5hbCBwdXJlIHJldHVybnMgKHVpbnQyNTYpIHsKICAgICAgICAvLyAyMjMyOSBnYXMKICAgICAgICAvLyByZXR1cm4geCAtIHk7CgogICAgICAgIC8vIDIyMTQ3IGdhcwogICAgICAgIHVuY2hlY2tlZCB7CiAgICAgICAgICAgIHJldHVybiB4IC0geTsKICAgICAgICB9CiAgICB9CgogICAgZnVuY3Rpb24gc3VtT2ZDdWJlcyh1aW50MjU2IHgsIHVpbnQyNTYgeSkgZXh0ZXJuYWwgcHVyZSByZXR1cm5zICh1aW50MjU2KSB7CiAgICAgICAgLy8gV3JhcCBjb21wbGV4IG1hdGggbG9naWMgaW5zaWRlIHVuY2hlY2tlZAogICAgICAgIHVuY2hlY2tlZCB7CiAgICAgICAgICAgIHVpbnQyNTYgeDMgPSB4ICogeCAqIHg7CiAgICAgICAgICAgIHVpbnQyNTYgeTMgPSB5ICogeSAqIHk7CgogICAgICAgICAgICByZXR1cm4geDMgKyB5MzsKICAgICAgICB9CiAgICB9Cn0K"}],zB=`Overflow and underflow of numbers in Solidity 0.8 throw an error. This can be disabled by using unchecked
.
Overflow and underflow of numbers in Solidity 0.8 throw an error. This can be disabled by using unchecked
.
Disabling overflow / underflow check saves gas.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
@@ -12370,7 +12440,7 @@ echidna EchidnaTestTimeAndCaller.sol --contract EchidnaTestTimeAndCaller
}
}
}
-
`,DB=({prev:s,next:a})=>i.jsx(A,{version:KB,title:MB,description:SB,cyfrinLink:xB,html:zB,prev:s,next:a,codes:JB}),EB="0.8.26",QB="User Defined Value Types",TB="User defined value types",UB="https://www.cyfrin.io/glossary/user-defined-value-types-code-example",_B=[{fileName:"UserDefinedValueTypes.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8vIENvZGUgY29waWVkIGZyb20gb3B0aW1pc20KLy8gaHR0cHM6Ly9naXRodWIuY29tL2V0aG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SBUaW1lc3RhbXAud3JhcCh1aW50NjQoYmxvY2sudGltZXN0YW1wKSk7CiAgICAgICAgLy8gVHVybiB1c2VyIGRlZmluZWQgdmFsdWUgdHlwZSBiYWNrIGludG8gcHJpbWl0aXZlIHZhbHVlIHR5cGUKICAgICAgICB1aW50NjQgZF91NjQgPSBEdXJhdGlvbi51bndyYXAoZCk7CiAgICAgICAgdWludDY0IHRfdTU0ID0gVGltZXN0YW1wLnVud3JhcCh0KTsKCiAgICAgICAgLy8gTGliQ2xvY2sgZXhhbXBsZQogICAgICAgIENsb2NrIGNsb2NrID0gQ2xvY2sud3JhcCgwKTsKICAgICAgICBjbG9jayA9IExpYkNsb2NrLndyYXAoZCwgdCk7CiAgICAgICAgLy8gT29wcyEgd3Jvbmcgb3JkZXIgb2YgaW5wdXRzCiAgICAgICAgLy8gVGhpcyB3aWxsIG5vdCBjb21waWxlCiAgICAgICAgLy8gY2xvY2sgPSBMaWJDbG9jay53cmFwKHQsIGQpOwogICAgfQp9Cg=="}],LB=`// SPDX-License-Identifier: MIT
+
`,DG=({prev:s,next:a})=>i.jsx(A,{version:KG,title:MG,description:SG,cyfrinLink:xG,html:zG,prev:s,next:a,codes:JG}),EG="0.8.26",QG="User Defined Value Types",TG="User defined value types",UG="https://www.cyfrin.io/glossary/user-defined-value-types-code-example",_G=[{fileName:"UserDefinedValueTypes.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCi8vIENvZGUgY29waWVkIGZyb20gb3B0aW1pc20KLy8gaHR0cHM6Ly9naXRodWIuY29tL2V0aGVyZXVtLW9wdGltaXNtL29wdGltaXNtL2Jsb2IvZGV2ZWxvcC9wYWNrYWdlcy9jb250cmFjdHMtYmVkcm9jay9zcmMvZGlzcHV0ZS9saWIvTGliVURULnNvbAoKdHlwZSBEdXJhdGlvbiBpcyB1aW50NjQ7Cgp0eXBlIFRpbWVzdGFtcCBpcyB1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bi51bndyYXAoZCk7CiAgICAgICAgdWludDY0IHRfdTU0ID0gVGltZXN0YW1wLnVud3JhcCh0KTsKCiAgICAgICAgLy8gTGliQ2xvY2sgZXhhbXBsZQogICAgICAgIENsb2NrIGNsb2NrID0gQ2xvY2sud3JhcCgwKTsKICAgICAgICBjbG9jayA9IExpYkNsb2NrLndyYXAoZCwgdCk7CiAgICAgICAgLy8gT29wcyEgd3Jvbmcgb3JkZXIgb2YgaW5wdXRzCiAgICAgICAgLy8gVGhpcyB3aWxsIG5vdCBjb21waWxlCiAgICAgICAgLy8gY2xvY2sgPSBMaWJDbG9jay53cmFwKHQsIGQpOwogICAgfQp9Cg=="}],LG=`// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
// Code copied from optimism
@@ -12456,7 +12526,7 @@ echidna EchidnaTestTimeAndCaller.sol --contract EchidnaTestTimeAndCaller
// clock = LibClock.wrap(t, d);
}
}
-
`,OB=({prev:s,next:a})=>i.jsx(A,{version:EB,title:QB,description:TB,cyfrinLink:UB,html:LB,prev:s,next:a,codes:_B}),PB="0.8.26",$B="Variables",qB="Local, state and global variables",sf="https://www.cyfrin.io/glossary/variables-code-example",af=[{fileName:"Variables.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFZhcmlhYmxlcyB7CiAgICAvLyBTdGF0ZSB2YXJpYWJsZXMgYXJlIHN0b3JlZCBvbiB0aGUgYmxvY2tjaGFpbi4KICAgIHN0cmluZyBwdWJsaWMgdGV4dCA9ICJIZWxsbyI7CiAgICB1aW50MjU2IHB1YmxpYyBudW0gPSAxMjM7CgogICAgZnVuY3Rpb24gZG9Tb21ldGhpbmcoKSBwdWJsaWMgewogICAgICAgIC8vIExvY2FsIHZhcmlhYmxlcyBhcmUgbm90IHNhdmVkIHRvIHRoZSBibG9ja2NoYWluLgogICAgICAgIHVpbnQyNTYgaSA9IDQ1NjsKCiAgICAgICAgLy8gSGVyZSBhcmUgc29tZSBnbG9iYWwgdmFyaWFibGVzCiAgICAgICAgdWludDI1NiB0aW1lc3RhbXAgPSBibG9jay50aW1lc3RhbXA7IC8vIEN1cnJlbnQgYmxvY2sgdGltZXN0YW1wCiAgICAgICAgYWRkcmVzcyBzZW5kZXIgPSBtc2cuc2VuZGVyOyAvLyBhZGRyZXNzIG9mIHRoZSBjYWxsZXIKICAgIH0KfQo="}],nf=`There are 3 types of variables in Solidity
+`,OG=({prev:s,next:a})=>i.jsx(A,{version:EG,title:QG,description:TG,cyfrinLink:UG,html:LG,prev:s,next:a,codes:_G}),PG="0.8.26",$G="Variables",qG="Local, state and global variables",sf="https://www.cyfrin.io/glossary/variables-code-example",af=[{fileName:"Variables.sol",code:"Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yNjsKCmNvbnRyYWN0IFZhcmlhYmxlcyB7CiAgICAvLyBTdGF0ZSB2YXJpYWJsZXMgYXJlIHN0b3JlZCBvbiB0aGUgYmxvY2tjaGFpbi4KICAgIHN0cmluZyBwdWJsaWMgdGV4dCA9ICJIZWxsbyI7CiAgICB1aW50MjU2IHB1YmxpYyBudW0gPSAxMjM7CgogICAgZnVuY3Rpb24gZG9Tb21ldGhpbmcoKSBwdWJsaWMgewogICAgICAgIC8vIExvY2FsIHZhcmlhYmxlcyBhcmUgbm90IHNhdmVkIHRvIHRoZSBibG9ja2NoYWluLgogICAgICAgIHVpbnQyNTYgaSA9IDQ1NjsKCiAgICAgICAgLy8gSGVyZSBhcmUgc29tZSBnbG9iYWwgdmFyaWFibGVzCiAgICAgICAgdWludDI1NiB0aW1lc3RhbXAgPSBibG9jay50aW1lc3RhbXA7IC8vIEN1cnJlbnQgYmxvY2sgdGltZXN0YW1wCiAgICAgICAgYWRkcmVzcyBzZW5kZXIgPSBtc2cuc2VuZGVyOyAvLyBhZGRyZXNzIG9mIHRoZSBjYWxsZXIKICAgIH0KfQo="}],nf=`There are 3 types of variables in Solidity
Getter functions can be declared view
or pure
.
Getter functions can be declared view
or pure
.
View
function declares that no state will be changed.
Pure
function declares that no state variable will be changed or read.
// SPDX-License-Identifier: MIT
@@ -12581,4 +12651,4 @@ echidna EchidnaTestTimeAndCaller.sol --contract EchidnaTestTimeAndCaller
return internalFunc();
}
}
-
`,uf=({prev:s,next:a})=>i.jsx(A,{version:hf,title:If,description:df,cyfrinLink:Cf,html:Af,prev:s,next:a,codes:jf}),yf=({size:s,className:a=""})=>i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",width:s,height:s,className:a,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),mf="_component_efeb7_1",bf="_icon_efeb7_8",wf="_input_efeb7_12",Ie={component:mf,icon:bf,input:wf},kf=({value:s,onChange:a})=>{function n(l){a(l.target.value)}return i.jsxs("div",{className:Ie.component,children:[i.jsx(yf,{size:18,className:Ie.icon}),i.jsx("input",{className:Ie.input,placeholder:"Search",value:s,onChange:n})]})};var Zf="Expected a function",Xo=NaN,Wf="[object Symbol]",Gf=/^\s+|\s+$/g,Bf=/^[-+]0x[0-9a-f]+$/i,ff=/^0b[01]+$/i,Vf=/^0o[0-7]+$/i,Yf=parseInt,Xf=typeof Il=="object"&&Il&&Il.Object===Object&&Il,vf=typeof self=="object"&&self&&self.Object===Object&&self,Rf=Xf||vf||Function("return this")(),Nf=Object.prototype,Hf=Nf.toString,Ff=Math.max,Kf=Math.min,de=function(){return Rf.Date.now()};function Mf(s,a,n){var l,p,e,c,t,o,r=0,I=!1,d=!1,j=!0;if(typeof s!="function")throw new TypeError(Zf);a=vo(a)||0,gc(n)&&(I=!!n.leading,d="maxWait"in n,e=d?Ff(vo(n.maxWait)||0,a):e,j="trailing"in n?!!n.trailing:j);function u(k){var B=l,Y=p;return l=p=void 0,r=k,c=s.apply(Y,B),c}function m(k){return r=k,t=setTimeout(h,a),I?u(k):c}function b(k){var B=k-o,Y=k-r,x=a-B;return d?Kf(x,e-Y):x}function G(k){var B=k-o,Y=k-r;return o===void 0||B>=a||B<0||d&&Y>=e}function h(){var k=de();if(G(k))return g(k);t=setTimeout(h,b(k))}function g(k){return t=void 0,j&&l?u(k):(l=p=void 0,c)}function C(){t!==void 0&&clearTimeout(t),r=0,l=o=p=t=void 0}function y(){return t===void 0?c:g(de())}function Z(){var k=de(),B=G(k);if(l=arguments,p=this,o=k,B){if(t===void 0)return m(o);if(d)return t=setTimeout(h,a),u(o)}return t===void 0&&(t=setTimeout(h,a)),c}return Z.cancel=C,Z.flush=y,Z}function gc(s){var a=typeof s;return!!s&&(a=="object"||a=="function")}function Sf(s){return!!s&&typeof s=="object"}function xf(s){return typeof s=="symbol"||Sf(s)&&Hf.call(s)==Wf}function vo(s){if(typeof s=="number")return s;if(xf(s))return Xo;if(gc(s)){var a=typeof s.valueOf=="function"?s.valueOf():s;s=gc(a)?a+"":a}if(typeof s!="string")return s===0?s:+s;s=s.replace(Gf,"");var n=ff.test(s);return n||Vf.test(s)?Yf(s.slice(2),n?2:8):Bf.test(s)?Xo:+s}var Jf=Mf;const zf=Ko(Jf),Df={leading:!1,trailing:!0};function Ef(s,a,n){return W.useCallback(zf(s,a,Df),n)}function Qf(s,a){let n=s;for(let l=0;l