Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lucid/src/mod.ts

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
Go to Latest
import * as lucid from "https://deno.land/x/lucid@0.7.6/src/mod.ts";

Classes

ED25519 key used as public key

We introduce a builder-pattern format for creating transaction outputs This is because:

  1. Some fields (i.e. data hash) are optional, and we can't easily expose Option<> in WASM
  2. Some fields like amounts have many ways it could be set (some depending on other field values being known)
  3. Easier to adapt as the output format gets more complicated in future Cardano releases

Builder de-duplicates witnesses as they are added

Variables

v
C

JSON <-> PlutusData conversion schemas. Follows ScriptDataJsonSchema in cardano-cli defined at: https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/ScriptData.hs#L254

Each new language uses a different namespace for hashing its script This is because you could have a language where the same bytes have different semantics So this avoids scripts in different languages mapping to the same hash Note that the enum value here is different than the enum value for deciding the cost model of a script https://github.com/input-output-hk/cardano-ledger/blob/9c3b4737b13b30f71529e76c5330f403165e28a6/eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs#L127

Used to choose the schema for a script JSON string

v
M

Functions

Concatenate the given arrays into a new Uint8Array.

Receives a script JSON string and returns a NativeScript. Cardano Wallet and Node styles are supported.

This function is temporarily needed only, until Blockfrost returns the datum natively in Cbor. The conversion is ambigious, that's why it's better to get the datum directly in Cbor.

Check whether binary arrays are equal to each other.

Splits unit into policy id, asset name (entire asset name), name (asset name without label) and label if applicable. name will be returned in Hex.

Address can be in Bech32 or Hex

Convert a native script from Json to the Hex representation. It follows this Json format: https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md

Interfaces

A wallet that can be constructed from external data e.g utxos and an address. It doesn't allow you to sign transactions/messages. This needs to be handled separately.

Type Aliases

Bech32

Plutus scripts need to be double Cbor encoded. Raw compiled scripts without any Cbor encoding do not work.

Hex

Hex

JSON object

Hex

Plutus scripts need to be double Cbor encoded. Raw compiled scripts without any Cbor encoding do not work.

asHash will add the datum hash to the output and the datum to the witness set. inline will add the datum to the output. scriptRef will add any script to the output. You can only specify asHash or inline, not both at the same time.

Hex

Hex

These are the arguments that conform a BuiltinData in Plutus: data Data = Constr Integer [Data] | Map [(Data, Data)] | List [Data] | I Integer | B BS.ByteString deriving stock (Show, Eq, Ord, Generic) deriving anyclass (NFData)

Hex

Bech32

Bech32

Bech32

Hex (Redeemer is only PlutusData, same as Datum)

Bech32

Plutus scripts need to be double Cbor encoded. Raw compiled scripts without any Cbor encoding do not work.

Hex

Hex

Plutus scripts need to be double Cbor encoded. Raw compiled scripts without any Cbor encoding do not work.

Hex

Hex

Hex

Hex

Concatenation of policy id and asset name in Hex

Time in milliseconds

Plutus scripts need to be double Cbor encoded. Raw compiled scripts without any Cbor encoding do not work.

Hex

Plutus scripts need to be double Cbor encoded. Raw compiled scripts without any Cbor encoding do not work.