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

CC BY-SA 4.0
2023-07-31T16:21:28.483Z
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
CC BY-SA 4.0
2023-08-16T08:31:00.553Z
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.
Nikhil Shetty
CC BY-SA 4.0
2023-07-31T07:38:27.787Z
2023-07-31T07:38:27.787Z
Sourabh
<p>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.</p>
<pre class="lang-js prettyprint-override"><code>import { Blockfrost, Lucid } from &quot;/mod.js&quot;;

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

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

const policyId = &quot;2b28c81dbba6d67e4b5a997c6be1212cba9d60d33f82444ab8b1f218&quot;;

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

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

const txHash = await signedTx.submit();

console.log(txHash);
</code></pre>

<lucid>
Issue with Lucid and sending tokens
# Issue with Lucid and sending tokens

(Asked by: username_0 on 2023-07-28)

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();
lucid.selectWallet(api);

const policyId = "2b28c81dbba6d67e4b5a997c6be1212cba9d60d33f82444ab8b1f218";

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

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

const txHash = await signedTx.submit();

console.log(txHash);

**Tags:** lucid

---

## 1 answers

### Answer by username_1 on 2023-07-31. Score: 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`.

> **Comments:**
> **username_0**: 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?  
> **username_2**: 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.  

---

