Smart Contracts are an integral part of the Ethereum blockchain. They assit in enablingg credible transaction executing without getting third parties invloved. Using this tutorial, you will learn how to deploy smart contracts on your geth node, be it testnet like ropsten and rinkeby or mainnet. You can also use this method to deploy contracts on a private testnet.
1) OS:- Ubuntu 16.04 or later
2) A running geth node
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code.It can be visualised as an application where the code and the agreements contained therein exist across a distributed, decentralized network like a blockchain network. The code controls the execution, and transactions are trackable and irreversible.
Once a smart contract is deployed , its code and functionality cannot be changed. If you make any error while publishing , a new contract instance has to be published. Thats why we should test our smart contract by testing it on testnets first before publishing it on the mainnet.
Now that you know what smart contract are and what are its advantages ,you can use the following steps to deploy your own smart contract using geth console on the ethereum network.This network can be a private testnet , ropsten or even mainnet.
For example , if you want to publish contract on your local machine , say at port 8545 , run
Using this command, the coinbase address would publish the contract on the network.
If you want to publish the contract using some other address,
(i) first of all unlock that account using
This will prompt you for the password to unlock this account
(ii) After successfully unlocking the account you can use command mentioned in step 5, just replace eth.accounts by account address of your publisher
Since deploying contract is also a type of transaction , you can see the transaction hash for the above contract using
Using the steps mentioned above ,
The above statement calls a function greet from the published contract.If you want to call any other function, just use that function name instead of greet with the correct number and data type of arguments.
You learnt what smart contracts are and how you can publish a smart contract on the geth console.