Get Outputs
Querying outputs allows you to retrieve specific information about transactions or assets on the Tangle. You can verify the status of transactions, track the movement of assets, and gather relevant details such as transaction history, ownership, or other metadata. You can query for any output type using the following functions:
- Rust
- Typescript (Node.js)
- Python
Client in Wallet
If you are using a wallet you can always get the client by calling the client()
/getClient()
/get_client()
method
Example Code
- Rust
- Typescript (Node.js)
- Python
The following code example will:
- Create a
Client
that will connect to the node defined in your.env
file'sNODE_URL
variable.
- Query the node for basic outputs with the specified
QueryParameters
using theClient.basic_output_ids()
function.
- Get the outputs retrieved in the previous step using the
Client.get_outputs()
function.
The following code example will:
- Create a
Client
that will connect to the node defined in your.env
file'sNODE_URL
variable.
- Query the node for basic outputs with the specified
QueryParameters
using theClient.basicOutputIds()
function.
- Get the outputs retrieved in the previous step using the
Client.getOutputs()
function.
The following code example will:
- Create a
Client
that will connect to the node defined in your.env
file'sNODE_URL
variable.
- Query the node for basic outputs with the specified
QueryParameters
using theClient.basic_output_ids()
function.
- Get the outputs retrieved in the previous step using the
Client.get_outputs()
function.
Full Example Code
- Rust
- Typescript (Node.js)
- Python
sdk/examples/how_tos/client/get_outputs.rs
loading...
bindings/nodejs/examples/how_tos/client/get-outputs.ts
loading...
bindings/python/examples/how_tos/client/get_outputs.py
loading...
Expected Output
- Rust
- Typescript (Node.js)
- Python
First output of query:
ID: OutputId(0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000)
OutputWithMetadata {
output: BasicOutput {
amount: 12310426,
native_tokens: NativeTokens(
[],
),
unlock_conditions: UnlockConditions(
[
AddressUnlockCondition(
Ed25519Address(0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3),
),
],
),
features: Features(
[],
),
},
metadata: OutputMetadata {
block_id: BlockId(0x2a006e26f54f1221b4fa5738bf2b3501a0a2e7085ff8dcc03d0700f75bbcc43c),
output_id: OutputId(0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000),
is_spent: false,
milestone_index_spent: None,
milestone_timestamp_spent: None,
transaction_id_spent: None,
milestone_index_booked: 5300818,
milestone_timestamp_booked: 1684939216,
ledger_index: 5794425,
},
}
First output of query:
ID: 0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000
OutputResponse {
metadata: {
blockId: '0x2a006e26f54f1221b4fa5738bf2b3501a0a2e7085ff8dcc03d0700f75bbcc43c',
transactionId: '0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c',
outputIndex: 0,
isSpent: false,
milestoneIndexBooked: 5300818,
milestoneTimestampBooked: 1684939216,
ledgerIndex: 5794505
},
output: BasicOutput {
type: 3,
amount: '12310426',
unlockConditions: [ [AddressUnlockCondition] ]
}
}
First output of query:
ID: 0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000
{
"metadata": {
"blockId": "0x2a006e26f54f1221b4fa5738bf2b3501a0a2e7085ff8dcc03d0700f75bbcc43c",
"transactionId": "0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c",
"outputIndex": 0,
"isSpent": false,
"milestoneIndexBooked": 5300818,
"milestoneTimestampBooked": 1684939216,
"ledgerIndex": 5794538
},
"output": {
"type": 3,
"amount": "12310426",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
}
]
}
}