Review of Ethereum API and Console Options

Note

If you are new to the blockchain technology, taking our Introduction to Blockchain Technology self-paced course is highly recommended. Also, for a comprehensive coverage of blockchain development in Ethereum or mastering Solidity programming, taking our below self paced courses is highly recommended:

 

Recap

In our previous article (Review of Ethereum Developer Chain Options), we discussed what Ethereum Chain Options are and how to use them.

In this article, we learn about Ethereum API and its console options.

 

API and console options

If you have gone through the Setting up a local private Ethereum blockchain, you’ve already encountered a few API and console options:

  • –ipcdisable and –rpcport: The –ipcdisable flag disables the IPC-RPC server.
  • –rpcport decides which listening port to use for the HTTP-RPC server.
  • –rpc starts the HTTP JSON-RPC server. Alternatively, you can use admin.startRPC (addr, port) to start the HTTP JSON-RPC server.
  • In order to access RPC via a browser without request failures (due to same-origin policy), –rpccorsdomain needs to be supplied with the comma-separated set of domains. Like the following command, we start with geth and append the– rpc, and –rpccorsdomain options with a local host, as follows:

 

One-to-One Live Blockchain Classes

Coding Bootcamps school offers One-to-One Live Blockchain Classes for Beginners.

 

$ geth –rpc –rpccorsdomain http://localhost:3000

  • To enable management APIs, use the flags in the format of –{interface}api. For example, –rpcapi is for the HTTP endpoint, while –wsapi is for the WebSocket. The default –ipcapi setting will enable all the APIs for the ipc interface, and db, eth, net, and web3 for the HTTP and WS interfaces. Please enable APIs for different interfaces with caution. All the management APIs are listed in the following  table:

 

Management API namespaces Support Methods
admin Nodes management datadir, nodeInfo, peers, setSolc, startRPC, startWS, stopRPC, stopWS
 

 

debug

 

 

Nodes debugging

backtraceAt, blockProfile, cpuProfile, dumpBlock, gcStats, getBlockRlp, goTrace, memStats, seedHashsign, setBlockProfileRate, setHead, stacks, startCPUProfile, startGoTrace, stopCPUProfile, stopGoTrace, traceBlock, traceBlockByNumber, traceBlockByHash, traceBlockFromFile, traceTransaction,
verbosity, vmodule, writeBlockProfile, writeMemProfile
miner Miner and Ethash DAG management setExtra, setGasPrice, start, stop, getHashrate, setEtherbase
 

personal

Accounts management ecRecover, importRawKey, listAccounts, lockAccount, newAccount, unlockAccount, sendTransaction, sign
 

txpool

Pool and transactions management  

content, inspect, status

Apart from the DApp namespaces such as eth, shh, and web3, geth allows the extra management API namespaces we mentioned previously:

  • Admin allows access to a few RPC methods, giving better control over the Geth instance
  • Debug helps developers debug during runtime
  • Miner provides extra mining settings, and helps developers gain remote control over a mining operation
  • Through a personal API, private keys in the key store can be managed
  • The txpoolAPI allows developers to access the transaction pool, as well as pending and queued transactions.

 

Next Article

In our next article (Review of Ethereum Networking Options), we discuss Ethereum Networking Options.

This article is written in collaboration with Brian Wu who is a leading author of “Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts” book. He has written 7 books on blockchain development.

 

Resources

coming soon