Deploy
Easily deploy any contract to any EVM compatible chain, using a single command:
npx thirdweb deploy
No setup, hardcoded private keys, RPC URLs or scripting required!
Why Use Deploy?
Benefits of using Deploy:
- No setup or installation is needed.
- Increased security:
- No need to set an RPC URL - we handle all the complexities for you!
- Deploy using a user interface. This allows you to set the constructor arguments at the time of deployment.
- Automatically uploads and pins the contract metadata to IPFS.
- Automatically verifies your contract on Sourcify.
- Automatically adds your contract to the dashboard - this step is gasless! This means you can easily manage and interact with your contract.
- No need to copy your contract ABI when integrating your smart contract into a web3 app.
How Does it Work?
By using Deploy, your contract metadata is automatically uploaded to IPFS and verified making your contract usable in any web3 app without having to copy your contract ABI.
This works by:
- Using the default behavior of solc (the solidity compiler) - appending the encoded contract metadata to the contract bytecode.
- Uploading the contracts metadata to IPFS
Encoding & Extracting the Contract Metadata
By default, when compiling any solidity contract, the solc compiler:
- Computes the IPFS hash of the contract metadata JSON artifact (containing information including the contract name, ABI, source code, comments and compiler settings).
- Encodes the computed IPFS hash using CBOR encoding
- Appends the encoded bytes at the end of the compiled bytecode
This means that from any deployed contract, you can:
- Get the contract bytecode using the standard RPC call
eth_getCode
. - Decode the data at the end of the bytecode using a CBOR decoder.
- Extract the IPFS hash from the decoded data.
- Download the original contract metadata which contains source code, ABI, etc.
Since IPFS hashes are immutable, the encoded contract metadata is guaranteed to be correct and unmodified. This means that all contracts are auto-verifiable by design and without needing any third party! However, the compiler only computes the IPFS hash and encodes it, it does not upload anything to IPFS!
Uploading Contract Metadata to IPFS
By using Deploy:
- Your contract metadata is automatically uploaded to IPFS meaning that we can make use of solc's default behavior to unlock our SDKs.
- Your contract is automatically verified on Sourcify.
This makes it easy to build web3 apps, using our SDKs, without having to copy or update the contract ABI. Instead, the ABI is retrieved from the contract metadata uploaded to IPFS! This acts as a source of truth and thus is always up to date.
For more information on how contracts are automatically verified using Deploy, visit the "Self-verifiable contracts using solc and IPFS" blog post.