Get Outputs
You can get outputs by their output ID using the Client.get_output(output_id)
function.
The following code example will:
- Create a
Client
which will connect to the Shimmer Testnet. - Get an output by its output ID.
Code Example
- Rust
- Nodejs
- Python
- Java
client/examples/node_api_core/09_get_output.rs
loading...
Run the Example
Run the example by running the following command:
cargo run --example node_api_core_get_output --release -- https://api.testnet.shimmer.network 0x1e857d380f813d8035e487b6dfd2ff4740b6775273ba1b576f01381ba2a1a44c
- You can replace
https://api.testnet.shimmer.network
with any node url. - You can replace
0x1e857d380f813d8035e487b6dfd2ff4740b6775273ba1b576f01381ba2a1a44c
with any other OutputID.
Dotenv
This example uses dotenv, which is not safe to use in production environments.
client/bindings/nodejs/examples/04_get_output.ts
loading...
You can run the example by running the following command from the bindings/node/examples/
folder:
node dist/04_get_output.js
client/bindings/python/examples/04_get_output.py
loading...
You can run the example by running the following command from the binding/python/examples
folder:
python3 04_get_output.py
client/bindings/java/examples/src/GetOutputs.java
loading...
Expected Output
- Rust
- Nodejs
- Python
- Java
OutputResponse {
metadata: OutputMetadataResponse {
block_id: "0xa9f11aba1e9965173dc21a47ec4fbfe5b953a6e60277857a3f7a5c1499e7c454",
transaction_id: "0x1e857d380f813d8035e487b6dfd2ff4740b6775273ba1b576f01381ba2a1a44c",
output_index: 0,
is_spent: true,
milestone_index_spent: Some(
249147,
),
milestone_timestamp_spent: Some(
1659379781,
),
transaction_id_spent: Some(
"0xa927ea21d3c4a49d5c73169c80302ddb223894c182a4b7cfef0af89568262749",
),
milestone_index_booked: 249145,
milestone_timestamp_booked: 1659379771,
ledger_index: 918846,
},
output: Alias(
AliasOutputDto {
kind: 4,
amount: "2000000",
native_tokens: [],
alias_id: AliasIdDto(
"0x0000000000000000000000000000000000000000000000000000000000000000",
),
state_index: 0,
state_metadata: "",
foundry_counter: 0,
unlock_conditions: [
StateControllerAddress(
StateControllerAddressUnlockConditionDto {
kind: 4,
address: Ed25519(
Ed25519AddressDto {
kind: 0,
pub_key_hash: "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3",
},
),
},
),
GovernorAddress(
GovernorAddressUnlockConditionDto {
kind: 5,
address: Ed25519(
Ed25519AddressDto {
kind: 0,
pub_key_hash: "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3",
},
),
},
),
],
features: [
Sender(
SenderFeatureDto {
kind: 0,
address: Ed25519(
Ed25519AddressDto {
kind: 0,
pub_key_hash: "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3",
},
),
},
),
Metadata(
MetadataFeatureDto {
kind: 2,
data: "0x010203",
},
),
],
immutable_features: [
Issuer(
IssuerFeatureDto {
kind: 1,
address: Ed25519(
Ed25519AddressDto {
kind: 0,
pub_key_hash: "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3",
},
),
},
),
],
},
),
}
{
'metadata': {
'blockId': '0xa9f11aba1e9965173dc21a47ec4fbfe5b953a6e60277857a3f7a5c1499e7c454',
'transactionId': '0x1e857d380f813d8035e487b6dfd2ff4740b6775273ba1b576f01381ba2a1a44c',
'outputIndex': 0,
'isSpent': True,
'milestoneIndexSpent': 249147,
'milestoneTimestampSpent': 1659379781,
'transactionIdSpent': '0xa927ea21d3c4a49d5c73169c80302ddb223894c182a4b7cfef0af89568262749',
'milestoneIndexBooked': 249145,
'milestoneTimestampBooked': 1659379771,
'ledgerIndex': 749737
},
'output': {
'type': 4,
'amount': '2000000',
'aliasId': '0x0000000000000000000000000000000000000000000000000000000000000000',
'stateIndex': 0,
'foundryCounter': 0,
'unlockConditions': [
{
'type': 4,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
},
{
'type': 5,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
}
],
'features': [
{
'type': 0,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
},
{
'type': 2,
'data': '0x010203'
}
],
'immutableFeatures': [
{
'type': 1,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
}
]
}
}
{
'metadata': {
'blockId': '0xa9f11aba1e9965173dc21a47ec4fbfe5b953a6e60277857a3f7a5c1499e7c454',
'transactionId': '0x1e857d380f813d8035e487b6dfd2ff4740b6775273ba1b576f01381ba2a1a44c',
'outputIndex': 0,
'isSpent': True,
'milestoneIndexSpent': 249147,
'milestoneTimestampSpent': 1659379781,
'transactionIdSpent': '0xa927ea21d3c4a49d5c73169c80302ddb223894c182a4b7cfef0af89568262749',
'milestoneIndexBooked': 249145,
'milestoneTimestampBooked': 1659379771,
'ledgerIndex': 749737
},
'output': {
'type': 4,
'amount': '2000000',
'aliasId': '0x0000000000000000000000000000000000000000000000000000000000000000',
'stateIndex': 0,
'foundryCounter': 0,
'unlockConditions': [
{
'type': 4,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
},
{
'type': 5,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
}
],
'features': [
{
'type': 0,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
},
{
'type': 2,
'data': '0x010203'
}
],
'immutableFeatures': [
{
'type': 1,
'address': {
'type': 0,
'pubKeyHash': '0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3'
}
}
]
}
}
{
"type": 3,
"amount": "1000000000",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0xf11b9d362a332263e7773350b0214b742ccffd364d678626bd15556514617058"
}
}
]
}{
"blockId": "0xb6e74f8a623756b26d6146ef34612890b6c858088482620eddaaf4ecb9c8b9fb",
"transactionId": "0xc66155c2bbbd8f22cb55940642aa65a8c5cd07fb1f93c7c4ff53414d45daa577",
"outputIndex": 0,
"isSpent": false,
"milestoneIndexBooked": 949,
"milestoneTimestampBooked": 1658138754,
"ledgerIndex": 749811
}