Test and emulate
Test and emulate transactions with the builtin emulator.
Initialize emulator
The emulator serves as a unique provider in Lucid, and it can be instantiated in the same way as any other provider. This provides a seamless experience, allowing for easy substitution of the emulator with a real network provider.
const emulator = new Emulator([{
address: "addr_test...",
assets: { lovelace: 3000000000n },
}]);
const lucid = new Lucid({ provider: emulator });
Working with time ranges
Unfortunately Date.now()
doesn't work with the emulator because the network is not live and steps are only taken when requested. Instead you have to use emulator.now()
;
const tx = await lucid.newTx()
.validTo(emulator.now())
.commit();
Distribute staking rewards
The emulator allows you to conveniently distribute rewards to all delegated stake addresses.
emulator.distributeRewards(100000000n);