Any ideas of why this isn't working? I obviously removed the Blockfrost ID and address, and I have enough tokens to send. For some reason it keeps saying Inputs Exhausted. Any help appreciated.

import { Blockfrost, Lucid } from "/mod.js";

const lucid = await Lucid.new(
  new Blockfrost("https://cardano-mainnet.blockfrost.io/api/v0", "mainnet...")

// Assumes you are in a browser environment
const api = await window.cardano.nami.enable();

const policyId = "2b28c81dbba6d67e4b5a997c6be1212cba9d60d33f82444ab8b1f218";

const tx = await lucid.newTx()
  .payToAddress("addr1...", { [policyId]: 100n })

const signedTx = await tx.sign().complete();

const txHash = await signedTx.submit();


1 Answer 1


A token has two components, it's name & corresponding policy-id. Thus, instead of .payToAddress("addr1...", { [policyId]: 100n }) you need to do .payToAddress("addr1...", { [token]: 100n }) where token is defined as concatenation of policy-id & name, like const token = policyId + tokenName.

  • I'm sorry, I am not following. Can you write out the full script so I can try and understand what you are trying to correct?
    – lovetoshi
    Commented Jul 31, 2023 at 16:21
  • Let's say that the name of the token you wish to send is "BTC" (const tokenName = "BTC"). So as mentioned in this answer, you need to update payToAddress like payToAddress("addr1...", { [policyId + fromText(tokenName)]: 100n }). You can import "fromText" from "/mod.js" itself. Commented Aug 16, 2023 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.