Sitemap
BlockChannel

BlockChannel is a new media & educational hub focused on the socio-cultural/economic issues related to blockchain technologies like BTC/ETH/& HNS. Visit BlockChannel.com for more resources; and SoundCloud.com/BlockChannelShow for our official podcast.

Life Cycle of an Ethereum Transaction

9 min readDec 26, 2017

--

1. End to end overview of an Ethereum transaction

Voting.deployed().then(function(instance) {
instance.voteForCandidate('Nick', {gas: 140000, from: web3.eth.accounts[0]}).then(function(r) {
console.log("Voted successfully!")
})
})

1. Construct the raw transaction object

txnCount = web3.eth.getTransactionCount(web3.eth.accounts[0])
var rawTxn = {
nonce: web3.toHex(txnCount),
gasPrice: web3.toHex(100000000000),
gasLimit: web3.toHex(140000),
to: '0x633296baebc20f33ac2e1c1b105d7cd1f6a0718b',
value: web3.toHex(0),
data: '0xcc9ab24952616d6100000000000000000000000000000000000000000000000000000000'
};
that recommends what you should set the gas price for your transaction to succeed in a reasonable amount of time. Gas prices are current measured in GWei and range from 0.1->100+Gwei. You will learn more about gas price and it’s impact later in this article.

> web3.sha3('voteForCandidate(bytes32)')'0xcc9ab267dda32b80892b2ae9e21b782dbf5562ef3e8919fc17cab72aa7db9d59'

2. Sign the Transaction

const privateKey = Buffer.from('e331b6d69882b4ab4ea581s88e0b6s4039a3de5967d88dfdcffdd2270c0fd109', 'hex')

const txn = new EthereumTx(rawTxn)
txn.sign(privateKey)
const serializedTxn = txn.serialize()

3. Transaction is validated locally

4. Transaction is broadcast to the network

transactionId = sha3(serializedTxn)

5. Miner Node accepts the transaction

explaining this topic in depth.

6. Miner Node finds a valid block and broadcasts to the network

7. Local Node receives/syncs the new block

2. Using Metamask instead of the local node

browser plugin, you can manage your accounts in your browser. The keys are stored only on your browser, so you are the only one who has access to your account and the private key. When you execute a transaction in your browser, the plugin takes care of converting your function call in to a raw transaction and sign the transaction using your private key. Metamask runs their own nodes which they use to broadcast your transaction (Behind the scenes Metamask uses nodes hosted by Infura). This way, you don’t even have to run your own Ethereum node.

3. Offline signing

for proofreading this article.

--

--

BlockChannel
BlockChannel

Published in BlockChannel

BlockChannel is a new media & educational hub focused on the socio-cultural/economic issues related to blockchain technologies like BTC/ETH/& HNS. Visit BlockChannel.com for more resources; and SoundCloud.com/BlockChannelShow for our official podcast.

Mahesh Murthy
Mahesh Murthy

Written by Mahesh Murthy

Building www.boringcrypto.xyz - a community owned forum for non price crypto discussions.

Responses (38)