...by Daniel Szego
"Simplicity is the ultimate sophistication."
Leonardo da Vinci

Friday, December 22, 2017

Solidity and Truffle Tips and Tricks - important Truffle console commands

eb3.eth.accounts[0] - getting the address of an account address

SmartContract.address - getting the smart contract address

SmartContract.deployed().then(inst=>{SmartContractReference=inst}) - getting a real SmartContract reference if it is deployed

SmartContractReference = SmartContract.at(tokenAddress) - getting a real reference if the tokenAddress is previously known

SmartContractReference.callFunction().then(res => res.toNumber())
- calling smart contract function with converting the result value

SmartContractReference.sendTransaction({ from: account1, value: web3.toWei(5, "ether")})
- sending ether to smart contract