List Outputs
You can list all the outputs related to an account by calling the Account.outputs()
function.
Code Example
The following example will:
- Create an account manager.
- Get Alice's account which was created in the first guide.
- List all the outputs related to Alice's account.
Outputs may have multiple UnlockConditions, which may require returning some or all of the transferred amount. The outputs could also expire if not claimed in time, or may not be unlockable for a predefined period.
To get outputs with only the AddressUnlockCondition
, you should synchronize with the option syncOnlyMostBasicOutputs: true
.
If you are synchronizing outputs with other unlock conditions, you should check the unlock conditions carefully before crediting users any balance.
You can find an example illustrating how to check whether an output has only the address unlock condition and whether this address belongs to the account in the Check Unlock Conditions how-to guide.
- Rust
- Nodejs
- Python
- Java
This how to guide is not available in your language of choice at the moment. Please feel free to browse more examples which may suit your requirements.
loading...
You can run the example by running the following command from the wallet/bindings/nodejs/examples/
folder:
node 12a-list-outputs.js
loading...
You can run the example by running the following command from the binding/python/examples
folder:
python3 9-list-outputs.py
loading...
Expected Output
- Rust
- Nodejs
- Python
- Java
This how to guide is not available in your language of choice at the moment. Please feel free to browse more examples which may suit your requirements.
Listing Outputs: [
{
outputId: '0x72240e6d6dc463e4dd962a2e34f2233a41b56a259c84faf895fbbb96820773050100',
metadata: {
blockId: '0x1106c1e0da5b2e10762fcf0ed3bc2a4790ffd2a81895afbc58df6b447c70ad3a',
transactionId: '0x72240e6d6dc463e4dd962a2e34f2233a41b56a259c84faf895fbbb9682077305',
outputIndex: 1,
isSpent: false,
milestoneIndexBooked: 972425,
milestoneTimestampBooked: 1662996908,
ledgerIndex: 974093
},
output: {
type: 5,
amount: '53600',
serialNumber: 4,
tokenScheme: [Object],
unlockConditions: [Array],
immutableFeatures: [Array]
},
isSpent: false,
address: {
type: 0,
pubKeyHash: '0xeed1e4e3e9e7555e2f1592594bf916523e7fef3a9a8c0d630a4934440b822647'
},
networkId: '1856588631910923207',
remainder: false,
chain: [ [Object], [Object], [Object], [Object], [Object] ]
},
[...]
]
Outputs:[
{
'outputId':'0xf4676daae96cf629c04d8d62989dec6d9dbbac221959d72c399729f92047ec140000',
'metadata':{
'blockId':'0x77b1fec7bd1ebb9ecfdf1ed9501dbf17acc4b1aa3889f310be95d5d82a5b5674',
'transactionId':'0xf4676daae96cf629c04d8d62989dec6d9dbbac221959d72c399729f92047ec14',
'outputIndex':0,
'isSpent':False,
'milestoneIndexBooked':1571314,
'milestoneTimestampBooked':1665991915,
'ledgerIndex':1571314
},
'output':{
'type':3,
'amount':'1000000000',
'unlockConditions':[
{
'type':0,
'address':{
'type':0,
'pubKeyHash':'0xf4d94c9f4e63d553c81e644225fa3bbc412f820c4eafd495aeb0bb05a29922b2'
}
}
]
},
'isSpent':False,
'address':{
'type':0,
'pubKeyHash':'0xf4d94c9f4e63d553c81e644225fa3bbc412f820c4eafd495aeb0bb05a29922b2'
},
'networkId':'1856588631910923207',
'remainder':False,
'chain':[
{
'hardened':True,
'bs':[
128,
0,
0,
44
]
},
{
'hardened':True,
'bs':[
128,
0,
16,
123
]
},
{
'hardened':True,
'bs':[
128,
0,
0,
0
]
},
{
'hardened':True,
'bs':[
128,
0,
0,
0
]
},
{
'hardened':True,
'bs':[
128,
0,
0,
0
]
}
]
}
]
Unspent outputs:[
{
'outputId':'0xf4676daae96cf629c04d8d62989dec6d9dbbac221959d72c399729f92047ec140000',
'metadata':{
'blockId':'0x77b1fec7bd1ebb9ecfdf1ed9501dbf17acc4b1aa3889f310be95d5d82a5b5674',
'transactionId':'0xf4676daae96cf629c04d8d62989dec6d9dbbac221959d72c399729f92047ec14',
'outputIndex':0,
'isSpent':False,
'milestoneIndexBooked':1571314,
'milestoneTimestampBooked':1665991915,
'ledgerIndex':1571314
},
'output':{
'type':3,
'amount':'1000000000',
'unlockConditions':[
{
'type':0,
'address':{
'type':0,
'pubKeyHash':'0xf4d94c9f4e63d553c81e644225fa3bbc412f820c4eafd495aeb0bb05a29922b2'
}
}
]
},
'isSpent':False,
'address':{
'type':0,
'pubKeyHash':'0xf4d94c9f4e63d553c81e644225fa3bbc412f820c4eafd495aeb0bb05a29922b2'
},
'networkId':'1856588631910923207',
'remainder':False,
'chain':[
{
'hardened':True,
'bs':[
128,
0,
0,
44
]
},
{
'hardened':True,
'bs':[
128,
0,
16,
123
]
},
{
'hardened':True,
'bs':[
128,
0,
0,
0
]
},
{
'hardened':True,
'bs':[
128,
0,
0,
0
]
},
{
'hardened':True,
'bs':[
128,
0,
0,
0
]
}
]
}
]
{
"outputId":"0xb23dc6681903672b76aae4f74c405fcd684c6fcf5d21fc367addcbafd0c3770c1a00",
"metadata":{
"blockId":"0xcfb891e37d261bf48381ec5fd7a6957396ce9296dab35d8111cc8bb4369dc2cd",
"transactionId":"0xb23dc6681903672b76aae4f74c405fcd684c6fcf5d21fc367addcbafd0c3770c",
"outputIndex":26,
"isSpent":false,
"milestoneIndexBooked":831306,
"milestoneTimestampBooked":1662290619,
"ledgerIndex":1351681
},
"output":{
"type":3,
"amount":"50600",
"unlockConditions":[
{
"type":0,
"address":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
}
},
{
"type":1,
"returnAddress":{
"type":0,
"pubKeyHash":"0x8297ac4149c80cca8225e5f2da36df89a93cd2998d7f6d488c97250a881e65af"
},
"amount":"50600"
},
{
"type":3,
"returnAddress":{
"type":0,
"pubKeyHash":"0x8297ac4149c80cca8225e5f2da36df89a93cd2998d7f6d488c97250a881e65af"
},
"unixTime":1662895377
}
]
},
"isSpent":false,
"address":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
},
"networkId":"1856588631910923207",
"remainder":false,
"chain":[
{
"hardened":true,
"bs":[
128,
0,
0,
44
]
},
{
"hardened":true,
"bs":[
128,
0,
16,
123
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
}
]
}
{
"outputId":"0x94f6bdabbfc0b3f39961ffe7a19c3a26fde2908cce6b879beb4c20ed27cdad420000",
"metadata":{
"blockId":"0x6079cabb638789187cb372d521c033afdf15f52093cc1b922330fe81bb3574d3",
"transactionId":"0x94f6bdabbfc0b3f39961ffe7a19c3a26fde2908cce6b879beb4c20ed27cdad42",
"outputIndex":0,
"isSpent":false,
"milestoneIndexBooked":1350472,
"milestoneTimestampBooked":1664887705,
"ledgerIndex":1351681
},
"output":{
"type":3,
"amount":"50601",
"unlockConditions":[
{
"type":0,
"address":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
}
},
{
"type":1,
"returnAddress":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
},
"amount":"50600"
},
{
"type":3,
"returnAddress":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
},
"unixTime":1664887701
}
]
},
"isSpent":false,
"address":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
},
"networkId":"1856588631910923207",
"remainder":false,
"chain":[
{
"hardened":true,
"bs":[
128,
0,
0,
44
]
},
{
"hardened":true,
"bs":[
128,
0,
16,
123
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
}
]
}
{
"outputId":"0xaccae1f4e78ee169d0fc1d99843e6cd417290da91aa62c696fa507d21fd245cc0200",
"metadata":{
"blockId":"0x8f9f12a968c32cc3d51e978f4de34252bc769ee7188e33a21f9351a7c1f122f3",
"transactionId":"0xaccae1f4e78ee169d0fc1d99843e6cd417290da91aa62c696fa507d21fd245cc",
"outputIndex":2,
"isSpent":false,
"milestoneIndexBooked":1350405,
"milestoneTimestampBooked":1664887370,
"ledgerIndex":1351681
},
"output":{
"type":3,
"amount":"2096427899",
"nativeTokens":[
{
"id":"0x08429fe5864378ce70699fc2d22bb144cb86a3c4833d136e3b95c5dadfd6ba0cef0100000000",
"amount":"0x3233"
},
{
"id":"0x08429fe5864378ce70699fc2d22bb144cb86a3c4833d136e3b95c5dadfd6ba0cef0200000000",
"amount":"0x3233"
},
{
"id":"0x08429fe5864378ce70699fc2d22bb144cb86a3c4833d136e3b95c5dadfd6ba0cef0400000000",
"amount":"0x17"
}
],
"unlockConditions":[
{
"type":0,
"address":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
}
}
]
},
"isSpent":false,
"address":{
"type":0,
"pubKeyHash":"0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
},
"networkId":"1856588631910923207",
"remainder":false,
"chain":[
{
"hardened":true,
"bs":[
128,
0,
0,
44
]
},
{
"hardened":true,
"bs":[
128,
0,
16,
123
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
},
{
"hardened":true,
"bs":[
128,
0,
0,
0
]
}
]
}