Skip to content

sendTransaction · PoolNFT ​

Back to the sendTransaction overview

Covers PoolNFT minting, initialization, liquidity management, swaps, and UTXO merging.

POOLNFT_MINT ​

Mint a PoolNFT to create a new liquidity pool for a fungible token. Supports optional hash lock and lock time configurations.

ts
const params = [
  {
    flag: "POOLNFT_MINT",         // Required
    ft_contract_address: "",      // Required, FT contract address
    serverProvider_tag: "",       // Required, service provider tag
    poolNFT_version: 2,           // Optional, forced to 2
    serviceFeeRate: 130,          // Optional; must match lpPlan. Plan 6 uses 130 (1.30%)
    with_lock: false,             // Optional, defaults to false; when true, creates a poolNFT with hash lock
    pubKeyLock: ["pubkey1", "pubkey2"], // Required when with_lock is true
    lpCostAddress: "",            // Required when with_lock is true, address for deducting liquidity addition costs
    lpCostAmount: 0,              // Required when with_lock is true, TBC amount for deducting liquidity addition costs
    lpPlan: 6,                    // Optional, 1-6, defaults to 1
    isLockTime: false,            // Optional, defaults to false
    broadcastEnabled: true,       // Optional, defaults to true
  },
];

const { txid } = await Turing.sendTransaction(params);
// const { txraw } = await Turing.sendTransaction(params); // When broadcastEnabled is false, the returned txraw contains two transactions separated by commas, which need to be broadcast in batch, ensuring the first txraw is broadcast first
// const { error } = await Turing.sendTransaction(params); // When an error occurs

Canonical service fee rates (basis points) are: Plan 1 = 35, Plan 2 = 35, Plan 3 = 135, Plan 4 = 335, Plan 5 = 535, and Plan 6 = 130. When serviceFeeRate is omitted, the wallet derives it from lpPlan; an explicitly supplied value must match the selected plan.

POOLNFT_INIT ​

Initialize a PoolNFT liquidity pool with initial TBC and FT amounts.

ts
const params = [
  {
    flag: "POOLNFT_INIT",         // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    address: "",                  // Required, recipient address
    tbc_amount: 0,                // Required, initial TBC amount
    ft_amount: 0,                 // Required, initial FT amount
    poolNFT_version: 2,           // Optional, forced to 2
    lockTime: 0,                  // Optional, lock until the specified block height
    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

POOLNFT_LP_INCREASE ​

Increase liquidity in a PoolNFT pool by adding TBC.

ts
const params = [
  {
    flag: "POOLNFT_LP_INCREASE",  // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    address: "",                  // Required, recipient address
    tbc_amount: 0,                // Required, TBC amount to add
    poolNFT_version: 2,           // Optional, forced to 2
    lockTime: 0,                  // Optional, lock until the specified block height
    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

POOLNFT_LP_CONSUME ​

Consume liquidity from a PoolNFT pool by redeeming LP tokens.

ts
const params = [
  {
    flag: "POOLNFT_LP_CONSUME",   // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    address: "",                  // Required, recipient address
    ft_amount: 0,                 // Required, FT LP amount to consume
    poolNFT_version: 2,           // Optional, forced to 2
    lockTime: 0,                  // Optional, manually set unlock parameters to the maximum unlockable block height. If lock-up is enabled without this parameter, unlock parameters will be automatically set to (current block height - 2)
    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

POOLNFT_LP_BURN ​

Burn all LP tokens from a PoolNFT pool.

ts
const params = [
  {
    flag: "POOLNFT_LP_BURN",      // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    poolNFT_version: 2,           // Optional, forced to 2
    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

POOLNFT_SWAP_TO_TOKEN ​

Swap TBC for tokens in a PoolNFT liquidity pool.

ts
const params = [
  {
    flag: "POOLNFT_SWAP_TO_TOKEN", // Required
    nft_contract_address: "",      // Required, PoolNFT contract address
    address: "",                   // Required, recipient address
    tbc_amount: 0,                 // Required, TBC amount to swap
    poolNFT_version: 2,            // Optional, forced to 2
    lpPlan: 6,                     // Optional; use 6 for a Plan 6 pool, or omit it for chain-state detection
    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

POOLNFT_SWAP_TO_TBC ​

Swap tokens for TBC in a PoolNFT liquidity pool.

ts
const params = [
  {
    flag: "POOLNFT_SWAP_TO_TBC",  // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    address: "",                  // Required, recipient address
    ft_amount: 0,                 // Required, FT amount to swap
    poolNFT_version: 2,           // Optional, forced to 2
    lpPlan: 6,                    // Optional; use 6 for a Plan 6 pool, or omit it for chain-state detection
    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

POOLNFT_MERGE ​

Merge PoolNFT-related UTXOs to consolidate pool state.

ts
const params = [
  {
    flag: "POOLNFT_MERGE",        // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    poolNFT_version: 2,           // Optional, forced to 2
    merge_times: 10,              // Optional, 1-10 times, defaults to 10, terminates early if fewer
  },
];

const { txid } = await Turing.sendTransaction(params); // txid is multiple Merge transaction txids separated by commas
// const { error } = await Turing.sendTransaction(params); // When an error occurs

FTLP_MERGE ​

Merge FTLP UTXOs to consolidate LP token holdings.

ts
const params = [
  {
    flag: "FTLP_MERGE",           // Required
    nft_contract_address: "",     // Required, PoolNFT contract address
    poolNFT_version: 2,           // Optional, forced to 2
    lockTime: 0,                  // Optional, manually set unlock parameters to the maximum unlockable block height. If lock-up is enabled without this parameter, unlock parameters will be automatically set to (current block height - 2)
  },
];

const { txid } = await Turing.sendTransaction(params); // txid is multiple Merge transaction txids separated by commas
// const { error } = await Turing.sendTransaction(params); // When an error occurs

Live Example ​

This single workspace covers PoolNFT minting, initialization, liquidity changes, swaps, and UTXO merging. It uses a business form by default and can switch to synchronized JSON.

Live Example

Turing.sendTransaction() / POOLNFT

Detecting Wallet...

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

Use an existing 64-character transaction ID from the active wallet network; format examples cannot be submitted.

The protocol accepts 1–6. The service fee rate follows the selected plan automatically.

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

Detecting Wallet...
Code Preview