darkfid JSON-RPC API
blockchain methods
blockchain.get_slot
blockchain.get_tx
blockchain.last_known_slot
blockchain.subscribe_blocks
blockchain.subscribe_err_txs
blockchain.lookup_zkas
blockchain.get_slot
Queries the blockchain database for a block in the given slot.
Returns a readable block upon success.
[src]
--> {"jsonrpc": "2.0", "method": "blockchain.get_slot", "params": [0], "id": 1}
<-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
blockchain.get_tx
Queries the blockchain database for a block in the given slot.
Returns a readable block upon success.
[src]
--> {"jsonrpc": "2.0", "method": "blockchain.get_tx", "params": ["TxHash"], "id": 1}
<-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
blockchain.last_known_slot
Queries the blockchain database to find the last known slot
[src]
--> {"jsonrpc": "2.0", "method": "blockchain.last_known_slot", "params": [], "id": 1}
<-- {"jsonrpc": "2.0", "result": 1234, "id": 1}
blockchain.subscribe_blocks
Initializes a subscription to new incoming blocks.
Once a subscription is established, darkfid
will send JSON-RPC notifications of
new incoming blocks to the subscriber.
[src]
--> {"jsonrpc": "2.0", "method": "blockchain.subscribe_blocks", "params": [], "id": 1}
<-- {"jsonrpc": "2.0", "method": "blockchain.subscribe_blocks", "params": [`blockinfo`]}
blockchain.subscribe_err_txs
Initializes a subscription to erroneous transactions notifications.
Once a subscription is established, darkfid
will send JSON-RPC notifications of
erroneous transactions to the subscriber.
[src]
--> {"jsonrpc": "2.0", "method": "blockchain.subscribe_err_txs", "params": [], "id": 1}
<-- {"jsonrpc": "2.0", "method": "blockchain.subscribe_err_txs", "params": [`tx_hash`]}
blockchain.lookup_zkas
Performs a lookup of zkas bincodes for a given contract ID and returns all of
them, including their namespace.
[src]
--> {"jsonrpc": "2.0", "method": "blockchain.lookup_zkas", "params": ["6Ef42L1KLZXBoxBuCDto7coi9DA2D2SRtegNqNU4sd74"], "id": 1}
<-- {"jsonrpc": "2.0", "result": [["Foo", [...]], ["Bar", [...]]], "id": 1}
tx methods
tx.simulate
Simulate a network state transition with the given transaction.
Returns true
if the transaction is valid, otherwise, a corresponding
error.
[src]
--> {"jsonrpc": "2.0", "method": "tx.simulate", "params": ["base58encodedTX"], "id": 1}
<-- {"jsonrpc": "2.0", "result": true, "id": 1}
tx.broadcast
Broadcast a given transaction to the P2P network.
The function will first simulate the state transition in order to see
if the transaction is actually valid, and in turn it will return an
error if this is the case. Otherwise, a transaction ID will be returned.
[src]
--> {"jsonrpc": "2.0", "method": "tx.broadcast", "params": ["base58encodedTX"], "id": 1}
<-- {"jsonrpc": "2.0", "result": "txID...", "id": 1}
wallet methods
wallet.query_row_single
Attempts to query for a single row in a given table.
The parameters given contain paired metadata so we know how to decode the SQL data.
An example of params
is as such:
params[0] -> "sql query"
params[1] -> column_type
params[2] -> "column_name"
...
params[n-1] -> column_type
params[n] -> "column_name"
This function will fetch the first row it finds, if any. The column_type
field
is a type available in the WalletDb
API as an enum called QueryType
. If a row
is not found, the returned result will be a JSON-RPC error.
NOTE: This is obviously vulnerable to SQL injection. Open to interesting solutions.
[src]
--> {"jsonrpc": "2.0", "method": "wallet.query_row_single", "params": [...], "id": 1}
<-- {"jsonrpc": "2.0", "result": ["va", "lu", "es", ...], "id": 1}
wallet.query_row_multi
Attempts to query for all available rows in a given table.
The parameters given contain paired metadata so we know how to decode the SQL data.
They're the same as above in wallet.query_row_single
.
If there are any values found, they will be returned in a paired array. If not, an
empty array will be returned.
[src]
--> {"jsonrpc": "2.0", "method": "wallet.query_row_multi", "params": [...], "id": 1}
<-- {"jsonrpc": "2.0", "result": [["va", "lu"], ["es", "es"], ...], "id": 1}
wallet.exec_sql
Executes an arbitrary SQL query on the wallet, and returns true
on success.
params[1..]
can optionally be provided in pairs like in wallet.query_row_single
.
[src]
--> {"jsonrpc": "2.0", "method": "wallet.exec_sql", "params": ["CREATE TABLE ..."], "id": 1}
<-- {"jsonrpc": "2.0", "result": true, "id": 1}
misc methods
ping
Returns a pong
to the ping
request.
[src]
--> {"jsonrpc": "2.0", "method": "ping", "params": [], "id": 1}
<-- {"jsonrpc": "2.0", "result": "pong", "id": 1}
clock
Returns current system clock in Timestamp
format.
[src]
--> {"jsonrpc": "2.0", "method": "clock", "params": [], "id": 1}
<-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
get_info
Returns sync P2P network information.
[src]
--> {"jsonrpc": "2.0", "method": "get_info", "params": [], "id": 42}
<-- {"jsonrpc": "2.0", result": {"nodeID": [], "nodeinfo": [], "id": 42}
get_consensus_info
Returns consensus P2P network information.
[src]
--> {"jsonrpc": "2.0", "method": "get_consensus_info", "params": [], "id": 42}
<-- {"jsonrpc": "2.0", result": {"nodeID": [], "nodeinfo": [], "id": 42}