Published in · 3 min read · Sep 6, 2017
--
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:
4. Open the contract tab, click deploy button, you can fill the form to submit your contract to the testnet.
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.
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
- Copy Trading | Crypto Tax Software
- Grid Trading | Crypto Hardware Wallet
- Crypto Telegram Signals | Crypto Trading Bot
- Pionex Dual Investment | AdvCash Review | Uphold Review
- 8 Best Cryptocurrency APIs for Developers
- Uphold Card Review | Trust Wallet vs MetaMask
- Earn Sign-up Bonus — 10 Best Crypto Platforms
- Best Crypto Exchange | Best Crypto Exchange in India
- Best Crypto APIs for Developers
- Best Crypto Lending Platform
- An ultimate guide to Leveraged Token
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:
-
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.
- The tutorial begins with the creation of a simple smart contract using Solidity, Ethereum's programming language for smart contracts. The provided contract, named
-
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.
-
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.
-
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.
-
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.
- Before deployment, the smart contract needs to be compiled. The tutorial instructs users to save the contract in a file (e.g.,
-
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.
-
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.