loved it :) just one thing I see the implementation contract address passed in the metamorphic contract method is only saved in a mapping so how is the add function is called on line 56 in the challenge.ts since when the 1st metamorphic contract is deployed the address & the bytecode is diff from contractOne(on line 32) ?
Thank you for watching and for your comment and question! In line 32, the contract C1 is deployed at address C1.address === A1, say. Then, in line 43 we deploy this contract to some new address, say, A0, that is determined by the `salt` parameter used. Later on, we deploy contract C2 with address C2.address === A2, say. Then, we update the metamorphic contract's code in line 96. The code is now updated to C2's code, but the address A0 is the same. This is because the `salt` is the same. Hence, we've changed the underlying code of a smart contract while keeping the address (A0) the same.
yeah I get the overall concept was just that in deployMetamorphicContractWithConstructor we use the _transientContractInitializationCode for deployment which we passed as "0x0" so was wondering how is C1 being deployed to the new address on 43 since the bytecode we use for deployment is "0x0"
@@virajmalhotra313 Ah! Great question. So the flow for deploying a proxy contract in this case is: 1) deploy the contract 2) call the "initializer" function (it's like a constructor) For more on 2) see this: docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializers. But, in our case, we don't have an initializer/constructor function for our very simple contract. So no need to pass anything (and hence we pass 0x0).
yeah yeah I know the concept I was looking at the wrong method on the metamorphic contract lol, I see the init bytecode for c1 is set in the constructor so all good, for real scenario's probably better to make the bytecode dynamic ofc
Thanks for watching! And thanks for your comment: I take your comment to imply the content is valuable - but of course, like any other tool and knowledge, we must always be careful to use it for good (great power, etc.)! This channel and I personally do not endorse any hacks, of course. Hacks ruin the space overall, and it financially hurts people. Knowing about hacks, however, can help us become better programmers and write safer codes - that's what I hope you and everybody who watches will take away from this! Stay safe!
@@cryptojesperk Exactly! I can clear understand what you're saying. At the end of day, we're just here to make the world much safer place. Moreover, Can I get in touch with you sir? I would love to be a student under you. Hoping that you'll respond kindly.
This is an amazing solidity concept. I never knew something like this existed🤦♂️🤦♂️. Thanks as always👍👍
Thank you so much 🙏 glad it’s useful! 🎉
You are the best, great content as always 🙂
thank you for the support 🙏
please upload more videos
Appreciate the support! My next video comes out very soon - on another type of advanced proxy pattern! 🙏
you are awesome!
Thank you very much 🙏
where's the link to your repo for the challenge?
Thanks for watching! It's here: github.com/jesperkristensen58/metamorphic-contract-example
Nice content
Thank you so much; I’m happy to hear you liked it!
loved it :)
just one thing I see the implementation contract address passed in the metamorphic contract method is only saved in a mapping so how is the add function is called on line 56 in the challenge.ts since when the 1st metamorphic contract is deployed the address & the bytecode is diff from contractOne(on line 32) ?
Thank you for watching and for your comment and question!
In line 32, the contract C1 is deployed at address C1.address === A1, say.
Then, in line 43 we deploy this contract to some new address, say, A0, that is determined by the `salt` parameter used.
Later on, we deploy contract C2 with address C2.address === A2, say.
Then, we update the metamorphic contract's code in line 96. The code is now updated to C2's code, but the address A0 is the same. This is because the `salt` is the same.
Hence, we've changed the underlying code of a smart contract while keeping the address (A0) the same.
yeah I get the overall concept was just that in deployMetamorphicContractWithConstructor we use the _transientContractInitializationCode for deployment which we passed as "0x0" so was wondering how is C1 being deployed to the new address on 43 since the bytecode we use for deployment is "0x0"
@@virajmalhotra313 Ah! Great question.
So the flow for deploying a proxy contract in this case is:
1) deploy the contract
2) call the "initializer" function (it's like a constructor)
For more on 2) see this: docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializers.
But, in our case, we don't have an initializer/constructor function for our very simple contract.
So no need to pass anything (and hence we pass 0x0).
yeah yeah I know the concept I was looking at the wrong method on the metamorphic contract lol,
I see the init bytecode for c1 is set in the constructor so all good,
for real scenario's probably better to make the bytecode dynamic ofc
@@virajmalhotra313 yes, indeed! thanks for your questions
Im damn sure that the guy who did the tornado DAO hack must seen this video 😅
Thanks for watching! And thanks for your comment: I take your comment to imply the content is valuable - but of course, like any other tool and knowledge, we must always be careful to use it for good (great power, etc.)! This channel and I personally do not endorse any hacks, of course. Hacks ruin the space overall, and it financially hurts people. Knowing about hacks, however, can help us become better programmers and write safer codes - that's what I hope you and everybody who watches will take away from this! Stay safe!
@@cryptojesperk Exactly! I can clear understand what you're saying. At the end of day, we're just here to make the world much safer place.
Moreover, Can I get in touch with you sir? I would love to be a student under you. Hoping that you'll respond kindly.
@@vamsikingu8453 Yes, exactly.
Sure! Happy to help; feel free to DM me on Twitter: twitter.com/cryptojesperk