Skip to main content
1 of 2

From this video: https://www.youtube.com/watch?v=8jI1TuEaTro

I discovered Truffle (https://github.com/trufflesuite/truffle)

Couple of things on life cycle:

  1. The contract creator pays gas to get the contract into the block chain.
  2. If the method or access is constant, the client and do the operation. Constant operations do not modify the block chain, so they are free.
  3. If the method is not constant, then it costs gas to run it.

Some code using Truffle:

# Beware the promise
> var helloWorld; HelloWorld.deployed().then((a) => helloWorld = a);
# Free
> hello.balance.call()
# Not free
> hello.getBalanceBaller.sendTransaction()
'0x7acb7577a8623090b4f648203f2ecfc2e0689e011f100edef212872fe9e917f7'
> hello.balance.call()
{ [String: '412'] s: 1, e: 2, c: [ 412 ] }
# Account value
> web3.eth.getBalance(account)
{ [String: '4.824337705048486307205e+21'] s: 1, e: 21, c: [ 48243377, 5048486307205 ] }
# Block was mined
> hello.getBalance.call()
{ [String: '824'] s: 1, e: 2, c: [ 824 ] }
# Balance of account is deducted
> web3.eth.getBalance(account)
{ [String: '4.829335031748486307205e+21'] s: 1, e: 21, c: [ 48293350, 31748486307205 ] }