1

is there any library or proper guide to send custom/native tokens in NodeJS? i don't want to run full node (cardano-node/cardano-wallet), just want to build and sign a transaction and submit it via Blockfrost's API? want something like this: https://github.com/blockfrost/blockfrost-js/blob/fb9a55fee07927f8d7c8b0a5aa9efd2d3daf6c77/examples/simple-transaction/src/index.ts but with Native token option. thanks! p.s: I want to do it in MAINNET if matters.

2 Answers 2

2

Yes, you can use libraries like lucid & mesh.

4
  • hey, thanks for suggesting these. i have already tried Mesh, but I was not really able to use it, because it was more like TS friendly (import style), and I was not able to import "type" in my node js backend, and I did not find any example for this in lucid. mesh's examples: mesh.martify.io/apis/transaction/basic
    – AmirhN
    Dec 5, 2022 at 4:41
  • Regarding "import style", did you try this?
    – Sourabh
    Dec 5, 2022 at 5:19
  • yeah, didn't work. can't really find a way to convert "import type { ... } from '...'" to require format
    – AmirhN
    Dec 5, 2022 at 5:46
  • 2
    this worked: const { AppWallet, BlockfrostProvider, Asset, Transaction } = require('@martifylabs/mesh');
    – AmirhN
    Dec 5, 2022 at 6:00
2

You could try Helios.

Here is a guide to building transactions: https://www.hyperion-bt.org/Helios-Book/api/building/index.html

The following links will help you define a UTxO containing native assets:

If you're struggling with using ES imports, then you can try the following import style:

import("/path/to/helios.js").then( helios=>{
   const tx = new helios.Tx()
   
   ...
})

Note: Helios is more low-level than Lucid/Mesh because you need to take care of calling the Blockfrost API yourself.

2
  • Thanks! figured out how to import via mesh tho
    – AmirhN
    Dec 5, 2022 at 6:00
  • How did you end up doing it? (might be helpful for others who are struggling with the same issue) Dec 5, 2022 at 6:06

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.