Create2 - Compute Contract Address Before Deploy | Solidity (0.8)

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

КОМЕНТАРІ • 35

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

    Code - 0:56
    Contract bytecode 1:52
    How to compute contract address for create2 3:05
    Deploy with create2 4:46
    Remix demo 7:04

    • @parasnathtiwari
      @parasnathtiwari 3 роки тому

      How to get in touch with you

    • @Brandon.busher
      @Brandon.busher 3 роки тому

      Hey buddy love your videos, I'm having trouble connecting my contract to the front end using Tron link on the Tron blockchain, can you make a video on a Tron Dapp?

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

      Tron is centralized?

  • @yellemonster
    @yellemonster 3 роки тому +11

    You're the best solidity resource on the internet! Thank you for what you do :)

  • @from2ureview251
    @from2ureview251 3 роки тому +1

    i love you man, you really putting great efforts into this, arigato gozaymasti

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

    Great video! May i ask what are the 0x94, 0xd6 and 0x80 hex codes representing?

  • @s1dc0des
    @s1dc0des 3 роки тому

    very nice solidity videos..thanks a lot.

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

    Awesome video! Can you create a video on how to deploy to other chains using the same contract address? ropsten, rinkeby, polygon, bsc. Thanks!

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

    Hey, slight confusion there. You said there are creation and runtime bytecode, but then what type of bytecode we are returning from getByteCode function,

  • @sunguru981
    @sunguru981 3 роки тому +1

    Sorry, if you get a bit cringe in seeing this question haha. But I have 2 really burning questions (Since Im super new to Solidity)
    1. Why would we ever need to compute an address before even deploy? Like if the deploy process is gonna happen for sure, couldnt we get the address after deploy or something?
    2. I for all these months thought deploying a smart contract was as easy as ‘new TestContract(address, foo)’, and getting its address.
    So what exactly is the difference between the new keyword and this complicated version?
    But overall, I thoroughly understood it thanks to your explanation. Its just that, I was curious about these 2 questions :)

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

      That's a good question
      Useful cases to know the contract address in advance
      * contract requires the same unique address given constructor inputs. For example Uniswap pair contract.
      You don't want to have multiple contracts, for an pair of tokens, like DAI / ETH.
      * situation where contract can be deployed at any time, but isn't. Example: resolving a dispute between parties. If there is no dispute, no need to ever deploy the contract.

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

      @@smartcontractprogrammer Ahhh, I see. So essentially, if a Uniswap Pair of ETH/DAI is already present, but not knowing the address of it, then this would be super useful eh? Wow. Never thought in that perspective. Also, could you please help me understand my 2nd doubt?

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

      2. Use new if you don't need to know the address before deploy. Use create2 if you need to know the address before the contract is deployed.

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

      @@smartcontractprogrammer awesomeeee. Thank you so much brother :) Much appreciated

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

    While demo When you are deploying the byte code and salt then it should supposed to be the whole byte code and not only creation code ?
    In normal contract deployment the whole bytecode is deployed Correct?

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

      creation code is the whole bytecode
      code from constructor + runtime code = creation code
      both create (normal) and create2 deploy the runtime code

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

    Is salt basically the nonce ?

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

      I dont get what the salt is ? Also if I independently deploy a contract through Remix, will I simply input the value of nonce for my next transaction as salt ?

  • @Yash-qe3bv
    @Yash-qe3bv 3 роки тому

    hi man! great vids as always. I've been learning for a while. can you make a tutorial on metaTxs using GSN, i am unable to find simple resources for that. You're explanation is best! looking forward!

  • @Yash-qe3bv
    @Yash-qe3bv 3 роки тому

    nice, so we know at what address our contract is going to be deployed to. but is there a way we can deploy at a specific address then? I see some protocols have their protocols deployed at unique addresses, and also I think uniswap deploys pair addresses at pre-determined address, can you shed some light on that sir!

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

      In theory unique address of your choice can be computed.
      Loop through the salt (0 to 2^256 -1) until the desired create2 address is obtained
      Uniswap pair addresses are determined by the address of the pairs (example DAI, ETH pair is determined by address of DAI + WETH)

    • @Yash-qe3bv
      @Yash-qe3bv 3 роки тому

      @@smartcontractprogrammer I see thanks!

  • @-eurosplitsofficalclanchan6057
    @-eurosplitsofficalclanchan6057 3 роки тому

    Awesome, thanks!

  • @salem232
    @salem232 3 роки тому

    awesome videio ! Thanks 😍

  • @ilovebass879
    @ilovebass879 3 роки тому

    Super !!

  • @Sanjism-y9k
    @Sanjism-y9k 3 роки тому

    💙

  • @parasnathtiwari
    @parasnathtiwari 3 роки тому

    @smart contract programer how to get in touch with you