JSON RPC Methods
Last updated
Last updated
In order to be compatible with , zekndProvider added some methods that follow the specification. Those methods are callable directly by the zeknd QueryService
or by zekndProvider
. In this tutorial, we're going to talk about zekndProvider
.
The provider should be the bridge between the client and the zeknd DAppChain. The code below is an example of zekndProvider
been instantiated:
#Description
Returns a list of addresses owned by the zekndProvider
#Parameters
None
#Returns
Array of DATA
, 20 Bytes- addresses owned by the client.
#Example
It should return something like this:
#Description
Returns the number of the most recent completed block.
#Parameters
None
#Returns
QUANTITY
- integer of the current block number the client is on.
#Example
The function would return something like this:
#Description
Executes a new message call immediately without creating a transaction on the blockchain.
#Parameters
Object - The transaction call object
from: DATA, 20 Bytes - The address the transaction is sent from.
to: DATA, 20 Bytes - The address the transaction is directed to.
data: DATA - Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI
#Returns
DATA
- the return value of the executed contract.
#Example
The returned value should look something like:
#Description
Returns information about a block by block number.
#Parameters
QUANTITY|TAG
:
an integer representing the block number, or -a string which can take one the following values- "earliest", "latest" or "pending", as in the default block parameter.
Boolean
- If true
, it returns the full transaction objects. If false
, it returns only the hashes of the transactions.
#Returns
Object
- A block object, or null
when no block was found:
number
: QUANTITY
- the block number. null
when it's a pending block.
hash
: DATA
, 32 Bytes - hash of the block. null
when it's a pending block.
parentHash
: DATA`, 32 Bytes - hash of the parent block.
logsBloom
: DATA
, 256 Bytes - the bloom filter for the logs of the block. null
when it's a pending block.
timestamp
: QUANTITY
- the Unix timestamp for when the block was collated.
transactions
: Array
- Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
#Example
This would return something like this:
#Description
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.
#Returns
Object
- A block object, or null
when no block was found:
number
: QUANTITY
- the block number. null
when it's a pending block.
hash
: DATA
, 32 Bytes - hash of the block. null
when it's a pending block.
parentHash
: DATA
, 32 Bytes - hash of the parent block.
logsBloom
: DATA
, 256 Bytes - the bloom filter for the logs of the block. null
when it's a pending block.
timestamp
: QUANTITY
- the Unix timestamp for when the block was collated.
transactions
: Array
- Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
#Example
The function would return something like this:
#Description
Returns the code at a given address.
#Parameters
DATA
, 20 Bytes
- address
#Returns
DATA
- the code from the given address.
#Example
The return value would look similar to this:
#Description
Polling method for a filter, which returns an array of logs which occurred since the last poll.
#Parameters
QUANTITY
- the filter id.
#Returns
Array
- Array of log objects, or an empty array if nothing has changed since the last poll.
For filters created with eth_newBlockFilter
, the return values are block hashes (DATA
, 32 Bytes), e.g. ["0x3454645634534..."]
.
For filters created with eth_newPendingTransactionFilter
, the return values are transaction hashes (DATA
, 32 Bytes), e.g. ["0x6345343454645..."]
.
For filters created with eth_newFilter
, logs are objects with following params:
removed
: TAG
- true
when the log was removed due to a chain reorganization. false
if it's a valid log.
logIndex
: QUANTITY
- integer of the log index position in the block. null
when it's a pending log.
transactionIndex
: QUANTITY
- integer index of the transactions index position the log was created from. null
when it's a pending log.
transactionHash
: DATA
, 32 Bytes - hash of the transactions this log was created from. null
when it's a pending log.
blockHash
: DATA
, 32 Bytes - hash of the block where this log was in. null when it's pending. null
when it's a pending log.
blockNumber
: QUANTITY
- the block number where this log was in. null when it's pending. null
when it's a pending log.
address
: DATA
, 20 Bytes - address from which this log originated.
data
: DATA
- contains one or more 32 Bytes 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 if you declared the event with the anonymous specifier.
#Example
The returned value would look like:
#Description
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, future) With the addition of EIP-234, blockHash
will be 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.
#Returns
See eth_getFilterChanges
#Example
#Description
Returns the receipt of a transaction by transaction hash.
The receipt is not available for pending transactions.
#Parameters
DATA
, 32 Bytes - hash of a transaction
#Returns
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 transactions 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.
contractAddress
: DATA
, 20 Bytes - The contract address created, if the transaction was a contract creation. Otherwise, null
.
logs
: Array
- Array of log objects generated by this transaction.
status
: QUANTITY
either 1 (success) or 0 (failure)
#Example
It'll return something like this:
#Description
Creates a filter, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.
#Parameters
None
#Returns
QUANTITY
- A filter id.
#Example
Return value:
#Description
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.
#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 the first position (and anything after)"
[null, B]
"anything in first position AND B in second position (and anything after)"
[A, B]
"A in the 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.
#Returns
QUANTITY
- A filter id
#Example
The return value should be something like:
#Description
Creates a 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 sent from.
to
: DATA
, 20 Bytes - (optional when creating a new contract) The address the transaction is directed to.
data
: DATA
- The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see the Ethereum Contract ABI
#Returns
DATA
, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
#Example
#Description
It works by subscribing to particular events. The node will return a subscription id. For each event that matches the subscription, a notification with relevant data is send together with the subscription id.
#Parameters
object
with the following (optional) fields:
address
, either an address or an array of addresses. Only logs that are created from these addresses are returned (optional)
topics
, only logs which match the specified topics (optional)
#Returns
Subscription id
#Example
The return value should look something like:
#Description
Uninstalls a filter with the given id. It should always be called when watching is no longer needed. Note that filters time out when they aren't requested with eth_getFilterChanges for a period of time.
#Parameters
QUANTITY
- The filter id
#Returns
Boolean
- true
if the filter was successfully uninstalled, otherwise false
.
#Example
It returns something like this:
#Description
Returns the current network id.
#Parameters
None
#Returns
String
- The current network id.
"474747": If there's now network id defined, it simply returns 474747
.
#Example
Result see