Open Zeppelin Upgradeable Contracts

Поділитися
Вставка
  • Опубліковано 2 гру 2024

КОМЕНТАРІ • 80

  • @smartcontractprogrammer
    @smartcontractprogrammer  2 роки тому +2

    0:00 - Overview
    1:44 - Project setup
    4:28 - Deploy Box V1 script
    7:10 - Execute deploy script
    8:29 - Verify Box V1 on Etherscan
    9:48 - Setup proxy / implementation on Etherscan
    10:47 - Upgrade Box V2 script
    11:49 - Execute upgrade script
    13:21 - Upgrade demo - call inc()

  • @0x_minato4thh
    @0x_minato4thh 2 роки тому +1

    u are the reason why I get internships........Happy Teachers Day.........love from India

  • @0ManishSharma0
    @0ManishSharma0 2 роки тому +15

    You have been my guardian angel in my process of learning solidity. Huge thanks to you for sharing the quality content for free

  • @Open4Profit
    @Open4Profit 2 роки тому +3

    Excellent - Learning smart contracts in depth now. Thanks for these awesome contents.

  • @enadiz246
    @enadiz246 2 роки тому

    learnt that you can verify from CLI and how to enable reading as proxy on etherscan. Very useful!

  • @omadalosso
    @omadalosso 2 роки тому +1

    Thanks for the video, the diagram made the whole pattern really easy to understand

  • @salem232
    @salem232 2 роки тому +1

    Very helpful and super clear example 🤩 thank you so much!!

  • @ThePersepolis32
    @ThePersepolis32 2 роки тому

    Thank you very much for creating these contents.

  • @zachz6620
    @zachz6620 2 роки тому +2

    One thing that is very confusing..... I thought that users are supposed to interact with the proxy contract? So shouldn't the proxy have all the functions the Box and Boxv2 contracts have? Users should be calling functions on the proxy contract which are getting routed to the implementation contract (box) via delegate call right? That date is then returned to the Proxy and the storage in proxy is used. It doesn't appear we set this up in a way that allows users to interact with the Proxy as it does not have the function to return the value.

  • @shaharnechmad2586
    @shaharnechmad2586 2 роки тому

    Great video. Thx for creating it! Would love to see one also with OpenZeplin UUPS

  • @sweetjimmy
    @sweetjimmy Рік тому +1

    12:23 on running this command I'm getting this error
    TypeError: Cannot read properties of undefined (reading 'encodeDeploy')
    at getDeployData (....node_modules\@openzeppelin\hardhat-upgrades\src\utils\deploy-impl.ts:49:45)
    PLEASE HELP!
    Here's my script:
    const { ethers, upgrades } = require("hardhat");
    const PROXY = "0xc25e45081aEB6075cc041b5346C351c820fD3306";
    async function main() {
    const BoxV2 = ethers.getContractFactory("BoxV2");
    await upgrades.upgradeProxy(PROXY, BoxV2);
    console.log("Box upgraded!");
    }
    main().catch((error) => {
    console.error(error);
    process.exitCode = 1;
    });

  • @tailyfale
    @tailyfale Рік тому +1

    1:38 - "this is done for a security reason which I will not discuss in this video" - I still don't get what security reason is here and which of your links should I check to know moree, could you please tell? Tbh I don't even understand WHAT is done for "a security reason". A smart contract acting as an Admin instead of an ordinary account? Or something else?

    • @smartcontractprogrammer
      @smartcontractprogrammer  Рік тому +1

      Functions selectors can be crafted to call upgrade instead of another function.
      forum.openzeppelin.com/t/beware-of-the-proxy-learn-how-to-exploit-function-clashing/1070
      This is prevented by forwading function call either to the implementation or execute some code inside the proxy depending on msg.sender.
      If msg.sender is the admin, then it will execute the code inside the proxy contract.
      Otherwise it will execute the code inside the implementation via delegatecall.
      Having admin be an EOA is not ideal, since the EOA may need to call functions inside the implementation. Hence the admin is set to a AdminProxy contract.

    • @tailyfale
      @tailyfale Рік тому

      @@smartcontractprogrammer thank you!

  • @andrewt5348
    @andrewt5348 2 роки тому

    Thank you very much for doing this, it has been very helpful!

  • @ThanhNguyen-ru6re
    @ThanhNguyen-ru6re 2 роки тому

    Great video. Thanks for your sharing!!!!!

  • @andreujuanc
    @andreujuanc 2 роки тому +2

    Great content!! Keep it up.

  • @pythusiast4701
    @pythusiast4701 Рік тому

    You are just awesome!!!!!!!!

  • @sulimanmukhtar4269
    @sulimanmukhtar4269 2 роки тому +1

    Waiting for the next video 🥺

  • @prolingua
    @prolingua 2 роки тому

    In the upgrade script, you specify the address of the PROXY but what is actually executed first is function upgrade() of the PROXY ADMIN, right? If so, how does the script know the address of PROXY ADMIN?

  • @ethansayagh2969
    @ethansayagh2969 2 роки тому

    Aweome and well explained.

  • @战忽局保洁阿姨
    @战忽局保洁阿姨 2 роки тому +1

    good job !

  • @fabiano.nascimento
    @fabiano.nascimento 2 роки тому +1

    Excellent!
    OpenZeppelin docs recommend shifting towards UUPS proxies. The same docs say that to use both UUPS and Transparent we call deployProxy and upgradeProxy functions. However, I haven't found how to distinguish when I want to follow UUPS pattern.
    Would you mind to make a video showing us how to follow the UUPS Proxy pattern?

  • @pulsechainalltheway1845
    @pulsechainalltheway1845 7 місяців тому

    Great video

  • @lianglaw6923
    @lianglaw6923 2 роки тому +3

    Brother, thanks for your sharing. Maybe you could share with us a little bit on reasons behind why we need to upgrade existing smart contract?
    Reason I am asking.
    1) Purpose of smart contract is do not change the logic once the code was uploaded to the blockchain.
    2) Even if we really need to upgrade. We can directly upload a new smart contract and point the front end to the latest contract.(Like uniswap and pancakeswap). Right?
    I got no clue why we need to upgrade existing smart contract.

    • @vitor4944
      @vitor4944 2 роки тому +1

      i have the same doubt 🥶

    • @0ManishSharma0
      @0ManishSharma0 2 роки тому +2

      The reason we need upgradeable contracts are:
      - Deploying new contracts would not allow us to have history of old states ( eg, the token amount for addresses will be lost if we deploy a fresh new updated instance )
      - In case of exploit discovery by white hats, we need patches/fixes too.

    • @lianglaw6923
      @lianglaw6923 2 роки тому

      ​@@0ManishSharma0
      But if we could easily modify a smart contract, the main purpose of a smart contract(unchangeble) is gone right?
      I think that is the reason why protocol like uniswap and pancakeswap come with v1 and v2 rather than v1.1xx.

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 роки тому +3

      I am just showing you how to do it. Whether you need it or not is another question

  • @saulgood2548
    @saulgood2548 2 роки тому +1

    Everything would be the same if you substitute Hardhat for Truffle?

  • @crypto_peng
    @crypto_peng 2 роки тому

    AWESOME

  • @Antonym-b5o
    @Antonym-b5o 2 роки тому

    Ohh if i change the contract version i lost my data in contract storage? can you explain please?

  • @seamini9172
    @seamini9172 2 роки тому

    Does BoxV2 inherit all functionality from BoxV1 or do you need to recreate those functions in the BoxV2 contract completely?

  • @twogroup825
    @twogroup825 2 роки тому

    Your videos are amazing! Can you explain pullPayments?

  • @countsofmath9623
    @countsofmath9623 2 роки тому

    Thank you! If we want to initialize a new variable (as in create a new variable and assign it a default value) in our second version, how would we do that without the initialize function?

    • @mikeha
      @mikeha 2 роки тому

      I don't think you can add a variable as it uses the storage of the proxy contract, not the implementation contract. And since the proxy is also immutable, we cannot make any changes to it

  • @seamini9172
    @seamini9172 2 роки тому

    Could proxy contracts be used to offload transaction gas costs from the implementation contract? For chains that have gas limits for transactions could proxies be used to take the costly gas function calls and encapsulate them in another contract that the proxy calls?

  • @jeffcui3660
    @jeffcui3660 2 роки тому

    Amazing video. If we want to change the storage variable, we have to redeploy the contract, am I right? Thanks!

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 роки тому

      Never change old storage layout. However it's safe to append new state variables

  • @mgeeta1365
    @mgeeta1365 Рік тому

    Can't we write upgradeable contracts using Remix IDE?

  • @MatiasSidler
    @MatiasSidler 2 роки тому

    Hey bro! Amazing video. One question: I'm using a local network (not with ganache) and I don't have a block explorer. Is there any other way to get the proxy and proxy admin addresses?

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 роки тому

      Look for contract creations from your account. There should be 3 (ProxyAdmin, Proxy, Implementation)

  • @alejandrocampo23
    @alejandrocampo23 2 роки тому

    Amazing video but im having trouble upgrading to V2. Once I set the PROXY constant of the verified proxy contract and run the upgrade script I am getting "Contract 0x... doesn't look like an administered ERC 1967 proxy" evethough everything looks fine on polygonscan... Help plz!

  • @jaikumar5838
    @jaikumar5838 10 місяців тому

    What happened when you have funds in the v1 ?

  • @سرالحضارات-ي4ق
    @سرالحضارات-ي4ق 2 роки тому

    Can you explain to me how you can let me make profits more than gas Fees for flash loans or flash minting

  • @asthayadav4931
    @asthayadav4931 2 роки тому

    Does this come under diamond proxy or UUPS?

  • @aaronneuville701
    @aaronneuville701 2 роки тому

    Hello, i got a question regarding the Ownabable Delegate Proxy contract…
    I cannot find my answer anywhere and opensea refers me to their discord (where i get no answer)
    So I accidentally sent eth funds to the “OwnableDelegateProxy”-contract of which i’m the owner.
    I just wonder if it is possible to get these funds back? And if so how it is done, or if anybody knows resources i should check out to solve it?
    Thank you in advance

  • @mgeeta1365
    @mgeeta1365 Рік тому

    I have only one contract creation that's the proxy contract , why can't I see the other two contracts.

    • @smartcontractprogrammer
      @smartcontractprogrammer  Рік тому

      use etherscan - you will see 3 consecutive transactions

    • @mgeeta1365
      @mgeeta1365 Рік тому

      @@smartcontractprogrammer I mean I checked the etherscan and found only one. And I was trying to redeploy , is that the reason?

  • @crocodilearms2093
    @crocodilearms2093 2 роки тому

    How do you do this in remix?

  • @guillermin1979
    @guillermin1979 2 роки тому

    github link doesn't work

  • @varundoshi5136
    @varundoshi5136 Рік тому

    Please make a similar tutorial for Proxy using Foundry

  • @jaystance9856
    @jaystance9856 2 роки тому +1

    Please I’m stuck , what do I use as my PRI_API?
    What does that even mean???
    Also in case of next time you are shooting a video that assume that we all know what’s going on, try to explain every line of code it’s necessary
    I’m still your biggest fan ✌️, watching through all your playlists

    • @jaystance9856
      @jaystance9856 2 роки тому

      Please what do I use for the PRI API???

    • @alexchang8180
      @alexchang8180 2 роки тому

      your wallet private key in Ropsten.. make sure u have some test ethers in it in order for it to work..

  • @crypto_peng
    @crypto_peng 2 роки тому

    nice nicenice

  • @blockchainapp4472
    @blockchainapp4472 2 роки тому

    where did we use the admin proxy in here?

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 роки тому

      upgrade can only be called by ProxyAdmin

    • @blockchainapp4472
      @blockchainapp4472 2 роки тому

      @@smartcontractprogrammer yes but the only thing that differentiates the first and second deployment is the proxy address that we provide.
      Where is anything specific to proxy admin is being written? while deployment. Or am I missing something related to the env keys?

  • @bitcoinshitcoin5116
    @bitcoinshitcoin5116 2 роки тому +1

    Please erc20 waiting

  • @JonJoshChua
    @JonJoshChua 2 роки тому

    Could you do one using a UUPS proxy?

  • @benjaminho351
    @benjaminho351 2 роки тому

    Diamond Standard pls

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 роки тому +2

      Over engineered. Stay away :D

    • @benjaminho351
      @benjaminho351 2 роки тому

      @@smartcontractprogrammer might be the only way for contracts that exceed the 24KB size limit tho

  • @cryptosurfer2369
    @cryptosurfer2369 2 роки тому

    Hi mate are you for hire? i can email you?

  • @JenniferBrown-n3r
    @JenniferBrown-n3r Місяць тому

    Walker Timothy Thompson Brian Lewis Ruth

  • @muhammadabdulrehman3744
    @muhammadabdulrehman3744 2 роки тому +1

    env $(cat .env) what does this please in the npx command?