Deploying smart contracts
Zvapedzisira kugadziriswa: @wackerow(opens in a new tab), 2024 Kubvumbi 23
You need to deploy your smart contract for it to be available to users of an Ethereum network.
To deploy a smart contract, you merely send an Ethereum transaction containing the compiled code of the smart contract without specifying any recipient.
Prerequisites
You should understand Ethereum networks, transactions and the anatomy of smart contracts before deploying smart contracts.
Deploying a contract also costs ether (ETH) since they are stored on the blockchain, so you should be familiar with gas and fees on Ethereum.
Finally, you'll need to compile your contract before deploying it, so make sure you've read about compiling smart contracts.
How to deploy a smart contract
What you'll need
- Your contract's bytecode – this is generated through compilation
- ETH for gas – you'll set your gas limit like other transactions so be aware that contract deployment needs a lot more gas than a simple ETH transfer
- a deployment script or plugin
- access to an Ethereum node, either by running your own, connecting to a public node, or via an API key using a node service
Steps to deploy a smart contract
The specific steps involved will depend on the development framework in question. For example, you can check out Hardhat's documentation on deploying your contracts(opens in a new tab) or Foundry's documentation on deploying and verifying a smart contract(opens in a new tab). Once deployed, your contract will have an Ethereum address like other accounts and can be verified using source code verification tools.
Related tools
Remix - Remix IDE allows developing, deploying and administering smart contracts for Ethereum like blockchains
Tenderly - Web3 development platform that provides debugging, observability, and infrastructure building blocks for developing, testing, monitoring, and operating smart contracts
- tenderly.co(opens in a new tab)
- Docs(opens in a new tab)
- GitHub(opens in a new tab)
- Discord(opens in a new tab)
Hardhat - A development environment to compile, deploy, test, and debug your Ethereum software
- hardhat.org(opens in a new tab)
- Docs on deploying your contracts(opens in a new tab)
- GitHub(opens in a new tab)
- Discord(opens in a new tab)
thirdweb - Easily deploy any contract to any EVM compatible chain, using a single command
Crossmint - Enterprise-grade web3 development platform to deploy smart contracts, enable credit-card and cross chain payments, and use APIs to create, distribute, sell, store, and edit NFTs.
- crossmint.com(opens in a new tab)
- Documentation(opens in a new tab)
- Discord(opens in a new tab)
- Blog(opens in a new tab)
Related tutorials
- Deploying your first smart contract – An introduction to deploying your first smart contract on an Ethereum test network.
- Hello World | smart contract tutorial – An easy-to-follow tutorial to create & deploy a basic smart contract on Ethereum.
- Interact with other contracts from Solidity – How to deploy a smart contract from an existing contract and interact with it.
- How to downsize your contract size - How to reduce your contract's size to keep it under the limit and save on gas
Further reading
- https://docs.openzeppelin.com/learn/deploying-and-interacting(opens in a new tab) - OpenZeppelin
- Deploying your contracts with Hardhat(opens in a new tab) - Nomic Labs
Know of a community resource that helped you? Edit this page and add it!