What is CREATE2?
Coinbase made headlines recently with its use of CREATE2 and minimal proxy contracts to improve their non-custodial commercial payments system. But if you’re like me, you probably came away with a very loose grasp of CREATE2. So, let’s break down exactly what it is and what it does.
What is CREATE2?
CREATE2 is an upgrade to Ethereum that changes the way smart contracts are deployed. In the original CREATE opcode, contract addresses were generated by from the deployer’s account and nonce. However, the new CREATE2 opcode replaces these values with a data value called salt. The salt combined with the init code of the contract allows you to determine its future address before it is deployed. It’s a way to say: “I’ll deploy this contract at this address in the future.”
This upgrade enables loads of off-chain scaling solutions. It allows interactions with addresses that do not exist yet on-chain with guarantees that this future on-chain address can only contain specific contract code. In other words, layer 2 state channel participants can agree upon the terms of a future smart contract and interact under this agreement before the contract ever exists on-chain.
History of CREATE2
EIP 1014, written by Vitalik Buterin, introduced “Skinny CREATE2” on April 20, 2018. The proposal sought to enable off-chain scalability, as previously mentioned, and to prepare for future upgrades to Ethereum like state rent and sharding.
At first, some in the Ethereum community expressed concerns about possible attack vectors created by this new way of deploying smart contracts. Concern arose from the fact that with CREATE2 a developer could theoretically deploy a contract, self-destruct it and then deploy it again with altered code. At first, this sounds frightening but there are ways to safeguard against this.
In an Ethereum Core Devs Meeting on Feb. 15th, 2018, the effects of CREATE2 to smart contract were discussed in an attempt to educate developers. Ultimately, it was determined that best practices would need to be formed for writing and performing audits on init codes to mitigate potentia l risks. CREATE2 went live with Ethereum’s Constantinople upgrade fork in February 2019.
So what’s the big deal with CREATE2?
Let’s take a look at how Coinbase Commerce used CREATE2 to reshape their customer experience. Through a combination of minimal proxy contracts, state channels, and the new CREATE2 opcode, Coinbase Commerce processes USDC transactions instantly.
Coinbase Commerce allows businesses to accept customer payments in cryptocurrency like ETH or USDC in a non-custodial way. They use what they call a “Forwarder” contract to create a charge, collect payments, and then forward them onto the vendor. In the past, Coinbase would have had to create many costly Forwarder contracts on-chain to receive customers’ payments.
But now, Coinbase is able to create copies of existing smart contract called minimal proxy contracts and interact with them off-chain before their deployed on-chain. CREATE2 enables these proxy contracts to reuse the Forwarder contract code off-chain allowing customers to pay these contracts instantly through state channels. And then, Coinbase deploys the forwarding smart contract and settles the payments on-chain later (like when gas prices are cheap).
Taking advantage of CREATE2, Coinbase Commerce became more time and cost-efficient for everyone involved. Making things more convenient for the customer while also cutting back on gas costs and possible network congestion. And that’s just one of many innovative solutions which will likely be built using CREATE2.
Come discuss how CREATE2 will impact the future of smart contract scalability in our Discord.