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
Enable administrators, official DApp and miner APIs via IPC interface
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:
will give all enabled modules including the version number:
API List
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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
admin_peers
You can query the peers property for information about all remote nodes that are connected.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
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 to8545
)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 |
|
Console |
|
RPC |
|
Example
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 to8546
)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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
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 |
|
Console |
|
RPC |
|
Example
miner_stop
Stop the CPU mining operation.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
miner_setCoinbase
Sets the coinbase, where mining rewards will go.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
miner_setElection
Sets the election,To vote or not to vote
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
Personal
personal_listAccounts
Returns all the abeychain account addresses of all keys in the key store.
Client | Method invocation |
Console |
|
RPC |
|
Example
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 |
|
RPC |
|
Example
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 |
|
RPC |
|
Example
The passphrase can also be supplied as a string.
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 |
|
RPC |
|
Examples
Supplying the passphrase and unlock duration as arguments:
If you want to type in the passphrase and stil override the default unlock duration, pass null
as the passphrase.
personal_sendTransaction
Validate the given passphrase and submit transaction.
The transaction is the same argument as for abey_sendTransaction
and contains the from
address. 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 |
|
RPC |
|
Examples
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 |
|
RPC |
|
Examples
personal_ecRecover
ecRecover
returns the address associated with the private key that was used to calculate the signature in personal_sign
.
Client | Method invocation |
Console |
|
RPC |
|
Examples
Txpool
The txpool
API gives you access to several non-standard RPC methods to inspect the contents of the transaction pool containing all the currently pending transactions as well as the ones queued for future processing.
txpool_content
Content returns the transactions contained within the transaction pool.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
txpool_inspect
The inspect
inspection property can be queried to list a textual summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only. This is a method specifically tailored to developers to quickly see the transactions in the pool and find any potential issues.
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 mutliple ones with varying gas allowances (or even complerely different transactions).
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
txpool_status
The status
inspection property can be queried for the number of transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.
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 |
Go |
|
Console |
|
RPC |
|
Example
Fruitpool
fruitpool_content
Content returns the pendingFruits contained within the snail pool.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
fruitpool_inspect
Inspect returns the unVerifiedFruits contained within the snail pool.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
fruitpool_status
Status returns the number of pending and unVerified Fruits in the pool.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
Debug
The debug
API gives you access to several non-standard RPC methods, which will allow you to inspect, debug and set certain debugging flags during runtime.
debug_backtraceAt
Sets the logging backtrace location. When a backtrace location is set and a log message is emitted at that location, the stack of the goroutine executing the log statement will be printed to stderr.
The location is specified as <filename>:<line>
.
Client | Method invocation |
Console |
|
RPC |
|
Example:
debug_blockProfile
Turns on block profiling for the given duration and writes profile data to disk. It uses a profile rate of 1 for most accurate information. If a different rate is desired, set the rate and write the profile manually using debug_writeBlockProfile
.
Client | Method invocation |
Console |
|
RPC |
|
debug_cpuProfile
Turns on CPU profiling for the given duration and writes profile data to disk.
Client | Method invocation |
Console |
|
RPC |
|
debug_dumpBlock
Retrieves the state that corresponds to the block number and returns a list of accounts (including storage and code).
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
debug_gcStats
Returns GC statistics.
See https://golang.org/pkg/runtime/debug/#GCStats for information about the fields of the returned object.
Client | Method invocation |
Console |
|
RPC |
|
debug_getBlockRlp
Retrieves and returns the RLP encoded block by number.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
debug_goTrace
Turns on Go runtime tracing for the given duration and writes trace data to disk.
Client | Method invocation |
Console |
|
RPC |
|
debug_memStats
Returns detailed runtime memory statistics.
See https://golang.org/pkg/runtime/#MemStats for information about the fields of the returned object.
Client | Method invocation |
Console |
|
RPC |
|
debug_seedHash
Fetches and retrieves the seed hash of the block by number
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
debug_setHead
Sets the current head of the local snail chain by snailBlock number. Note, this is a destructive action and may severely damage your snail chain. Use with extreme caution.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
warn: it may cause the console quit and may destory the database,just for debug and test.
debug_setBlockProfileRate
Sets the rate (in samples/sec) of goroutine block profile data collection. A non-zero rate enables block profiling, setting it to zero stops the profile. Collected profile data can be written using debug_writeBlockProfile
.
Client | Method invocation |
Console |
|
RPC |
|
debug_stacks
Returns a printed representation of the stacks of all goroutines. Note that the web3 wrapper for this method takes care of the printing and does not return the string.
Client | Method invocation |
Console |
|
RPC |
|
debug_startCPUProfile
Turns on CPU profiling indefinitely, writing to the given file.
Client | Method invocation |
Console |
|
RPC |
|
debug_startGoTrace
Starts writing a Go runtime trace to the given file.
Client | Method invocation |
Console |
|
RPC |
|
debug_stopCPUProfile
Stops an ongoing CPU profile.
Client | Method invocation |
Console |
|
RPC |
|
debug_stopGoTrace
Stops writing the Go runtime trace.
Client | Method invocation |
Console |
|
RPC |
|
debug_traceBlock
The traceBlock
method will return a full stack trace of all invoked opcodes of all transaction that were included included in this block. Note, the parent of this block must be present or it will fail.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
debug_traceBlockByNumber
Similar to debug_traceBlock, traceBlockByNumber
accepts a block number and will replay the block that is already present in the database.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
debug_traceBlockByHash
Similar to debug_traceBlock, traceBlockByHash
accepts a block hash and will replay the block that is already present in the database.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
debug_traceBlockFromFile
Similar to debug_traceBlock, traceBlockFromFile
accepts a file containing the RLP of the block.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
debug_traceTransaction
The traceTransaction
debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.
In addition to the hash of the transaction you may give it a secondary optional argument, which specifies the options for this specific call. The possible options are:
disableStorage
:BOOL
. Setting this to true will disable storage capture (default = false).disableMemory
:BOOL
. Setting this to true will disable memory capture (default = false).disableStack
:BOOL
. Setting this to true will disable stack capture (default = false).tracer
:STRING
. Setting this will enable JavaScript-based transaction tracing, described below. If set, the previous four arguments will be ignored.timeout
:STRING
. Overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Valid values are described here.
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
JavaScript-based tracing
Specifying the tracer
option in the second argument enables JavaScript-based tracing. In this mode, tracer
is interpreted as a JavaScript expression that is expected to evaluate to an object with (at least) two methods, named step
and result
.
step
is a function that takes two arguments, log and db, and is called for each step of the EVM, or when an error occurs, as the specified transaction is traced.
log
has the following fields:
pc
: Number, the current program counterop
: Object, an OpCode object representing the current opcodegas
: Number, the amount of gas remaininggasPrice
: Number, the cost in wei of each unit of gasmemory
: Object, a structure representing the contract's memory spacestack
: array[big.Int], the EVM execution stackdepth
: The execution depthaccount
: The address of the account executing the current operationerr
: If an error occured, information about the error
If err
is non-null, all other fields should be ignored.
For efficiency, the same log
object is reused on each execution step, updated with current values; make sure to copy values you want to preserve beyond the current call. For instance, this step function will not work:
But this step function will:
log.op
has the following methods:
isPush()
- returns true if the opcode is a PUSHntoString()
- returns the string representation of the opcodetoNumber()
- returns the opcode's number
log.memory
has the following methods:
slice(start, stop)
- returns the specified segment of memory as a byte slicelength()
- returns the length of the memory
log.stack
has the following methods:
peek(idx)
- returns the idx-th element from the top of the stack (0 is the topmost element) as a big.Intlength()
- returns the number of elements in the stack
db
has the following methods:
getBalance(address)
- returns abig.Int
with the specified account's balancegetNonce(address)
- returns a Number with the specified account's noncegetCode(address)
- returns a byte slice with the code for the specified accountgetState(address, hash)
- returns the state value for the specified account and the specified hashexists(address)
- returns true if the specified address exists
The second function, 'result', takes no arguments, and is expected to return a JSON-serializable value to return to the RPC caller.
If the step function throws an exception or executes an illegal operation at any point, it will not be called on any further VM steps, and the error will be returned to the caller.
Note that several values are Golang big.Int objects, not JavaScript numbers or JS bigints. As such, they have the same interface as described in the godocs. Their default serialization to JSON is as a Javascript number; to serialize large numbers accurately call .String()
on them. For convenience, big.NewInt(x)
is provided, and will convert a uint to a Go BigInt.
Usage example, returns the top element of the stack at each CALL opcode only:
debug_verbosity
Sets the logging verbosity ceiling. Log messages with level up to and including the given level will be printed.
The verbosity of individual packages and source files can be raised using debug_vmodule
.
Client | Method invocation |
Console |
|
RPC |
|
debug_vmodule
Sets the logging verbosity pattern.
Client | Method invocation |
Console |
|
RPC |
|
Examples
If you want to see messages from a particular Go package (directory) and all subdirectories, use:
If you want to restrict messages to a particular package (e.g. p2p) but exclude subdirectories, use:
If you want to see log messages from a particular source file, use
You can compose these basic patterns. If you want to see all output from peer.go in a package below abey (abey/peer.go, abey/downloader/peer.go) as well as output from package p2p at level <= 5, use:
debug_writeBlockProfile
Writes a goroutine blocking profile to the given file.
Client | Method invocation |
Console |
|
RPC |
|
debug_writeMemProfile
Writes an allocation profile to the given file. Note that the profiling rate cannot be set through the API, it must be set on the command line using the --memprofilerate
flag.
Client | Method invocation |
Console |
|
RPC |
|
ABEY
abey_protocolVersion
Returns the current abeychain protocol version.
Client | Method invocation |
Console |
|
RPC |
|
abey_syncing
Returns an object with data about the sync status or false
Client | Method invocation |
Go |
|
Console |
|
RPC |
|
Example
abey_coinbase
Returns the client coinbase address.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_mining
Returns true
if client is actively mining new blocks.
Client | Method invocation |
Console |
|
RPC |
|
abey_hashrate
Returns the number of hashes per second that the node is mining with.
Client | Method invocation |
Console |
|
RPC |
|
abey_gasPrice
Returns the current price per gas in wei.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_accounts
Returns a list of addresses owned by client.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_blockNumber
Returns the number of most recent block.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getBalance
Returns the balance of the account of given address.integer of the current balance in wei.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getStorageAt
GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.
Client | Method invocation |
Go | `abey.getStorageAt(address,key,blockNr) (hexutil.Bytes, error) |
Console |
|
RPC |
|
Example
abey_getTransactionCount
GetTransactionCount returns the number of transactions the given address has sent for the given block number
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getBlockTransactionCount
Returns the number of transactions in a block matching the given block number.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getCode
Returns code at a given address. Divided into ordinary account and contract account address Ordinary account return "0x" Where the contract account returns the binary code
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_sign
The sign method calculates an abeychain specific signature with: sign(keccak256("\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.
Note the address to sign with must be unlocked.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
params:
Object - The transaction object from: DATA, 20 Bytes - The address the transaction is send from. to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to. gas: QUANTITY - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas. gasPrice: QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas value: QUANTITY - (optional) Integer of the value sent with this transaction data: DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see abeychain Contract ABI nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_sendRawTransaction
SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_call
Call executes the given transaction on the state for the given block number. It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
Parameters Object - The transaction call object from: DATA, 20 Bytes - (optional) The address the transaction is sent from. to: DATA, 20 Bytes - The address the transaction is directed to. gas: QUANTITY - (optional) Integer of the gas provided for the transaction execution. abey_call consumes zero gas, but this parameter may be needed by some executions. gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas value: QUANTITY - (optional) Integer of the value sent with this transaction data: DATA - (optional) Hash of the method signature and encoded parameters. For details see abeychain Contract ABI QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getBlock
Returns information about a block by hash or number
Client | Method invocation |
Console |
|
RPC |
|
Parameters can be integer of a block number,or hash of a block,or the string "earliest", "latest" or "pending".
Example
abey_getTransaction
Returns the information about a transaction requested by transaction hash
Client | Method invocation |
Console |
|
RPC |
|
abey_getTransactionReceipt
Returns the receipt of a transaction by transaction hash. Note That the receipt is not available for pending transactions.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_compile
Returns a list of available compilers in the client.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getWork
GetWork returns a work package for external miner. The work package consists of 3 strings result[0], 32 bytes hex encoded current block header pow-hash result[1], 32 bytes hex encoded seed hash used for DAG result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_defaultBlock
Return latest block marking
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_PendingTransactions
PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_committeeNumber
Return the current number of sessions of the committee
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_fruitNumber
Returns the height of the current fruit
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_rewardSnailBlock
RewardSnailBlock return the latest snail block rewarded.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_snailBlockNumber
SnailBlockNumber returns the block number of the snailchain head.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getCommittee
Returns information about the specified session of the committee
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getCurrentState
Returns the current membership of the committee
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getFruit
Returns the specified fruit information
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getRewardBlock
GetRewardBlock return the fast block position where the given snail block is rewarded.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_getSnail
Returns the requested snail block. When blockNr is -1 the chain head is returned.
Client | Method invocation |
Console |
|
RPC |
|
Example
abey_snailBlockNumber
SnailBlockNumber returns the block number of the snailchain head.
Client | Method invocation |
Console |
|
RPC |
|
Example
Last updated