Vouchers
Vouchers represent transactions that can be carried out on the base layer blockchain, such as asset transfers. They are used to effect changes in the base layer based on the application's state.
1. Get Voucher by Index
Retrieve a specific voucher based on its index and associated input index.
query voucher($voucherIndex: Int!, $inputIndex: Int!) {
voucher(voucherIndex: $voucherIndex, inputIndex: $inputIndex) {
index
input {
index
timestamp
msgSender
blockNumber
}
destination
payload
proof {
validity {
inputIndexWithinEpoch
outputIndexWithinInput
outputHashesRootHash
vouchersEpochRootHash
noticesEpochRootHash
machineStateHash
outputHashInOutputHashesSiblings
outputHashesInEpochSiblings
}
context
}
}
}
For vouchers, the API provides access to proof data that can be used for validation on the base layer blockchain. This proof data is accessible through the Proof
field on voucher objects.
Arguments
Name | Type | Description |
---|---|---|
voucherIndex | Int! | The index of the voucher to retrieve. |
inputIndex | Int! | The index of the associated input. |
Response Type
2. Get Vouchers
Retrieve a list of vouchers with support for pagination.
query vouchers($first: Int, $after: String) {
vouchers(first: $first, after: $after) {
edges {
node {
index
input {
index
timestamp
msgSender
blockNumber
}
destination
payload
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}
Arguments
Name | Type | Description |
---|---|---|
first | Int | Number of vouchers to retrieve (for pagination). |
after | String | Cursor to start retrieving vouchers from (for pagination). |
Response Type
3. Get Vouchers by Input
Retrieve vouchers associated with a specific input.
query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) {
input(index: $inputIndex) {
vouchers(first: $first, after: $after) {
edges {
node {
index
destination
payload
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
Arguments
Name | Type | Description |
---|---|---|
inputIndex | Int! | Index of the input to retrieve vouchers for. |
first | Int | Number of vouchers to retrieve (for pagination). |
after | String | Cursor to start retrieving vouchers from (for pagination). |
Response Type
Examples
Fetching a specific voucher:
query {
voucher(voucherIndex: 3, inputIndex: 2) {
index
destination
payload
proof {
validity {
inputIndexWithinEpoch
outputIndexWithinInput
}
context
}
}
}Listing earlier(first 5) vouchers:
query {
vouchers(first: 5) {
edges {
node {
index
input {
index
timestamp
}
destination
payload
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}Retrieving vouchers associated with a specific input:
query {
input(index: 10) {
vouchers(first: 3) {
edges {
node {
index
destination
payload
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}
}