Build an NFT Output
The following code example will:
- Create a
Client
which will connect to the Shimmer Testnet. - Create a
SecretManager
from a mnemonic. - Build an NFT output.
- Build and post a block with the NFT output created in step 3.
Iota.js
You can also find this guide in the native iota.js library
Code Example
- Rust
- Nodejs
- Python
- Java
Dotenv
This example uses dotenv, which is not safe to use in production environments.
client/examples/output/nft.rs
loading...
Run the Example
Run the example by running the following command:
cargo run --example nft --release
Dotenv
This example uses dotenv, which is not safe to use in production environments.
client/bindings/nodejs/examples/15_build_nft_output.ts
loading...
You can run the example by running the following command from the bindings/node/examples/
folder:
node dist/15_build_nft_output.js
client/bindings/python/examples/10_mint_nft.py
loading...
You can run the example by running the following command from the binding/python/examples
folder:
python3 10_mint_nft.py
client/bindings/java/examples/src/BuildNftOutput.java
loading...
Expected Output
- Rust
- Nodejs
- Python
- Java
Transaction with new NFT output sent: https://api.testnet.shimmer.network/api/core/v2/blocks/0xcfc8599956396ec01a0f4fed2f218f10f43876df28b3e9115d3695f99a536a4b
bech32_nft_address rms1zzke7q909dzj95v6nlcdlafz0ylc6dux5a2qwenq0xfuc9hcr8h76spvz3f
{
type: 6,
amount: '1000000',
nftId: '0x0000000000000000000000000000000000000000000000000000000000000000',
unlockConditions: [ { type: 0, address: [Object] } ],
immutableFeatures: [ { type: 2, data: '0x68656c6c6f' } ]
}
[
"0xa05ab7a0ab2842dedda5bd788b30ad98e32e32a35951896093de40833e9719fa",
{
"protocolVersion": 2,
"parents": [
"0x5031f5dd9defa4a663c33183f32259e35013d940b8453cb2f985f49363a905af",
"0x9a1692a4976bafb78318cdfcb0277e12f80f0db1fc441765503095ec6d326071",
"0xaeb154db6b9f32cd56bb622f209dec6565645296650c132c957d31139dd01ded",
"0xd28cfe9950c7a7be8eceb921107fc5fb6ac5c67013e59ea23e30a39d45a459f2"
],
"payload": {
"type": 6,
"essence": {
"type": 1,
"networkId": "1856588631910923207",
"inputs": [
{
"type": 0,
"transactionId": "0x434e6b652e801b80841d72f29ba7ea82c6222118c8e18177e16225e7e3668252",
"transactionOutputIndex": 0
},
{
"type": 0,
"transactionId": "0x470d590d4a747e52db3e7d908a732311b10ffebe5cad65030c8b7a57484ba125",
"transactionOutputIndex": 0
}
],
"inputsCommitment": "0x6dd5e1990b10aa6cd458cf88d0febfbe5d4b97ab50ead3059a6f1338e93f6892",
"outputs": [
{
"type": 6,
"amount": "1000000",
"nftId": "0x0000000000000000000000000000000000000000000000000000000000000000",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x8297ac4149c80cca8225e5f2da36df89a93cd2998d7f6d488c97250a881e65af"
}
}
],
"features": [
{
"type": 2,
"data": "0x68656c6c6f"
}
],
"immutableFeatures": [
{
"type": 2,
"data": "0x68656c6c6f"
}
]
},
{
"type": 3,
"amount": "50600",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x8297ac4149c80cca8225e5f2da36df89a93cd2998d7f6d488c97250a881e65af"
}
}
]
}
]
},
"unlocks": [
{
"type": 0,
"signature": {
"type": 0,
"publicKey": "0xe62838fda7e8b77bf80e49967f0f089ae2a7230547d5231649732952f6336fae",
"signature": "0x044689897d08227e0134489c4c29398e8ae745727a99dcad7ceb36e4228a0b9a71939ece341f17c6d62c9bef93f9fc72c426c4fae159dcca24bdfed1182e3903"
}
},
{
"type": 1,
"reference": 0
}
]
},
"nonce": "13835058055282177567"
}
]
{
"type": 6,
"amount": "45900",
"nftId": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
}
}
]
}