Skip to main content
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
Go to Latest
class Emulator
implements Provider
Re-export
import { Emulator } from "https://deno.land/x/lucid@0.10.1/mod.ts";

Constructors

new
Emulator(accounts: { address: Address; assets: Assets; }[], 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>
distributeRewards(rewards: Lovelace)

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>
getProtocolParameters(): Promise<ProtocolParameters>
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()
now(): UnixTime
submitTx(tx: Transaction): Promise<TxHash>