Java Magazine, Jan/Feb 2017
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2017 42 cryptocurrency 4 This transaction is combined with other new transactions to form a block by miners on the Ethereum network Once a valid block is formed the block and details of its associated transactions are immortalized on the blockchain You can head back over to Etherscan to view the details of your transaction Figure 4 Figure 5 show the contents of the block on the blockchain in which the transaction resides Gas I touched earlier in the article on Ether which is used to pay for the execution of code in the EVM There are two parameters that need to be specified with respect to the cost you are prepared to pay for transactions the gas price and the gas limit The gas price is the price in Ether you are prepared to pay per gas unit Each EVM opcode contains a gas cost associated with it The gas limit is the total amount of gas usage you are willing to pay for the transaction execution This ensures that all transactions have a finite cost of execution Details about the gas associated with a transaction are visible in the transaction receipt and Etherscan Hello Ethereum World Now that Ive demonstrated a simple transaction things will start to get interesting as I create the first smart contract Ethereum smart contracts are usually written in a language named Solidity which is a statically typed high level language Describing how to use Solidity could fill many articles so Im going to keep the example simple You can read more about Solidity online Now lets use the Greeter contract example The Greeter contract is the hello world example of a smart contract of Ethereum When you deploy the contract you pass a UTF 8 encoded string to its constructor Then whenever you call the deployed contract the value of this string is returned by the node on the Ethereum network that processes your request contract mortal Define variable owner of the type address address owner this function is executed at initialization and sets the owner of the contract function mortal owner msg sender Figure 4 A receipt of the transaction
You must have JavaScript enabled to view digital editions.