Unlock Conditions
Outputs can have different unlock conditions. This guide explains how to add them to an output.
If you are using a wallet you can always get the client by calling the client()
/getClient()
/get_client()
method
Different outputs can have different unlock conditions. This table shows you which output is compatible with which unlock condition. You can find the output specs in TIP-018
Output | Address | Storage Deposit Return | Timelock | Expiration | State Controller Address | Governor Address | Immutable Alias Address |
---|---|---|---|---|---|---|---|
Basic | x | x | x | x | |||
Alias | x | x | |||||
Foundry | x | ||||||
NFT | x | x | x | x |
Example Code
- Rust
- Typescript (Node.js)
- Python
The following example will use the create multiple outputs and add the following
unlock_conditions
using the add_unlock_condition
function of each output type:
The following example will add the following
unlockConditions
by passing them as output parameters
when building the outputs:
The following example will add the following unlockConditions
by passing them as output parameters
when building the outputs:
Full Example Code
- Rust
- Typescript (Node.js)
- Python
loading...
loading...
loading...
Expected Output
[
{
"type": 3,
"amount": "42600",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
}
]
},
{
"type": 3,
"amount": "46800",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
},
{
"type": 1,
"returnAddress": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
},
"amount": "1000000"
}
]
},
{
"type": 3,
"amount": "43100",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
},
{
"type": 2,
"unixTime": 1
}
]
},
{
"type": 3,
"amount": "46400",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
},
{
"type": 3,
"returnAddress": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
},
"unixTime": 1
}
]
},
{
"type": 4,
"amount": "50300",
"aliasId": "0x0000000000000000000000000000000000000000000000000000000000000000",
"stateIndex": 0,
"stateMetadata": "0x",
"foundryCounter": 0,
"unlockConditions": [
{
"type": 4,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
},
{
"type": 5,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
}
]
},
{
"type": 5,
"amount": "52800",
"serialNumber": 1,
"tokenScheme": {
"type": 0,
"mintedTokens": "0x32",
"meltedTokens": "0x0",
"maximumSupply": "0x64"
},
"unlockConditions": [
{
"type": 6,
"address": {
"type": 8,
"aliasId": "0xe8506eb1dc96cbe3b24ef8102551328bfff767393389e824e7cef199e52d87b6"
}
}
]
}
]