emulator.emulator
Home > @blaze-cardano/emulator > Emulator
Emulator class
The Emulator class is used to simulate the behavior of a ledger. It maintains a ledger of unspent transaction outputs, reward accounts, protocol parameters, and a clock. It also provides methods to start and stop an event loop for the ledger.
Signature:
export declare class Emulator
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Constructs a new emulator instance seeded with the provided genesis outputs. |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
Map<RewardAccount, RegisteredAccount> |
The map of reward accounts and their balances. | ||
|
Record<PoolId, PoolParameters> | |||
|
boolean | |||
|
Committee | |||
|
The clock of the ledger. | |||
|
ConstitutionCore | |||
|
Record<DatumHash, PlutusData> |
A lookup table of hashes to datums. | ||
|
bigint | |||
|
Record<Hash28ByteBase16, DRepState> | |||
|
Evaluator |
The script evaluator for the emulator | ||
|
ReturnType<typeof setInterval> |
(Optional) The event loop for the ledger. | ||
|
bigint | |||
|
Map<string, Wallet> |
A map from label to blaze instance for that wallet | ||
|
ProtocolParameters |
The protocol parameters of the ledger. | ||
|
Record<number, StakeSnapshot> | |||
|
bigint |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
Returns the current change address for a labelled wallet, creating the wallet if it has not been initialised yet. | ||
|
Adds a given UTxO to the Emulator's ledger. Overwrites any existing UTxO with the same input. | ||
|
Executes the supplied callback in the context of a labelled wallet and Blaze client, simplifying multi-party test flows. | ||
|
Forces block production until the referenced transaction leaves the mempool. | ||
|
Asserts that completing the provided transaction fails with an optional matching error message. Helps validate negative Plutus scenarios. | ||
|
Submits a transaction requiring multiple labelled wallets to co-sign. Each signer is resolved via | ||
|
Completes, signs, and submits a transaction, throwing if validation fails. Retains the CBOR for debugging in line with emulator troubleshooting flow. | ||
|
Mints a synthetic genesis UTxO to the labelled wallet to seed it with funds. | ||
|
Retrieves the cached hot credential for the provided committee cold hash. | ||
|
Calculates the treasury's share of accumulated fees based on the current parameters. | ||
|
Returns the lifecycle status for a governance action, if the emulator is tracking it. | ||
|
Retrieves an output from the ledger by input. | ||
|
Computes the latest ratification tallies for an action using the most recent stake snapshot. | ||
|
Locates the synthetic script reference UTxO for the provided script. | ||
|
Attaches the provided script to a genesis-style UTxO so tests can reference it via | ||
|
Funds and registers a labelled wallet, returning its default change address. | ||
|
Removes a given UTxO from the Emulator's ledger by input. | ||
|
Assigns or clears the active hot credential for a committee member. Throws when the supplied cold credential hash is not part of the committee. | ||
|
Replaces the current constitutional committee and resets cached hot credentials. Clearing the committee also clears the last enacted constitution per Conway §5.5. | ||
|
Converts a slot index back into a unix timestamp (ms). | ||
|
Starts the event loop for the ledger. If the event loop is already running, it is cleared and restarted. The event loop calls the stepForwardBlock method every 20 slots. | ||
|
Advances exactly one block (20 slots) according to the emulator clock. | ||
|
Advances the emulator to the first slot of the next epoch. Mirrors the epoch boundary workflow defined in the Conway ledger spec. | ||
|
Advances the emulator forward to the provided slot, triggering epoch transitions and materialising the mempool as needed. | ||
|
Advances time to the slot corresponding to the provided unix timestamp. | ||
|
Stops the event loop for the ledger. If the event loop is running, it is cleared. | ||
|
Submits a transaction to the ledger. | ||
|
Converts a unix timestamp (ms) into a slot using the current slot configuration. | ||
|
Retrieves the Emulator's ledger as an array of UTxOs. |