Fetch block data if available
LOOKING FOR INSTRUCTIONS ON HOW TO RUN YOUR OWN LIGHT CLIENT?
You can check out our docs here for instructions on how to run your own light client.
Note:
Light client must be running in app-mode
to retrieve data. Click here for instructions on how to run an Avail Light Client in app-mode
.
Gets the block data if available.
Only returns data if the block contains it for the configured app_id
. If there is no data against the configured app_id
it returns an empty array.
Query parameter fields
specifies whether to return decoded data and encoded extrinsic (with signature). If fields
parameter is omitted, response contains hash and data, while extrinsic is omitted.
The data
and extrinsic
is encoded in base64
format.
CURL
Local
curl "localhost:7007/v2/blocks/{block_number}/data?fields=data,extrinsic"
Sample Response:
If block_status = “finished”, data is available and the response is:
{
"data_transactions": [
{
"data": "{base-64-encoded-data}" // Optional
"extrinsic": "{base-64-encoded-extrinsic}", // Optional
}
]
}
If block_status is not “finished”, or app-mode
is not enabled, data is not available and the response is:
Not Found
If no data is available in the block against the configured app_id
in app-mode
:
{
"data_transactions": []
}
The next few methods are used to submit data to the Avail network. But to use them:
-
you need to configure an
identity.toml
file which will contain the seed phrase for an account that has someAVAIL
tokens. You can learn how to do that here. -
You will also need to run the Avail LC in app-client mode. The command to do all this will look something like this:
curl -sL1 avail.sh | bash -s -- --app_id 1 --identity identity.toml --network mainnet