Translucent is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript.
Translucent forks from Lucid and makes major breaking changes.
Development happens in bun. We use bun build:wasm, bun test. If you want to contribute to translucent, please do so with bun. Translucent can be used from any other js runtime.
npm install translucent-cardano
Use polyfills to make translucent run in the browser.
(these polyfills are preliminary and we should package translucent for the browser)
resolve: {
alias: {
'node-fetch': 'node-fetch-polyfill',
'sha256': 'tiny-sha256',
'@sinclair/typebox': '@sinclair/typebox',
'@dcspark/cardano-multiplatform-lib-nodejs': '@dcspark/cardano-multiplatform-lib-browser',
'uplc-node': 'translucent/uplc/pkg-web',
'@emurgo/cardano-message-signing-nodejs': '@emurgo/cardano-message-signing-browser',
}
},
optimizeDeps: {
exclude: ['translucent', 'typebox'],
...
},
... how to use translucent in deno ...
import { Maestro, Translucent } from "translucent-cardano";
const translucent = await Translucent.new(
new Maestro({ network: "Mainnet", apiKey: "<apikey>" }),
"Mainnet",
);
// 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);
Join us on Discord!