Ethereum smart contract use cases

In previous sections we have seen how contracts can be written, deployed and interacted with. Now it’s time to dive in the details of communicating with the Ethereum network and smart contracts. An Ethereum node offers a RPC interface. This interface gives Ðapp’s access to the Ethereum blockchain and functionality that the ethereum smart contract use cases provides, such as compiling smart contract code.

It uses a subset of the JSON-RPC 2. The RPC interface uses a couple of conventions that are not part of the JSON-RPC 2. This decision was made because some languages have no or limited support for working with extremly large numbers. To prevent these type of errors numbers are hex encoded and it is up to the deverloper to parse these numbers and handle them appropriately. See the hex encoding section on the wiki for examples. Default block number, several RPC methods accept a block number.

In some cases it’s not possible to give a block number or not very convenient. For these cases the default block number can be one of these strings . See the wiki page for a list of RPC methods that use the default block parameters. We will go through the different steps to deploy the following contract using only the RPC interface. The first thing to do is make sure the HTTP RPC interface is enabled. In this example we use the geth node on a private development chain.

Using this approach we don’t need ether on the real network. We can verify that the interface is running by retrieving the coinbase address and balance using curl. Please note that data in these examples will differ on your local node. If you want to try these command replace the request params accordingly. Remember when we said that numbers are hex encoded? In this case the balance is returned in wei as a hex string. If we want to have the balance in ether as a number we can use web3 from the geth console.

Now that we have some ether on our private development chain we can deploy the contract. The first step is to verify that the solidity compiler is available. We can see that the solidity compiler is available. If it’s not available follow these instructions. The next step is to compile the Multiply7 contract to byte code that can be send to the EVM. Now that we have the compiled code we need to determine how much gas it costs to deploy it.