Skip to main content

Translucent Integration

Translucent is a library, which allows you to create Cardano transactions and off-chain code for your Plutus & Aiken contracts in JavaScript. Translucent forks from Lucid and makes major breaking changes. This makes it particularly adapted for Web development, giving it a lot of flexibility and ease of use out of the box. In particular, it lowers the barrier to entry for many developers who aren’t familiar with Haskell and struggle with the functional programming paradigm. Lastly, it integrates well with Aiken smart contracts.

Maestro Data Provider

Translucent must be configured with Maestro in order to interface with the Cardano blockchain.

import { Maestro, Translucent } from "translucent-cardano";

const translucent = await Translucent.new(
new Maestro({
network: "Preprod",
apiKey: "<Your-API-Key>",
turboSubmit: true
}),
"Mainnet",
);

JSON keys definition:

  • network: Define your network type: "Mainnet", "Preprod", "Preview".
  • apiKey: Maestro apiKey. Get a Free key here
  • turboSubmit: Turn on Turbo Transaction submission, learn more here

Submit a (turbo) transaction

Automatically tracked in Maestro's Transaction Dashboard

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

const tx = await translucent
.newTx()
.payToAddress("addr...", { lovelace: 5000000n })
.complete();

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

const txHash = await signedTx.submit();

console.log(txHash);
tip

To benefit from Turbo Transactions, set turboSubmit: true in the Maestro provider config above.