How to deploy a smart contract on ethereum testnet? (2024)

This is a step by step tutorial for people who want to learn how to deploy a contract to ethereum testnet. More and more people are interested on smart contract development on ethereum nowadays. When I started to learn solidity, the first thing I wanted to do is to deploy a contract and see what a smart contract can do on the blockchain. Therefore I decided to write a blog to share my experience about how I deployed contracts on ethereum testnet.

New to trading? Try crypto trading bots or copy trading

1. Write a contract. In this case, we are using the simplest contract from solidity official document.

pragma solidity ^0.4.0;

contract SimpleStorage {
uint storedData;

function set(uint x) {
storedData = x;
}

function get() constant returns (uint) {
return storedData;
}
}

2. The testnet I’m using here is Roptsen. You can get some free ether for deploying contracts at this faucet website: http://faucet.ropsten.be:3001/.

3. Using a wallet to deploy the contract. I’m using Parity for myself. There are many other options on the market. Should be very similar. For starting parity to connect with Ropsten testnet, you can use following command:

$ parity — chain ropsten — bootnodes “enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303”

open your browser at localhost:8080, you can see parity web UI:

How to deploy a smart contract on ethereum testnet? (3)

4. Open the contract tab, click deploy button, you can fill the form to submit your contract to the testnet.

How to deploy a smart contract on ethereum testnet? (4)

5. To complete the form, you need to get the abi / solc combined ouput for the contract. You can save the contract in a storage.sol file. Using the following command to compile this file to get the output (you might to need to install solc first):

$ solc --combined-json abi,bin storage.sol

the output is:

{"contracts":{"storage.sol:SimpleStorage":{"abi":"[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]","bin":"6060604052341561000f57600080fd5b5b60ce8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460475780636d4ce63c146067575b600080fd5b3415605157600080fd5b60656004808035906020019091905050608d565b005b3415607157600080fd5b60776098565b6040518082815260200191505060405180910390f35b806000819055505b50565b6000805490505b905600a165627a7a72305820fbe58fb47842b138c5fd44d533bd6dd9324435d415c78395941197f0e01d69950029"}},"version":"0.4.16+commit.d7661dd9.Linux.g++"}

6. After you complete the form for deploying the contract, you can submit the deployment request to deploy it to the testnet.

How to deploy a smart contract on ethereum testnet? (5)

7. Now you can see the deployed contract on the testnet blockchian: https://ropsten.etherscan.io/address/0x18A0fa8e30f419c26744dBDC149c7de0fCea92D0

Deploying smart contracts is fun. It is even more fun to interact with them on the blockchain. I usually learn more and faster when my hands get dirty. If you have any other questions, please leave your questions in the comments. Thanks!

Join Coinmonks Telegram Channel and Youtube Channel get daily Crypto News

Also, Read

As a seasoned expert in blockchain technology and Ethereum smart contract development, my comprehensive understanding of the subject matter allows me to provide valuable insights into the step-by-step tutorial mentioned in the article from Bleev.In. Having actively engaged in smart contract development and Ethereum blockchain exploration, I am well-equipped to discuss each concept presented in the tutorial.

The article primarily focuses on deploying a contract to the Ethereum testnet, specifically using the Ropsten testnet. Let's break down the key concepts discussed in the tutorial:

  1. Writing a Simple Smart Contract:

    • The tutorial begins with the creation of a simple smart contract using Solidity, Ethereum's programming language for smart contracts. The provided contract, named SimpleStorage, includes functions for setting and getting a uint variable.
  2. Choosing the Testnet (Ropsten):

    • The tutorial uses the Ropsten testnet for deploying the smart contract. Ropsten is a popular Ethereum testnet that mimics the Ethereum mainnet, allowing developers to test their contracts in a simulated environment.
  3. Obtaining Test Ether for Deployment:

    • To deploy a contract on the Ropsten testnet, the tutorial suggests obtaining free test ether from a faucet. The mentioned faucet website () provides a way to receive test ether for development purposes.
  4. Using Parity Wallet for Deployment:

    • The tutorial recommends using the Parity wallet for deploying the smart contract. Parity is an Ethereum client that facilitates various blockchain-related operations. The provided command demonstrates how to start Parity and connect it to the Ropsten testnet.
  5. Compiling the Smart Contract:

    • Before deployment, the smart contract needs to be compiled. The tutorial instructs users to save the contract in a file (e.g., storage.sol) and compile it using the Solidity compiler (solc). The compilation command generates the ABI (Application Binary Interface) and bytecode needed for contract deployment.
  6. Submitting the Deployment Request:

    • After compiling the contract, the tutorial guides users through filling out a form in the Parity wallet for deploying the contract. This involves providing the ABI and bytecode obtained during the compilation process.
  7. Viewing the Deployed Contract on Etherscan:

    • Once the deployment is successful, the tutorial directs users to the Ropsten Etherscan () to view the deployed contract. The provided contract address (0x18A0fa8e30f419c26744dBDC149c7de0fCea92D0) can be used to explore the contract on the blockchain.

In conclusion, the tutorial offers a detailed and hands-on guide for individuals interested in learning how to deploy a smart contract on the Ethereum testnet. Following these steps allows developers to gain practical experience in the deployment and interaction with smart contracts, fostering a deeper understanding of Ethereum blockchain development. If you have any further questions or require additional clarification on these concepts, feel free to ask.

How to deploy a smart contract on ethereum testnet? (2024)

FAQs

How to deploy smart contract on Ethereum testnet? ›

Click the “Deploy” button to deploy your smart contract to the testnet. Follow the prompts in your Ethereum wallet to confirm the transaction. Once the transaction is confirmed, you should see a new “Deployed Contracts” section appear at the bottom of the “Deploy & Run Transactions” panel.

How much does it cost to deploy a smart contract on ETH? ›

Smart contract creation cost can be anywhere from $10 to $2,000 assuming Ether costs between $1,500 to $2,000. The biggest factors are 1) Ethereum price, 2) the size of the compiled contract (in bytes), 3) the current gas price on the Ethereum network.

How do you test a smart contract for Ethereum? ›

Testing your contract on a local blockchain (also known as a development network) is a recommended alternative to testing on Mainnet. A local blockchain is a copy of the Ethereum blockchain running locally on your computer which simulates the behavior of Ethereum's execution layer.

How do I deploy on arbitrum testnet? ›

Deploy the smart contract to your local testnet​

Then run yarn hardhat run scripts/deploy. js --network localhost . This command will deploy your smart contract to the local testnet's node. You should see something like Cupcake vending machine deployed to 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 in your terminal.

How to create a smart contract in testnet? ›

Isaac Odeh
  1. Step 1: Set Up the Development Environment. Before we start writing the smart contract, we need to set up our development environment. ...
  2. Step 2: Write the Bank Smart Contract. ...
  3. Step 3: Test the Smart Contract. ...
  4. Step 4: Deploy the Contract to a Testnet. ...
  5. Step 5: Connect to your deployed smart contract.
Jul 21, 2023

How much does it cost to deploy ERC 20 token? ›

On average, the cost to create ERC20 token lies between $5000 to $10,000, depending on the type of token developed and business requirements.

How do I deploy a contract on Etherscan? ›

Submitting your Smart Contract to Etherscan
  1. Step 1: Generate an API Key on your Etherscan account. An Etherscan API Key is necessary to verify that you're the owner of the smart contract that you're trying to publish.
  2. Step 2: Hardhat-deployed Smart Contracts. ...
  3. Step 3: Check out your smart contract on Etherscan!

How much does it cost to deploy an ERC 721 contract? ›

Depending on the current gas cost on Ethereum, deploying an ERC-721 smart contract can cost anywhere from $400 to $2,000.

How do I verify and publish smart contract on Etherscan? ›

The simplest way to verify your source code is via the Etherscan UI. This process does not require any programming skills. Navigate to the Contract tab of the smart contract you are viewing on Etherscan and click the Verify and Publish link. Then, you'll need to select the file type, compiler version, and license.

How to create and deploy smart contracts? ›

There is no pre-requisite required.
  1. 5 steps to deploy a smart contract. Set up the environment. Initiate a hardhat project. ...
  2. Step1. Set up the environment. Step1, run the code in your terminal. ...
  3. Step2. Initiate a hardhat project. ...
  4. Step3. Configure network and private key. ...
  5. Step4. Code for Deployment. ...
  6. Step5. Deploy.

How to write a contract test? ›

How to perform Pact Contract Testing?
  1. Step 1: Define the Consumer Test. In the consumer service, you would write a test that defines the expected interaction with the provider's API. ...
  2. Step 2: Run the Consumer Test. ...
  3. Step 3: Generate the Contract (Pact File) ...
  4. Step 4: Verify the Provider with the Pact File.
Nov 23, 2023

How to deploy ERC20 on testnet? ›

- Use the OpenZeppelin library to import the ERC20 standard implementation. - Define your token by specifying the name, symbol, and initial supply. - Compile your smart contract using Hardhat by running `npx hardhat compile` in your terminal. - Configure Hardhat to connect to the Sepolia testnet.

How to send ETH from testnet to Mainnet? ›

Nothing from the test network can be migrated to mainnet. The chain data is different for both Execution and Consensus, so you must remove the old chain data and resync the mainnet chains from scratch. Your validators on the testnet do not carry over to mainnet.

How do I connect to Ethereum testnet? ›

Using MetaMask to send Ether and tokens on a testnet is straightforward; in the top-left of MetaMask, you can select an Ethereum network. Switch from the Main Ethereum Network to Rinkeby (or other testnet) and you should see your balances and transaction history update, to reflect the network you've selected.

How do I add Ethereum testnet to MetaMask? ›

The test networks are already there on Metamask, just that they are hidden by default. You just need to go to Settings -> Advanced and turn on the “Show test networks” switch. That's it!

How do I deploy a smart contract on testnet using truffle? ›

  1. Connect Your GitHub Repository to Truffle Teams.
  2. Setup Your Migrations Scripts.
  3. Commit to GitHub.
  4. Monitor the Status of Your Build.
  5. All Your Tests Pass, Let's Deploy! ( but only to a testnet just to be sure)
  6. Happy With a Released Version? Promote it to Production (aka deploy to Mainnet)

Top Articles
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 5933

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.