Deploying a smart contract to Ethereum

Image for post
Image for post
pragma solidity ^0.4.11;  contract Simple {    

uint8 public count;

function Simple(uint8 _amount) {
count = _amount;
}
function add(uint8 _amount) {
count += _amount;
}
}
node compile Simple
6060604052341561000f57600080fd5b60405160208061011a833981016040528080516000805460ff90921660ff19909216919091179055505060d3806100476000396000f300606060405263ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302067e6a8114604557806306661abd14605d57600080fd5b3415604f57600080fd5b605b60ff600435166083565b005b3415606757600080fd5b606d609e565b60405160ff909116815260200160405180910390f35b6000805460ff19811660ff9182169390930116919091179055565b60005460ff16815600a165627a7a723058203b071253b061d82c255e5006105dfcb6234b29200503a45f7a55c842c0dbc10a0029
node deploy Simple
module.exports = [253]
paying a max of 2000000 gas @ the price of 22 gwei (22000000000) 
...
==ETHER COST: 0.0029070139999999994 $1.0174548999999997

//
// usage: node contract getCount Simple
//
module.exports = (contract,params,args)=>{
contract.methods.count().call().then((count)=>{
console.log("COUNT:"+count)
})
}
node contract getCount SimpleCOUNT:253
//
// usage: node contract add Simple null #AMOUNT#
//
// ex: node contract add Simple null 1
//
module.exports = (contract,params,args)=>{
console.log("**== adding "+args[5])
return contract.methods.add(args[5]).send({
from: params.accounts[0],
gas: params.gas,
gasPrice:params.gasPrice
})
}
node contract add Simple null 1
Success
{
blockHash: '0x78ad780d0bf95737baec82f974e067d4ee67708829cbd4dad4fda15c3de39a51',
blockNumber: 1856672,
contractAddress: null,
cumulativeGasUsed: 26840,
from: '0x4ffd642a057ce33579a3ca638347b402b909f6d6',
gasUsed: 26840,
status: '0x1',
to: '0xd68ef7611913d0aff3627a92f5e502696887d626',
transactionHash: '0x78a472410ada67aa2345d37fb4d695e1e07702940aae51616efacb7e4b01621c',
transactionIndex: 0
}
node contract getCount SimpleCOUNT:254
echo "2" > gasprice.int
node contract add Simple null 1
COUNT:255

node contract add Simple null 1
COUNT:0

Coinmonks

Coinmonks is a non-profit Crypto educational publication.

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by CoinCodeCap.com Take a look

By signing up, you will create a Medium account if you don’t already have one.

Check your inbox
Click the link Medium sent to to verify your email address.

Austin Thomas Griffith

Written by

http://austingriffith.com

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Austin Thomas Griffith

Written by

http://austingriffith.com

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store