Skip to content

sendTransaction · NFT ​

Back to the sendTransaction overview

Covers collection creation, NFT creation, and NFT transfers.

COLLECTION_CREATE ​

Create a new NFT collection with metadata including name, description, supply, and an image file.

ts
const params = [
  {
    flag: "COLLECTION_CREATE",    // Required
    collection_data: "",          // Required, CollectionData in JSON format
    broadcastEnabled: true,       // Optional, defaults to true
  },
];

const { txid } = await Turing.sendTransaction(params);
// const { txraw } = await Turing.sendTransaction(params); // When broadcastEnabled is false
// const { error } = await Turing.sendTransaction(params); // When an error occurs

NFT_CREATE ​

Create a new NFT within an existing collection.

ts
const params = [
  {
    flag: "NFT_CREATE",           // Required
    collection_id: "",            // Required, collection ID
    nft_data: "",                 // Required, NFTData in JSON format
    broadcastEnabled: true,       // Optional, defaults to true
  },
];

const { txid } = await Turing.sendTransaction(params);
// const { txraw } = await Turing.sendTransaction(params); // When broadcastEnabled is false
// const { error } = await Turing.sendTransaction(params); // When an error occurs

NFTData and attributes ​

nft_data is a serialized JSON string. Its attributes field is itself a JSON-object string for custom NFT metadata such as category, rarity, or business tags. Use "{}" when no additional attributes are needed.

ts
const nftData = {
  nftName: "Turing Cat #1",
  symbol: "TCAT",
  description: "Turing Cat collection item",
  attributes: JSON.stringify({
    category: "Art",
    rarity: "Rare",
    generation: 1,
  }),
  file: "...", // Image Data URL or application-defined file data
};

const params = [{
  flag: "NFT_CREATE",
  collection_id: "transaction ID returned by COLLECTION_CREATE on this network",
  nft_data: JSON.stringify(nftData),
  broadcastEnabled: false,
}];

NFT_TRANSFER ​

Transfer an NFT to another address.

The wallet detects NFT v0, v1, or v2 from the on-chain NFT output and selects the matching transfer method automatically. DApps do not pass an NFT version parameter.

ts
const params = [
  {
    flag: "NFT_TRANSFER",         // Required
    nft_contract_address: "",     // Required, NFT contract address
    address: "",                  // Required, recipient address
    broadcastEnabled: true,       // Optional, defaults to true
  },
];

const { txid } = await Turing.sendTransaction(params);
// const { txraw } = await Turing.sendTransaction(params); // When broadcastEnabled is false
// const { error } = await Turing.sendTransaction(params); // When an error occurs

Live Example ​

Live Example

Turing.sendTransaction() / NFT

Detecting Wallet...

The active wallet network is Unknown. This method requires TBC. Switch networks and try again.

Image data is readyUse an image up to 5 MiB. It will be compressed when needed and synced to JSON.

Form and JSON stay in sync. Use real transaction IDs from the current network for on-chain resources.

Detecting Wallet...
Code Preview