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
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– AmirhNCommented Dec 5, 2022 at 4:41
-
-
yeah, didn't work. can't really find a way to convert "import type { ... } from '...'" to require format– AmirhNCommented Dec 5, 2022 at 5:46
-
2this worked: const { AppWallet, BlockfrostProvider, Asset, Transaction } = require('@martifylabs/mesh');– AmirhNCommented Dec 5, 2022 at 6:00
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:
- https://www.hyperion-bt.org/Helios-Book/api/reference/utxo.html
- https://www.hyperion-bt.org/Helios-Book/api/reference/txoutput.html
- https://www.hyperion-bt.org/Helios-Book/api/reference/value.html
- https://www.hyperion-bt.org/Helios-Book/api/reference/assets.html
- https://www.hyperion-bt.org/Helios-Book/api/reference/mintingpolicyhash.html
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.
-
-
How did you end up doing it? (might be helpful for others who are struggling with the same issue) Commented Dec 5, 2022 at 6:06