You can start the HTTP JSON-RPC with the --rpc flag
gabey --rpc
change the default port (8545) and listing address (localhost) with:
gabey --rpc --rpcaddr <ip> --rpcport <portnumber>
If accessing the RPC from a browser, CORS will need to be enabled with the appropriate domain set. Otherwise, JavaScript calls are limit by the same-origin policy and requests will fail:
The following methods have an extra default block parameter:
When requests are made that act on the state of abeychain, the last default block parameter determines the height of the block.
The following options are possible for the defaultBlock parameter:
HEX String - an integer block number【
String "earliest" for the earliest/genesis block
String "latest" - for the latest mined block
String "pending" - for the pending state/transactions
Curl Examples Explained
The curl options below might return a response where the node complains about the content type, this is because the --data option sets the content type to application/x-www-form-urlencoded . If your node does complain, manually set the header by placing -H "Content-Type: application/json" at the start of the call.
The examples also do not include the URL/IP & port combination which must be the last argument given to curl e.x. 127.0.0.1:8545
JSON-RPC methods
-
JSON RPC API Reference
web3
web3_clientVersion
Returns the current client version.
Parameters
none
Returns
String - The current client version.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'
// Result
{
"id":67,
"jsonrpc":"2.0",
"result": "gabey/v1.1.0-unstable-d4c05e98/linux-amd64/go1.10"
}
web3_sha3
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
Parameters
DATA - the data to convert into a SHA3 hash.
Example Parameters
params: [
"0x68656c6c6f20776f726c64"
]
Returns
DATA - The SHA3 result of the given string.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c64"],"id":64}'
// Result
{
"id":64,
"jsonrpc": "2.0",
"result": "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
}
net
net_version
Returns the current network id.
Parameters
none
Returns
String - The current network id.
"19330": abeychain Mainnet
"18928": Testnet
"100": Devnet
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'
// Result
{
"id":67,
"jsonrpc": "2.0",
"result": "19330"
}
net_listening
Returns true if client is actively listening for network connections.
Parameters
none
Returns
Boolean - true when listening, otherwise false.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":67}'
// Result
{
"id":67,
"jsonrpc":"2.0",
"result":true
}
net_peerCount
Returns number of peers currently connected to the client.
Parameters
none
Returns
QUANTITY - integer of the number of connected peers.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}'
// Result
{
"id":74,
"jsonrpc": "2.0",
"result": "0x2" // 2
}
ABEY
abey_protocolVersion
Returns the current abeychain protocol version.
Parameters
none
Returns
String - The current abeychain protocol version.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_protocolVersion","params":[],"id":67}'
// Result
{
"id":67,
"jsonrpc": "2.0",
"result": "0x40"
}
abey_syncing
Returns an object with data about the sync status or false.
Parameters
none
Returns
Object|Boolean, An object with sync status data or FALSE, when not syncing:
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_getTotalBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":1}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x0234c8a3397aab58" // 158972490234375000
}
abey_getStorageAt
Returns the value from a storage position at a given address.
Parameters
DATA, 20 Bytes - address of the storage.
QUANTITY - integer of the position in the storage.
Returns
DATA - the value at this storage position.
Example
Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at 0x295a70b2de5e3953354a6a8344e616ed314d7251 by address 0x391694e7e0b0cce554cb130d723a9d27458f9298.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_getCode","params":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x2"],"id":1}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}
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.
Parameters
account, message
DATA, 20 Bytes - address.
DATA, N Bytes - message to sign.
Returns
DATA: Signature
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_sign","params":["0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "0xdeadbeaf"],"id":1}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
}
abey_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
Parameters
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.
nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_sendAbeyRawTransaction","params":[{see above}],"id":1}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xc7509ef7672e1c1d59cec2854d3d074d442984382bd03c665c2e82ebfdacc25e"
}
abey_call
Executes a new message call immediately without creating a transaction on the block chain.
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
Returns
DATA - the return value of executed contract.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_call","params":[{see abey_sendTransaction parameter}],"id":1}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x"
}
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.
Parameters
Returns
QUANTITY - the amount of gas used.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_estimateGas","params":[{see abey_sendTransaction parameter}],"id":1}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x5208" // 21000
}
abey_getBlockByHash
Returns information about a block by hash.
Parameters
DATA, 32 Bytes - Hash of a block.
Boolean - If true it returns the full transaction objects, if false only the hashes of the transactions.
Object - A transaction receipt object, or null when no receipt was found:
transactionHash: DATA, 32 Bytes - hash of the transaction.
transactionIndex: QUANTITY - integer of the transaction's index position in the block.
blockHash: DATA, 32 Bytes - hash of the block where this transaction was in.
blockNumber: QUANTITY - block number where this transaction was in.
from: DATA, 20 Bytes - address of the sender.
to: DATA, 20 Bytes - address of the receiver. null when it's a contract creation transaction.
cumulativeGasUsed: QUANTITY - The total amount of gas used when this transaction was executed in the block.
gasUsed: QUANTITY - The amount of gas used by this specific transaction alone.
contractAddress: DATA, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null.
to: DATA, 20 Bytes - The address the transaction is directed to.
logs: Array - Array of log objects, which this transaction generated.
logsBloom: DATA, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs.
It also returns either :
root : DATA 32 bytes of post-transaction stateroot (pre Byzantium)
status: QUANTITY either 1 (success) or 0 (failure)
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_getTransactionReceipt","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'
// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
transactionHash: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238',
transactionIndex: '0x1', // 1
blockNumber: '0xb', // 11
blockHash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b',
cumulativeGasUsed: '0x33bc', // 13244
gasUsed: '0x4dc', // 1244
contractAddress: '0xb60e8dd61c5d32be8058bb8eb970870f07233155', // or null, if none was created
logs: [{
// logs as returned by getFilterLogs, etc.
}, ...],
logsBloom: "0x00...0", // 256 byte bloom filter
status: '0x1'
}
}
abey_newFilter
A note on specifying topic filters:
Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:
[] "anything"
[A] "A in first position (and anything after)"
[null, B] "anything in first position AND B in second position (and anything after)"
[A, B] "A in first position AND B in second position (and anything after)"
[[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
Parameters
Object - The filter options:
fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_newFilter","params":[{"topics":["0x0000000000000000000000000000000000000000000000000000000012341234"]}],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}
abey_newBlockFilter
Parameters
None
Returns
QUANTITY - A filter id.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_newBlockFilter","params":[],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}
abey_newPendingTransactionFilter
Parameters
None
Returns
QUANTITY - A filter id.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_newPendingTransactionFilter","params":[],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}
abey_uninstallFilter
Parameters
QUANTITY - The filter id.
Example Parameters
params: [
"0xb" // 11
]
Returns
Boolean - true if the filter was successfully uninstalled, otherwise false.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_uninstallFilter","params":["0xb"],"id":73}'
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": true
}
abey_getFilterChanges
Polling method for a filter, which returns an array of logs which occurred since last poll.
Parameters
QUANTITY - the filter id.
Example Parameters
params: [
"0x16" // 22
]
Returns
Array - Array of log objects, or an empty array if nothing has changed since last poll.
For filters created with abey_newBlockFilter the return are block hashes (DATA, 32 Bytes), e.g. ["0x3454645634534..."].
For filters created with abey_newPendingTransactionFilter the return are transaction hashes (DATA, 32 Bytes), e.g. ["0x6345343454645..."].
For filters created with abey_newFilter logs are objects with following params:
removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.
logIndex: QUANTITY - integer of the log index position in the block. null when its pending log.
transactionIndex: QUANTITY - integer of the transactions index position log was created from. null when its pending log.
transactionHash: DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.
blockHash: DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.
blockNumber: QUANTITY - the block number where this log was in. null when its pending. null when its pending log.
address: DATA, 20 Bytes - address from which this log originated.
data: DATA - contains the non-indexed arguments of the log.
topics: Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
Returns an array of all logs matching filter with given id.
Parameters
QUANTITY - The filter id.
Example Parameters
params: [
"0x16" // 22
]
Returns
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_getFilterLogs","params":["0x16"],"id":74}'
abey_getLogs
Returns an array of all logs matching a given filter object.
Parameters
Object - The filter options:
fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
blockhash: DATA, 32 Bytes - (optional) With the addition of EIP-234 (gabey >= v1.8.13 or Parity >= v2.1.0), blockHash is a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in the filter criteria, then neither fromBlock nor toBlock are allowed.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_getLogs","params":[{"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]}],"id":74}'
abey_getWork
Returns the hash of the current block, the seedHash, and the boundary condition to be met ("target").
Parameters
none
Returns
Array - Array with the following properties: 1. DATA, 32 Bytes - current snailBlock header without nonce 2. DATA, 32 Bytes - the seed hash used for the DAG. 3. DATA, 32 Bytes - the boundary condition ("target"), 2^256 / fruit difficulty. 4. DATA, 32 Bytes - the boundary condition ("target"), 2^256 / snailBlock difficulty.
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"abey_getWork","params":[],"id":73}'
// Result
{
"jsonrpc": "2.0",
"id": 73,
"result": ["0xbcdcb8533dcf88b736f5b44f777250922f0f0472d4dd34a5a1b445a0c47aceed", "58bc067579760d307143ec1cd416eb3814110d29bf21aba0cd18586e2f038791", "0x0000000000000000000000000000000000000000000000000000000000000064", "0x0000000000000000000000000000000000000000000000000000000000002710"]
}
is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.
is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON () as data format.
gabey has experimental pub/sub support. See page for more information.
Default JSON-RPC endpoints:
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the .
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the .
An example how to use solidity ecrecover to verify the signature calculated with abey_sign can be found . The contract is deployed on the testnet Ropsten and Rinkeby.
Use to get the contract address, after the transaction was mined, when you created a contract.
Use to get the contract address, after the transaction was mined, when you created a contract.
Use to get the contract address, after the transaction was mined, when you created a contract.
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
See parameters, expect that all properties are optional. If no gas limit is specified gabey uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.
QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the .
See
Result see
See
Result see
QUANTITY|TAG - a block number, or the string "earliest", "latest" or "pending", as in the .
See
Result see
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call .
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call .
Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call .
Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additonally Filters timeout when they aren't requested with for a period of time.
See
Result see
See
Result see
See
// Result See
QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the .
QUANTITY - integer of the snail block number,or the string "latest", "earliest" or "pending", see the
See
// Result See
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the
QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the