ABEYChain Docs
Search
⌃K

Management API

The APIs supported by abeychain are mainly based on function modules: admin, miner, personal, etc. These APIs are provided using JSON-RPC.

Enabling the management APIs

gabey comes with a JavaScript console that supports all of the APIs described here. To provide these APIs through gabey RPC, specify them with the --${interface}api command line argument. Where ${interface} can be HTTP rpc, WebSocket ws and Unix socket ipc or Windows pipe
For example: gabey --ipcapi admin, abey,miner --rpc api abey,web3 --rpc
  1. 1.
    Enable administrators, official DApp and miner APIs via IPC interface
  2. 2.
    Enable official DApp and web3 API via HTTP interface
The HTTP RPC interface must be explicitly enabled using the --rpc flag.
Please note, offering an API over the HTTP (rpc) or WebSocket (ws) interfaces will give everyone access to the APIs who can access this interface (DApps, browser tabs, etc). Be careful which APIs you enable. By default gabey enables all APIs over the IPC (ipc) interface and only the db, abey, net and web3 APIs over the HTTP and WebSocket interfaces.
To determine which APIs an interface provides, the modules JSON-RPC method can be invoked. For example over an ipc interface on unix systems:
echo '{"jsonrpc":"2.0","method":"rpc_modules","params":[],"id":1}' | nc -U $datadir/gabey.ipc
will give all enabled modules including the version number:
{
"id":1,
"jsonrpc":"2.0",
"result":{
"admin":"1.0",
"debug":"1.0",
"abey":"1.0",
"miner":"1.0",
"net":"1.0",
"personal":"1.0",
"rpc":"1.0",
"txpool":"1.0",
"web3":"1.0"
}
}

API List

​admin​
​debug​
​miner​
​personal​
​Txpool​
​fruitpool​
​abey​
​addPeer​
​backtraceAt​
​setExtra​
​listAccounts​
​content​
​content​
​protocolVersion​
​datadir​
​blockProfile​
​setGasPrice​
​lockAccount​
​inspect​
​inspect​
​syncing​
​nodeInfo​
​cpuProfile​
​start​
​newAccount​
​status​
​status​
​coinbase​
​peers​
​dumpBlock​
​stop​
​unlockAccount​
​
​
​mining​
​startRPC​
​gcStats​
​setCoinbase​
​sign​
​
​
​hashrate​
​startWS​
​getBlockRlp​
​setElection​
​ecRecover​
​
​
​gasPrice​
​stopRPC​
​goTrace​
​
​
​
​
​accounts​
​stopWS​
​memStats​
​
​
​
​
​blockNumber​
​
​seedHash​
​
​
​
​
​getBalance​
​
​setHead​
​
​
​
​
​getStorageAt​
​
​setBlockProfileRate​
​
​
​
​
​getTransactionCount​
​
​stacks​
​
​
​
​
​getBlockTransactionCount​
​
​startCPUProfile​
​
​
​
​
​getCode​
​
​startGoTrace​
​
​
​
​
​sign​
​
​stopCPUProfile​
​
​
​
​
​sendTransaction​
​
​stopGoTrace​
​
​
​
​
​sendRawTransaction​
​
​traceBlock​
​
​
​
​
​call​
​
​traceBlockByNumber​
​
​
​
​
​estimateGas​
​
​traceBlockByHash​
​
​
​
​
​getBlock​
​
​traceBlockFromFile​
​
​
​
​
​getTransaction​
​
​traceTransaction​
​
​
​
​
​getTransactionReceipt​
​
​verbosity​
​
​
​
​
​compile​
​
​vmodule​
​
​
​
​
​getWork​
​
​writeBlockProfile​
​
​
​
​
​defaultBlock​
​
​writeMemProfile​
​
​
​
​
​pendingTransactions​
​
​
​
​
​
​
​fruitNumber​
​
​
​
​
​
​
​rewardSnailBlock​
​
​
​
​
​
​
​snailBlockNumber​
​
​
​
​
​
​
​getCommittee​
​
​
​
​
​
​
​committeeNumber​
​
​
​
​
​
​
​getCurrentState​
​
​
​
​
​
​
​getFruit​
​
​
​
​
​
​
​getRewardBlock​
​
​
​
​
​
​
​getSnall​
​
​
​
​
​
​
​snailBlockNumber​

Admin

The admin API gives you access to several non-standard RPC methods, which will allow you to have a fine grained control over your gabey instance, including but not limited to network peer and RPC endpoint management.

admin_addPeer

The addPeer administrative method requests adding a new remote node to the list of tracked static nodes. The node will try to maintain connectivity to these nodes at all times, reconnecting every once in a while if the remote connection goes down.
The method accepts a single argument, the enode URL of the remote peer to start tracking and returns a BOOL indicating whether the peer was accepted for tracking or some error occurred.
Client
Method invocation
Go
admin.AddPeer(url string) (bool, error)
Console
admin.addPeer(url)
RPC
{"method": "admin_addPeer", "params": [url]}

Example

> admin.addPeer("enode://0adc97d2046e0b96956feed699b92fc34d2e5ba1f7ab411c884786ded213f70c0e78f0acce7a548ab32e1c2a817[email protected]:30313")
true

admin_datadir

The datadir administrative property can be queried for the absolute path the running gabey node currently uses to store all its databases.
Client
Method invocation
Go
admin.Datadir() (string, error)
Console
admin.datadir
RPC
{"method": "admin_datadir"}

Example

> admin.datadir
"/home/abeychain/go-abey/cmd/gabey/data"

admin_nodeInfo

The nodeInfo administrative property can be queried for all the information known about the running gabey node at the networking granularity. These include general information about the node itself as a participant of the P2P overlay protocol, as well as specialized information added by each of the running application protocols (e.g. abey, les, shh).
Client
Method invocation
Go
admin.NodeInfo() (*p2p.NodeInfo, error)
Console
admin.nodeInfo
RPC
{"method": "admin_nodeInfo"}

Example

> admin.nodeInfo
{
enode: "enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@[::]:30303",
id: "44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d",
ip: "::",
listenAddr: "[::]:30303",
name: "gabey/v0.7.2-unstable-46f28475/linux-amd64/go1.10.1",
ports: {
discovery: 30303,
listener: 30303
},
protocols: {
abey: {
difficulty: null,
genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
head: "0xb83f73fbe6220c111136aefd27b160bf4a34085c65ba89f24246b3162257c36a",
network: 20
}
}
}

admin_peers

You can query the peers property for information about all remote nodes that are connected.
Client
Method invocation
Go
admin.Peers() ([]*p2p.PeerInfo, error)
Console
admin.peers
RPC
{"method": "admin_peers"}

Example

> admin.peers
[{
caps: ["abey/61", "abey/62", "abey/63"],
id: "08a6b39263470c78d3e4f58e3c997cd2e7af623afce64656cfc56480babcea7a9138f3d09d7b9879344c2d2e457679e3655d4b56eaff5fd4fd7f147bdb045124",
name: "gabey/v0.7.2-unstable-46f28475/linux-amd64/go1.10.1",
network: {
localAddress: "192.168.0.104:51068",
remoteAddress: "71.62.31.72:30303"
},
protocols: {
abey: {
difficulty: null,
head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
version: 63
}
}
}, /* ... */ {
caps: ["abey/61", "abey/62", "abey/63"],
id: "fcad9f6d3faf89a0908a11ddae9d4be3a1039108263b06c96171eb3b0f3ba85a7095a03bb65198c35a04829032d198759edfca9b63a8b69dc47a205d94fce7cc",
name: "gabey/v0.7.2-unstable-46f28475/linux-amd64/go1.10.1",
network: {
localAddress: "192.168.0.104:55968",
remoteAddress: "121.196.232.205:30303"
},
protocols: {
abey: {
difficulty: null,
head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
version: 63
}
}
}]

admin_startRPC

The startRPC administrative method starts an HTTP based JSON RPC API webserver to handle client requests. All the parameters are optional:
  • host: network interface to open the listener socket on (defaults to "localhost")
  • port: network port to open the listener socket on (defaults to 8545)
  • cors: cross-origin resource sharing header to use (defaults to "")
  • apis: API modules to offer over this interface (defaults to "abey,net,web3")
The method returns a boolean flag specifying whether the HTTP RPC listener was opened or not. Please note, only one HTTP endpoint is allowed to be active at any time.
Client
Method invocation
Go
admin.StartRPC(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error)
Console
admin.startRPC(host, port, cors, apis)
RPC
{"method": "admin_startRPC", "params": [host, port, cors, apis]}

Example

> admin.startRPC("127.0.0.1", 8545)
true

admin_startWS

The startWS administrative method starts an WebSocket based JSON RPC API webserver to handle client requests. All the parameters are optional:
  • host: network interface to open the listener socket on (defaults to "localhost")
  • port: network port to open the listener socket on (defaults to 8546)
  • cors: cross-origin resource sharing header to use (defaults to "")
  • apis: API modules to offer over this interface (defaults to "abey,net,web3")
The method returns a boolean flag specifying whether the WebSocket RPC listener was opened or not. Please note, only one WebSocket endpoint is allowed to be active at any time.
Client
Method invocation
Go
admin.StartWS(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error)
Console
admin.startWS(host, port, cors, apis)
RPC
{"method": "admin_startWS", "params": [host, port, cors, apis]}

Example

> admin.startWS("127.0.0.1", 8546)
true

admin_stopRPC

The stopRPC administrative method closes the currently open HTTP RPC endpoint. As the node can only have a single HTTP endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
Client
Method invocation
Go
admin.StopRPC() (bool, error)
Console
admin.stopRPC()
RPC
{"method": "admin_stopRPC"

Example

> admin.stopRPC()
true

admin_stopWS

The stopWS administrative method closes the currently open WebSocket RPC endpoint. As the node can only have a single WebSocket endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
Client
Method invocation
Go
admin.StopWS() (bool, error)
Console
admin.stopWS()
RPC
{"method": "admin_stopWS"

Example

> admin.stopWS()
true

Miner

The miner API allows you to remote control the node's mining operation and set various mining specific settings.

miner_setExtra

Sets the extra data string that is included when this miner mines a block.
Client
Method invocation
Go
miner.setExtra(extra string) (bool, error)
Console
miner.setExtra(string)
RPC
{"method": "miner_setExtra", "params": [string]}

Example

> miner.setExtra("it's my block")
true

miner_setGasPrice

Sets the minimal accepted gas price when mining transactions. Any transactions that are below this limit are excluded from the mining process.
Client
Method invocation
Go
miner.setGasPrice(number *rpc.HexNumber) bool
Console
miner.setGasPrice(number)
RPC
{"method": "miner_setGasPrice", "params": [number]}

Example

> miner.setGasPrice(10000000)
true

miner_start

Start the CPU mining process with the given number of threads and generate a new DAG if need be.
Client
Method invocation
Go
miner.Start(threads *rpc.HexNumber) (bool, error)
Console
miner.start(number)
RPC
{"method": "miner_start", "params": [number]}

Example

> miner.start(8)
null

miner_stop

Stop the CPU mining operation.
Client
Method invocation
Go
miner.Stop() bool
Console
miner.stop()
RPC
{"method": "miner_stop", "params": []}

Example

> miner.stop()
true

miner_setCoinbase

Sets the coinbase, where mining rewards will go.
Client
Method invocation
Go
miner.Setcoinbase(common.Address) bool
Console
miner.setCoinbase(address)
RPC
{"method": "miner_setcoinbase", "params": [address]}

Example

> miner.setCoinbase("0xbe7e39fa0645f6eaf501ad02318a7fda5c4df6c6")
true

miner_setElection

Sets the election,To vote or not to vote
Client
Method invocation
Go
miner.SetElection(toElect bool, pubkey []byte) (bool, error)
Console
miner.setElection(toElect,pubkey)
RPC
{"method": "miner_setElection", "params": [toElect,pubkey]}

Example

> miner.setElection(true,"0x04044308742b61976de7344edb8662d6d10be1c477dd46e8e4c433c1288442a79183480894107299ff7b0706490f1fb9c9b7c9e62ae62d57bd84a1e469460d8ac1")
true

Personal

personal_listAccounts

Returns all the abeychain account addresses of all keys in the key store.
Client
Method invocation
Console
personal.listAccounts
RPC
{"method": "personal_listAccounts", "params": []}

Example

> personal.listAccounts
["0xbe7e39fa0645f6eaf501ad02318a7fda5c4df6c6", "0xaf1dd3a5135bcdd38079927a80c75ad05cfd140b", "0x4a98debf425a2fd4f56ef6674c72c3606b615e75"]

personal_lockAccount

Removes the private key with given address from memory. The account can no longer be used to send transactions.
Client
Method invocation
Console
personal.lockAccount(address)
RPC
{"method": "personal_lockAccount", "params": [string]}

Example

> personal.lockAccount("0xbe7e39fa0645f6eaf501ad02318a7fda5c4df6c6")
true

personal_newAccount

Generates a new private key and stores it in the key store directory. The key file is encrypted with the given passphrase. Returns the address of the new account.
At the gabey console, newAccount will prompt for a passphrase when it is not supplied as the argument.
Client
Method invocation
Console
personal.newAccount()
RPC
{"method": "personal_newAccount", "params": [string]}

Example

> personal.newAccount()
Passphrase:
Repeat passphrase:
"0x5e97870f263700f46aa00d967821199b9bc5a120"
The passphrase can also be supplied as a string.
> personal.newAccount("h4ck3r")
"0x3d80b31a78c30fc628f20b2c89d7ddbf6e53cedc"

personal_unlockAccount

Decrypts the key with the given address from the key store.
Both passphrase and unlock duration are optional when using the JavaScript console. If the passphrase is not supplied as an argument, the console will prompt for the passphrase interactively.
The unencrypted key will be held in memory until the unlock duration expires. If the unlock duration defaults to 300 seconds. An explicit duration of zero seconds unlocks the key until gabey exits.
The account can be used with abey_sign and abey_sendTransaction while it is unlocked.
Client
Method invocation
Console
personal.unlockAccount(address, passphrase, duration)
RPC
{"method": "personal_unlockAccount", "params": [string, string, number]}

Examples

> personal.unlockAccount("0x5e97870f263700f46aa00d967821199b9bc5a120")
Unlock account 0x5e97870f263700f46aa00d967821199b9bc5a120
Passphrase:
true
Supplying the passphrase and unlock duration as arguments:
> personal.unlockAccount("0x5e97870f263700f46aa00d967821199b9bc5a120", "foo", 30)
true
If you want to type in the passphrase and stil override the default unlock duration, pass null as the passphrase.
> personal.unlockAccount("0x5e97870f263700f46aa00d967821199b9bc5a120", null, 30)
Unlock account 0x5e97870f263700f46aa00d967821199b9bc5a120
Passphrase:
true

personal_sendTransaction

Validate the given passphrase and submit transaction.
The transaction is the same argument as for abey_sendTransaction and contains the fromaddress. If the passphrase can be used to decrypt the private key belogging to tx.from the transaction is verified, signed and send onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.
Client
Method invocation
Console
personal.sendTransaction(tx, passphrase)
RPC
{"method": "personal_sendTransaction", "params": [tx, string]}

Examples

> var tx = {from: "0x391694e7e0b0cce554cb130d723a9d27458f9298", to: "0xafa3f8684e54059998bc3a7b0d2b0da075154d66", value: web3.toWei(1.23, "abey")}
undefined
> personal.sendTransaction(tx, "passphrase")
0x8474441674cdd47b35b875fd1a530b800b51a5264b9975fb21129eeb8c18582f

personal_sign

The sign method calculates an abeychain specific signature with:sign(keccack256("\x19abeychain Signed Message:\n" + len(message) + message))).
By adding a prefix to the message makes the calculated signature recognisable as an abeychain specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.
See ecRecover to verify the signature.
Client
Method invocation
Console
personal.sign(message, account, [password])
RPC
{"method": "personal_sign", "params": [message, account, password]}

Examples

> personal.sign("0xdeadbeaf", "0xbe7e39fa0645f6eaf501ad02318a7fda5c4df6c6", "")
"0x0d7d2150b38dc30ba0aa8db9171abb1bd31b6cf39f4edf2b93de0a2b6ba05a81034aa81b462fb5b8b09c74dba29172c9ad098607d7898a3aa8412b40ef2686841b"

personal_ecRecover

ecRecover returns the address associated with the private key that was used to calculate the signature in personal_sign.
Client