Easiest way to deploy your Ethereum Smart Contract

lparvinsmith

Lara Parvinsmith

Posted on January 9, 2022

Easiest way to deploy your Ethereum Smart Contract

So you've written your Ethereum smart contract, and now you may be wondering how to deploy it. I recommend first deploying the contract to a Test Network (testnet), such as Rinkeby, before deploying it to Ethereum Main Network (mainnet). You can deploy to both testnet and mainnet by using the Remix web app.

Why deploy to a testnet

Testnets behave similarly to the Ethereum Main Network, but the ETH required to transact with them is free to get from a "faucet." Faucets are apps where you can input your testnet wallet address and receive testnet assets like ETH. (I like Chainlink's Faucet and refer to it in the instructions below.) Testnet ETH enables you to pay the gas to deploy your smart contract to testnet and make test transactions.

Deploy the easiest way

Paste your contract code into the Remix IDE and deploy it from the Remix web app. Step by step instructions below:

Set up a test account on your crypto wallet, such as MetaMask. Make sure to select the Testnet of your choice from the Networks dropdown.

MetaMask test account with Rinkeby network selected

Get ETH on Testnet from a faucet by entering the address from your test account above. You will need this in the next step to pay the gas fee for deploying your contract.

Chainlink Faucet with Rinkeby network and 0.1 ETH selected

Load Remix with http rather than https to allow interaction with the wallet. Create a file in the contracts folder and paste in your smart contract.

Ballot contract file in Remix IDE

Then compile the contract in the Compile tab.

Compile Ballot contract in Remix

Note: for more information on the Compiler configuration options, please read the Remix documentation. The default configuration is fine for testing.

Then go to the Deploy tab when it's compiled. In the Deploy tab, use the Environment selector to select "Injected Web3." Confirm the correct Network, account and contract are selected.

Deploy Ballot contract on Rinkeby Network in Remix

Note: if your constructor function requires any parameters, specify them in the input next to the "Deploy" button. For more on deploy configuration, see the Remix documentation.

Your wallet will confirm the transaction in a pop-up window, including a gas fee. You should still have plenty left for testing transactions.

MetaMask transaction

Note: if you load Remix with https, you may get this message "You are using an https connection. Please switch to http if you are using Remix against an http Web3 provider or allow Mixed Content in your browser." This will prevent you from connecting to your wallet, so make sure to use "http" in the URL.

Optionally deploy to mainnet in the same Deploy tab by selecting "Ethereum Mainnet" from the MetaMask Network selector. This will also prompt the wallet to confirm the transaction, including a gas fee.

Congrats, you've deployed your contract! Now you can interact with it on Etherscan (on Rinkeby or Mainnet) or in your very own Web3 app.

💖 💪 🙅 🚩
lparvinsmith
Lara Parvinsmith

Posted on January 9, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related