13.06.2017 Views

Whitepaper - Ethereum Classic With Cover

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Ethereum</strong> <strong>Classic</strong> Documentation, Release 0.1<br />

miner.stop();<br />

balance = web3.fromWei(eth.getBalance(primary), "ether");<br />

After you create transactions, you can force process them with the following lines:<br />

miner.start(1);<br />

admin.sleepBlocks(1);<br />

miner.stop();<br />

You can check your pending transactions with:<br />

// shows transaction pool<br />

txpool.status<br />

// number of pending txs<br />

eth.getBlockTransactionCount("pending");<br />

// print all pending txs<br />

eth.getBlock("pending", true).transactions<br />

If you submitted contract creation transaction, you can check if the desired code actually got inserted in the current<br />

blockchain:<br />

txhash = eth.sendTansaction({from:primary, data: code})<br />

//... mining<br />

contractaddress = eth.getTransactionReceipt(txhash);<br />

eth.getCode(contractaddress)<br />

1.7.3 Accessing Contracts and Transactions<br />

RPC<br />

In previous sections we have seen how contracts can be written, deployed and interacted with. Now it’s time to<br />

dive in the details of communicating with the <strong>Ethereum</strong> network and smart contracts.<br />

An <strong>Ethereum</strong> node offers a RPC interface. This interface gives Ðapp’s access to the <strong>Ethereum</strong> blockchain and<br />

functionality that the node provides, such as compiling smart contract code. It uses a subset of the JSON-RPC<br />

2.0 specification (no support for notifications or named parameters) as serialisation protocol and is available over<br />

HTTP and IPC (unix domain sockets on linux/OSX and named pipe’s on Windows).<br />

If you are not interested in the details but are looking for an easy to use javascript library you can skip the following<br />

sections and continue with Using Web3.<br />

Conventions<br />

The RPC interface uses a couple of conventions that are not part of the JSON-RPC 2.0 specification:<br />

• Numbers are hex encoded. This decision was made because some languages have no or limited support for<br />

working with extremly large numbers. To prevent these type of errors numbers are hex encoded and it is up<br />

to the deverloper to parse these numbers and handle them appropriately. See the hex encoding section on<br />

the wiki for examples.<br />

• Default block number, several RPC methods accept a block number. In some cases it’s not possible to give<br />

a block number or not very convenient. For these cases the default block number can be one of these strings<br />

[”earliest”, “latest”, “pending”]. See the wiki page for a list of RPC methods that use the default block<br />

parameters.<br />

Deploy contract<br />

We will go through the different steps to deploy the following contract using only the RPC interface.<br />

1.7. Contracts and Transactions 85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!