Miner commands for both RPC and JS Console mode

Our guides

Get started

We have two main options to control the miner, so let’s start!

1.1 JS Console mode

The first method is through the JavaScript Console; this means that the miner will present you with a CLI (command line interface) that supports direct interaction and every event is printed directly on the screen. Note that there is no logfile in this mode!
The main reason to use this method of control is if you need direct feedback, in general however I personally prefer the JSON RPC mode, since it will keep the log and allows you to control the miner from anything that can make RPC calls.

How to start the miner In JS Console mode:

				
					./start.sh 1
				
			

1.2. RPC Mode

The second method is through JSON RPC (Remote Procedure Calls in JSON format) Cypherium can expose a REST API that accepts RPC in JSON format, what this means is that the miner is running in the background and accepts commands on a specific port (this port should only be exposed on your local system) where the default port is 8000
Note that you will need to use a “tool” to interact with the miner, this can be a standard Linux command line utility like curl or maybe you like to use a desktop tool like postman (https://www.postman.com/) or if you are more into programming you can even build something in your favorite programming language (almost all of them have libraries that facilitate RPC calls)
All events are appended to the default logfile cypherlog.txt

Note that the helper script starts the miner in RPC mode, so when you choose to use the menu.sh script all RPC commands can also be used directly.

How to start the miner in RPC mode:

				
					./start.sh 0
				
			

2. Commands

Now that we know the difference and how to start the miner in the desired mode, lets list some commands that can be issued in both JSON RPC and JS Console mode
Note that the JSON RPC command examples use curl, since that is something that you probably have installed on your miner.

Note that the geth rpc-api can be set to accept certain commands, the modules that are passed in the run.sh script do not contain the “admin” module that is required by some calls, please refer to the on how to modify the run.sh script.

Note that the command’s displayed in this section are subject to change and this section will be updated accordingly.

2. Net

2.1 net_version
Function to return the network ID of the currently connected network

Client

Method invocation

JS console

				
					net.version
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "net_version", "params": []}' 0.0.0.0:8000
				
			

2.2 net_peerCount
Function to return the number of peer nodes that are currently connected to the client.

Client

Method invocation

JS console

				
					net.peerCount
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "net_peerCount", "params": []}' 0.0.0.0:8000
				
			

3. Miner

3.1 miner_start
Function to start the mining process, where
Note that you can have more than one miner account/wallet so make sure the CPH address and passphrase match

Client

Method invocation

JS console

				
					miner.start(<number of threads>, "<miner address>", "<address passphrase>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "miner_start", "params": [<number of threads>,"<miner address>", "<address passphrase>"]}' 0.0.0.0:8000
				
			

3.2 miner_stop
Function to stop the mining process

Client

Method invocation

JS console

				
					miner.stop()
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "miner_stop"}' 0.0.0.0:8000
				
			

3.3 miner_content
Function to return the status of all candidate nodes (candidate nodes are nodes that are considered to become part of the committee)

Client

Method invocation

JS console

				
					miner.content()
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "miner_content", "params": []}' 0.0.0.0:8000
				
			

3.4 miner_status
Function to return the status (common node, committee member, committee leader) of the miner.

Client

Method invocation

JS console

				
					miner.status()
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "miner_status", "params": []}' 0.0.0.0:8000
				
			

4. Admin

4.1 admin_addPeer
Function to connect a node (miner) to a static set of peers called “static nodes”. The miner will periodically check for connectivity with the static nodes and will attempt to reconnect in case of dropped connections.
A so called cnode URL is required to add a static node;

				
					cnode://<hexadecimal node id>@<IP>:<TCP listening port>?discport=<UDP discovery port>
				
			

By default the discovery and listener port are the same (both 6000) so only one port needs to be specified, this simplifies the cnode URL to;

				
					cnode://<hexadecimal node id>@<IP>:6000
				
			

The reason for wanting to add a static node manually can be network connectivity, for example issues related to a firewall.

For examples, you can get your miners own cnode with the admin_nodeInfo function or use the admin admin_peers function to get a cnode URLs from the your peer nodes

Client

Method invocation

JS console

				
					admin.addPeer("<cnode> ")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_addPeer", "params": ["<cnode>"]}' 0.0.0.0:8000
				
			

4.2 admin_datadir
Function to return absolute path used by the Geth node to store its databases

Client

Method invocation

JS console

				
					admin.datadir
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_datadir"}' 0.0.0.0:8000
				
			

4.3 admin_nodeInfo
Function to return all known information about the running Geth node at networking granularity.
This includes general information about the node as a participant of the P2P overlay protocol, as well as specialized information added by each of the running application protocols (e.g. cph, shh, bzz)

Client

Method invocation

JS console

				
					admin.nodeInfo
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_nodeInfo"}' 0.0.0.0:8000
				
			

4.4 admin_peers
Function to return all known information about the connected remote nodes (peers) at networking granularity.
This includes general information about the node as a participant of the P2P overlay protocol, as well as specialized information added by each of the running application protocols (e.g. cph, shh, bzz)

Client

Method invocation

JS console

				
					admin.peers
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_peers"}' 0.0.0.0:8000
				
			

4.5 admin_startRPC
Function to start a HTTP based JSON RPC API webserver to handle client requests.
All parameters are optional (all of them have a default value):

•             host: Listener socket network interface (default: “localhost”)
•             port: Listener socket network port (default: 8546)
•             cors: Cross-origin resource sharing header (default: “”)
•             apis: Enabled API modules (default: “cph,net,web3”)

Client

Method invocation

JS console

				
					admin.startRPC("<host> ", <port>, "<cors>", "<apis>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_startRPC", "params": ["<host>", <port number>, "<cors>", "<apis>"]}' 0.0.0.0:8000
				
			

4.6 admin_startWS
Function to start a WebSocket based JSON RPC API webserver to handle client requests.
All parameters are optional (all of them have a default value):

•             host: Listener socket network interface (default: “localhost”)
•             port: Listener socket network port (default: 8000)
•             cors: Cross-origin resource sharing header (default: “”)
•             apis: Enabled API modules (default: “cph,net,web3”)

Client

Method invocation

JS console

				
					admin.startRPC("<host>", <port>, "<cors>", "<apis>")", "<apis>"]}' 0.0.0.0:8000
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_startWS", "params": ["<host>", < port number>, "<cors>", "<apis>"]}' 0.0.0.0:8000
				
			

4.7 admin_stopRPC
Function to close the currently open HTTP RPC endpoint, since a node can only have a single HTTP endpoint thus no parameters are required.  

Client

Method invocation

JS console

				
					admin.stopRPC()
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_stopRPC"}' 0.0.0.0:8000
				
			

4.8 admin_stopWS
Function to close the currently open WebSocket RPC endpoint, since a node can only have a single WebSocket endpoint no parameters are required.  

Client

Method invocation

JS console

				
					admin.stopWS()
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "admin_stopWS"}' 0.0.0.0:8000
				
			

5. Personal

5.1 personal_listAccounts
Function to return all Cypherium account addresses of all keys in the key store

Client

Method invocation

JS console

				
					personal.listAccounts()
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_listAccounts"}' 0.0.0.0:8000
				
			

5.2 personal_lockAccount
Function to remove the private key with the given address parameter from memory, the account can no longer be used to send transactions.

Client

Method invocation

JS console

				
					personal.lockAccount("<address>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_lockAccount", "params": ["<address>"]}' 0.0.0.0:8000
				
			

5.3 personal_newAccount
Function to generate a new account based on the supplied passphrase (when a passphrase is not supplied in JS Console mode the method will ask to enter a passphrase). The method returns the address of the new account.
Note that a new key file is created and encrypted with the supplied passphrase.

Client

Method invocation

JS console

				
					personal.newAccount("<passphrase>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_newAccount", "params": ["<passphrase>"]}' 0.0.0.0:8000
				
			

5.4 personal_unlockAccount
Function to unlock an account “globally” so it can be used for multiple calls (for example personal_sendTransaction only unlocks an account for a single transaction).
The account is unlocked for a specific period of time (the default is 300 seconds) its also possible to set the timeout to 0, in that case the account will be locked when geth exits (when the miner exits).
Note that JS Console mode will prompt for a passphrase in case it has not been passed as a parameter (the RPC mode requires it to be set). 
<address> mandatory
<passphrase> mandatory for RPC mode, optional for console mode
<duration> (in seconds) optional, note that it is possible to skip the passphrase and specify a duration in JS Console mode, in that case specify null for the passphrase (without quotes)

Client

Method invocation

JS console

				
					personal.unlockAccount("<address>", "<passphrase>", <duration>)
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_unlockAccount", "params": ["<address>", "<passphrase>", <duration>]}' 0.0.0.0:8000
				
			

5.5 personal_sendTransaction

Submitting a transaction to the Cypherium network can be done in a couple of ways where JS Console mode and JSON-RPC mode differ a bit more then we have seen thus far.

Let’s start with JS Console mode, the main difference (and advantage for ad-hoc cli use) is the ability to use common JavaScript “magic”, for example its possible (and good practice) to define a transaction as a variable in the JS Console and referring to this variable when making the call to the transaction method.
Another convenient extra is the ability to use the “toWei” conversion function in web3c this makes it a bit easier to set a correct value for your transaction.

for example:
Start with defining the transaction variable

				
					var tx = {from: "<from address>", to: "<to address>", gas: <units of gas >, gasPrice: <wei unit price of gas>, value: web3c.toWei(<amount of CPH to send>, "cpher")}
				
			

And then calling the function

				
					personal.sendTransaction(tx, "<passphrase>")
				
			

Note that the equivalent transaction without the use of web3c helper function would be something like:

				
					var tx = {from: "<from address>", to: "<to address>", gas: "<units of gas>", gasPrice: "<wei unit price of gas>", value: "<amount of wei to send>"}     
				
			

And now for the JSON-RPC equivalent, the JSON-RPC call is structured slightly differently since it does not have access to the helper functions of web3c, so all numbers need to be in hexadecimal (and keep in mind that the gasPrice and value are in Wei)

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_sendTransaction", "params": [{ "from": "<from address>",  "to": "<to address>",  "gas": "<units of gas in hexadecimal>" , "gasPrice": "<wei unit price of gas in hexadecimal>", "value": "<amount of wei to send in hexadecimal>" }, "<sender passphrase>"]}' 0.0.0.0:8000
				
			
Client

Method invocation

JS console

				
					var tx = {from: "<from address>", to: "<to address>", gas: <units of gas >, gasPrice: <wei unit price of gas>, value: web3c.toWei(<amount of CPH to send>, "cpher")}

personal.sendTransaction(tx, "<passphrase>")

				
			
				
					var tx = {from: "<from address>", to: "<to address>", gas: <units of gas >, gasPrice: <wei unit price of gas>, value: <amount of wei to send>}     

personal.sendTransaction(tx, "<passphrase>")

				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_sendTransaction ", "params": [{ "from": "<from address>",  "to": "<to address>",  "gas": "<units of gas in hexadecimal>" , "gasPrice": "<wei unit price of gas in hexadecimal>", "value": "<amount of wei to send in hexadecimal>"}, "<sender passphrase>"]}' 0.0.0.0:8000
				
			

6. TXpool

6.1 txpool_content
Function to query the content inspection property in order to list the exact details of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are only being scheduled for future execution.
The returned object contains two fields “pending” and “queued”, each of these fields are associative arrays in which each entry maps an origin-address to a batch of scheduled transactions.
These batches themselves are maps associating nonces with actual transactions.

Please note, there may be multiple transactions associated with the same account and nonce. This can happen if the user broadcast multiple ones with varying gas allowances (or even completely different transactions).

Client

Method invocation

JS console

				
					txpool.content
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "txpool_content"}' 0.0.0.0:8000
				
			

6.2 txpool_inspect
Function to query the inspect inspection property in order to retrieve a textual summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are only being scheduled for future execution.
The result is an object with two fields “pending” and “queued”. Each of these fields are associative arrays, in which each entry maps an origin-address to a batch of scheduled transactions.
These batches themselves are maps associating nonces with transactions summary strings.

Please note, there may be multiple transactions associated with the same account and nonce. This can happen if the user broadcast multiple ones with varying gas allowances (or even completely different transactions).

Client

Method invocation

JS console

				
					txpool.inspect
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "txpool_inspect"}' 0.0.0.0:8000
				
			

6.3 txpool_status
Function to query the status inspection property in order to find the number of transactions that are currently pending for inclusion in the next block(s), as well as the ones that are being only scheduled for future execution.
The result is an object with two fields “pending” and “queued”, each of which is a counter representing the number of transactions in that particular state.

Client

Method invocation

JS console

				
					txpool.status
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "txpool_status"}' 0.0.0.0:8000
				
			

7. CPH

7.1 cph_syncing
Function to query the current syncing state.
returns a Boolean value, true for syncing and false for not syncing.

Client

Method invocation

JS console

				
					cph.syncing
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_syncing"}' 0.0.0.0:8000
				
			

7.2 cph_coinbase
Function to return the current coinbase address.

Client

Method invocation

JS console

				
					cph.coinbase
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_coinbase"}' 0.0.0.0:8000
				
			

7.3 cph_hashrate
Function to return the miners number of hashes per second.

Client

Method invocation

JS console

				
					cph.hashrate
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_hashrate"}' 0.0.0.0:8000
				
			

7.4 cph_accounts
Function to return the miners current list of addresses.

Client

Method invocation

JS console

				
					cph.accounts
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_accounts"}' 0.0.0.0:8000
				
			

7.5 cph_txBlockNumber
Function to return the most recent transaction block number.

Client

Method invocation

JS console

				
					cph.txBlockNumber
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_txBlockNumber"}' 0.0.0.0:8000
				
			

7.6 cph_keyBlockNumber
Function to return the most recent key block number.

Client

Method invocation

JS console

				
					cph.keyBlockNumber
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_keyBlockNumber"}' 0.0.0.0:8000
				
			

7.7 cph_gasPrice
Function to return the current price per unit of gas.

Client

Method invocation

JS console

				
					cph.gasPrice
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_gasPrice"}' 0.0.0.0:8000
				
			

7.8 cph_getBalance
Function to return the balance of the passed address in wei.

Client

Method invocation

JS console

				
					cph.getBalance("<address>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getBalance", "params": ["<address>", "latest"]}' 0.0.0.0:8000
				
			

7.9 cph_getStorageAt
Function to return the value from a storage position at a given address

Client

Method invocation

JS console

				
					JS Console	cph.getStorageAt("<storage address in hexadecimal>", <integer position in storage>, <tag integer block number or "latest", "earliest", "pending">)
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getStorageAt", "params": ["<storage address in hexadecimal>", "<hexadecimal position in storage>", "<hexadecimal tag block number or "latest", "earliest", "pending">"]}' 0.0.0.0:8000
				
			

7.10 cph_getTransactionCount
Function to return the number of transactions send from an address.

Client

Method invocation

JS console

				
					cph.getTransactionCount ("<address>", <tag integer block number or "latest", "earliest", "pending">)
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getTransactionCount", "params": ["<address>", "<hexadecimal tag block number or "latest", "earliest", "pending">"]}' 0.0.0.0:8000
				
			

7.11 cph_getCode
Function to return the code stored at the given address in the state for the given block number.
Note that the JSON-RPC mode expects a hexadecimal block number

Client

Method invocation

JS console

				
					cph.getCode("<address>", "<tag block number or "latest", "earliest", "pending">")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getCode", "params": ["<address>", "<hexadecimal tag block number or "latest", "earliest", "pending">"]}' 0.0.0.0:8000
				
			

7.12 cph_sendTransaction
Function to execute a transaction or contract creation (if the data field contains code) this function is quite similar to personal_sendTransaction since it needs the account to be unlocked first with personal.unlockAccount (JS Console mode) or personal_unlockAccount (JSON-RPC mode)
The main difference is that value is optional (when the data field is used) and that the data field allows for contract deployment (compiled contract code)

Client

Method invocation

JS console

				
					var obj = {from: "<from address>", to: "<to address>", gas: <units of gas >, gasPrice: <wei unit price of gas>, value: web3c.toWei(<amount of CPH to send>, "cpher"), data: "<compiled contract code>"}

personal.unlockAccount("<from address>", "<passphrase>", <duration>)
cph.sendTransaction(obj)

				
			
				
					var obj = {from: "<from address>", to: "<to address>", gas: <units of gas>, gasPrice: <wei unit price of gas >, value: <amount of wei to send>, data: "<compiled contract code>"}     

personal.unlockAccount("<from address>", "<passphrase>", <duration>)
cph.sendTransaction(obj)

				
			

JSON-RPC

				
					var obj = {from: "<from address>", to: "<to address>", gas: <units of gas>, gasPrice: <wei unit price of gas >, value: <amount of wei to send>, data: "<compiled contract code>"}     

personal.unlockAccount("<from address>", "<passphrase>", <duration>)
cph.sendTransaction(obj)

				
			

7.13 cph_sendRawTransaction
Function to add a signed transaction (the “raw” part or RLP encoded transaction) to the transaction pool.
Note that the sender is responsible for signing the transaction and using the correct nonce.
use this after signing the transaction with cph_signTransaction (see 7.19)

Client

Method invocation

JS console

				
					cph.sendRawTransaction("<raw RLP encoded transaction>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_ sendRawTransaction", "params": ["<raw RLP encoded transaction>"]}' 0.0.0.0:8000
				
			

7.14 cph_getTransactionReceipt
Function to return transaction receipt (information about a transaction like used gas and originating address) by passing in the transaction hash.

Client

Method invocation

JS console

				
					cph.getTransactionReceipt("<transaction hash>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getTransactionReceipt", "params": ["<transaction hash>"]}' 0.0.0.0:8000
				
			

7.15 cph_call
Function to execute a new message call transaction, which is directly executed in the VM of the node, but the transaction is not created (mined) on the blockchain.
The blockNumber selects the block height at which the call runs. It can be nil; in which case the code is taken from the latest known block.

Client

Method invocation

JS console

				
					var obj = {from: "<from address>", to: "<to address>", gas: <units of gas >, gasPrice: <wei unit price of gas >, value: web3c.toWei(<amount of CPH to send>, "cpher"), data: "<compiled contract code>"}

cph.call("<obj>", "<tag block number or "latest", "earliest", "pending">")

				
			
				
					var obj = {from: "<from address>", to: "<to address>", gas: <units of gas>, gasPrice: <wei unit price of gas>, value: "<amount of wei to send>", data: "<compiled contract code>"}
cph.call("<obj>", "<tag block number or "latest", "earliest", "pending">")

				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_call", "params": ["from": "<from address>",  "to": "<to address>",  "gas": "<units of gas in hexadecimal>" , "gasPrice": "<wei unit price of gas in hexadecimal>", "value": "<amount of wei to send in hexadecimal>", "data": "<compiled contract code>"]}' 0.0.0.0:8000
				
			

7.16 cph_getTxBlockByNumber
Function to retrieve information about a transaction block by transaction block hash.
when inclTx is true the returned block shows transaction hashes within the transaction block
when fullTx is true all transactions within the transaction block are returned in full

Client

Method invocation

JS console

				
					cph.getTxBlockByNumber(<transaction block number>, <boolean incTx>, <Boolean fullTx>)
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getTxBlockByNumber", "params": ["<hexadecimal transaction block number>", <boolean incTx>, <Boolean fullTx>]}' 0.0.0.0:8000
				
			

7.17 cph_getKeyBlockByHash
Function to retrieve information about a key block by key block hash.

Client

Method invocation

JS console

				
					cph.getKeyBlockByHash("<key block hash>")
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getKeyBlockByHash", "params": ["<key block hash>"]}' 0.0.0.0:8000
				
			

7.18 cph_getKeyBlockByNumber
Function to retrieve information about a key block by key block number.

Client

Method invocation

JS console

				
					cph.getKeyBlockByNumber(<key block number>)
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_getKeyBlockByNumber", "params": ["<hexadecimal key block number>"]}' 0.0.0.0:8000
				
			

7.19 cph_signTransaction
Function that returns a signed Cypherium transaction that can that can be submitted to the network at a later time by using cph_sendRawTransaction by passing in the “raw” RLP encoded transaction.

Client

Method invocation

JS console

				
					JS Console	var obj = {from: "<from address>", to: "<to address>", gas: <units of gas >, gasPrice: <wei unit price of gas>, value: web3c.toWei(<amount of CPH to send>, "cpher"), data: "<compiled contract code OR hash of the invoked method signature and encoded parameters refer to Contract ABI>", <nonce integer>}

personal.unlockAccount("<from address>", "<passphrase>", <duration>)
cph.signTransaction(obj)
	var obj = {from: "<from address>", to: "<to address>", gas: <units of gas>, gasPrice: <wei unit price of gas>, value: <amount of wei to send>, data: "<compiled contract code OR hash of the invoked method signature and encoded parameters refer to Contract ABI>", < nonce integer>}     

personal.unlockAccount("<from address>", "<passphrase>", <duration>)
cph.signTransaction(obj)

				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "personal_unlockAccount", "params": ["<from address>", "<passphrase>", <duration>]}' 0.0.0.0:8000

curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_signTransaction", "params": [{"from": "<from address>", "to": "<OPTIONAL to address>", "gas": "<units of gas in hexadecimal>" , "gasPrice": "<wei unit price of gas in hexadecimal>", "value": "<OPTIONAL amount of wei to send in hexadecimal>", "data": "<OPTIONAL compiled contract code OR hash of the invoked method signature and encoded parameters refer to Contract ABI as string>", "nonce": "<provide a valid nonce in hexadecimal>"}]}' 0.0.0.0:8000

				
			

7.27 cph_estimateGas
Function to estimate the amount of gas that is required to allow a transaction to complete.
The transaction will not be added to the blockchain.
Note that the estimate may be significantly higher than the amount of gas that is actually used by the transaction, this is caused by a variety of reasons and mainly related to the innerworkings of the EVM and node performance.

Client

Method invocation

JS console

				
					cph.estimateGas(data)
				
			

JSON-RPC

				
					curl -X POST -H "Content-Type: application/json" --data '{"id":"1", "method": "cph_ estimateGas", "params": […]}' 0.0.0.0:8000