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

x/lucid/mod.ts>Emulator

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.
Very Popular
Latest
class Emulator
implements Provider
Re-export
import { Emulator } from "https://deno.land/x/lucid@0.10.10/mod.ts";

Constructors

new
Emulator(accounts: { address: Address; assets: Assets; outputData?: OutputData; }[], protocolParameters?: ProtocolParameters)

Properties

blockHeight: number
chain: Record<RewardAddress, { registeredStake: boolean; delegation: Delegation; }>

Only stake key registrations/delegations and rewards are tracked. Other certificates are not tracked.

datumTable: Record<DatumHash, Datum>
ledger: Record<FlatOutRef, { utxo: UTxO; spent: boolean; }>
mempool: Record<FlatOutRef, { utxo: UTxO; spent: boolean; }>
protocolParameters: ProtocolParameters
slot: number
time: UnixTime

Methods

awaitBlock(height?)
awaitSlot(length?)
awaitTx(txHash: string): Promise<boolean>

Emulates the behaviour of the reward distribution at epoch boundaries. Stake keys need to be registered and delegated like on a real chain in order to receive rewards.

getDatum(datumHash: DatumHash): Promise<Datum>
getDelegation(rewardAddress: RewardAddress): Promise<Delegation>
getUtxoByUnit(unit: string): Promise<UTxO>
getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>
getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>
getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>
log()
submitTx(tx: Transaction): Promise<TxHash>