Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
The Ethereum networkâs next major upgrade is the Constantinople upgrade (was meant to be January 16th but has since been delayed). The upgrade introduces several new features, one of which seems unexciting on the surface but enables a range of possibilities for scalability and user onboarding. This feature is the introduction of a new opcode for the Ethereum Virtual Machine: CREATE2. This article will briefly outline what CREATE2 does and how it could drastically improve the adoption cycle for decentralised applications.
What is CREATE2?
The important thing about CREATE2 is it allows DApp (Decentralized Application) developers to generate contract addresses without having to actually deploy a contract. Previously there was no way of âreservingâ a contract address without deploying it. Weâll discuss why this is a problem for adoption later.
The actual CREATE2 opcode behaves virtually identically to the current CREATE opcode with 1 slight change. Both attempt to deploy some EVM bytecode as a new contract. However, whilst the contract address that a CREATE call deploys to is dependent solely on the sender and nonce, the new contract address for CREATE2 is dependent on extra input data.
In simple terms, you can think of it as allowing developers a level of âcontrolâ over the new contract address generated.
The Onboarding Process Before CREATE2
Think of some DApp that weâre trying to build and to market to the general public. At some point in the process of users interacting with our DApp, we likely want to give them some on-chain reward; maybe ether, tokens, or some non-fungible token. To do this, of course, the users need their own address, despite this application being their first interaction with the Ethereum blockchain.
There are a couple of options here.
We could maintain a list of private keys on some centralised server behind the scenes of the DApp. This would allow us to cheaply distribute new addresses to all of our users. However this is a significant security burden for us, and really takes the âDâ out of âDAppâ.
Another option is to create a wallet-like contract for every new user. Initially, our DApp will have full rights to all of the operations on this contract. Users can still receive everything they need, and whenever they do create their own Ethereum address, we can easily transfer full ownership over to them, removing the rights of our DApp. In theory, this works great. In practice, itâs very expensive. Contract deployments cost gas, and as the developers of this DApp we have to continually fund the creation of new contractsâââeven for cases where the users never come back. Sunk cost.
If only we could know about these contract addresses without having to spend the gas to create them!
Enter CREATE2
With CREATE2 our DApps can now know a contractâs address before itâs created. In the case above, we can easily generate wallet contract addresses for all of our users. Off-chain. For free.
We can send all of the tokens and in-game items that we need to to this address, and when the user is ready to commit and claim their new property, we can require that they send a small amount of ether to the contract address. Which will allow our DApp to go and create the contract for free, taking some of the funds to cover gas costs!
Concluding
This is just one possible brainstormed workflow, but hopefully gives you an idea of the kinds of things we can start doing when we are able to reserve contract addresses for currently unidentified users.
Let me know if you have any thoughts, or if this high-level explanation can be improved in any way.
Find me on Twitter: https://twitter.com/codingupastorm
The CREATE2 OpCode and DApp Onboarding in Ethereum was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.