MeshJS / mesh

An open-source library to advance Web3 development on Cardano

Home Page:https://meshjs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mintAsset with more than the minAda Amount for smart contract recipients

fsamvura opened this issue · comments

Minting a tracking NFT would not serve its purpose with the expected UTXO is split in two or more indexes. It would be nice to be able to send more Ada within the same UTXO line. Great Work!

use tx.sendValue() to customize the output to however you like.

Hi Jingles, thanks for the prompt reply. Yes, tx.sendValue() would work for arbitrary values, but the minting step itself has an in-built sending function which requires a recipient. In the case of minting an NFT during a locking step to a smart contract, this would result in two or more UTXOs being created unless that NFT could be assigned a recipient in a separate step within the same transaction.

Just chain .sendValue() multiple times to create multiple UTXOs outputs in the same transaction.

e.g.

const tx = new Transaction({ initiator: wallet })
.sendValue(...)
.sendValue(...)
.sendValue(...)
;

It is indeed what I am trying to avoid. With multiple UTXOs, the logique of a tracking NFT is undermined.

If you want to have multiple assets in ONE UTXO. Both sendValue() and sendAssets() takes an array of assets.

Please see docs

  .sendAssets(
    'addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr',
    [
      {
        unit: '64af286e2ad0df4de2e7de15f8ff5b3d27faecf4ab2757056d860a424d657368546f6b656e',
        quantity: '1',
      },
      {
        unit: 'ANOTHERASSET',
        quantity: '1',
      },
      {
        unit: 'OHANOTHERASSET',
        quantity: '1',
      },
      {
        unit: 'lovelace',
        quantity: '1000000000',
      },
    ]
  )