Helios API/ API Reference/ Classes/

NetworkEmulator

A simple emulated Network. This can be used to do integration tests of whole dApps. Staking is not yet supported.

Implements

Implements

Index

Constructors

constructor

new NetworkEmulator(seed?)

Instantiates a NetworkEmulator at slot 0. An optional seed number can be specified, from which all emulated randomness is derived.

Parameters

NameType
seed?number

Accessors

currentSlot

get currentSlot(): bigint

Returns

bigint

Methods

createUtxo

createUtxo(wallet, lovelace, assets?): void

Creates a UTxO using a GenesisTx.

Parameters

NameType
walletSimpleWallet
lovelacebigint
assets?Assets

Returns

void

createWallet

createWallet(lovelace?, assets?): SimpleWallet

Creates a new SimpleWallet and populates it with a given lovelace quantity and assets. Special genesis transactions are added to the emulated chain in order to create these assets.

Parameters

NameType
lovelace?bigint
assets?Assets

Returns

SimpleWallet

dump

dump(): void

Returns

void

getParameters

getParameters(): Promise<NetworkParams>

Returns

Promise<NetworkParams>

Implementation of

Network.getParameters

getUtxo

getUtxo(id): Promise<TxInput>

Throws an error if the UTxO isn't found

Parameters

NameType
idTxOutputId

Returns

Promise<TxInput>

Implementation of

Network.getUtxo

getUtxos

getUtxos(address): Promise<TxInput[]>

Parameters

NameType
addressAddress

Returns

Promise<TxInput[]>

Implementation of

Network.getUtxos

initNetworkParams

initNetworkParams(networkParams): NetworkParams

Creates a new NetworkParams instance that has access to current slot (so that the Tx validity range can be set automatically during Tx.finalize()).

Parameters

NameType
networkParamsNetworkParams

Returns

NetworkParams

isConsumed

isConsumed(utxo): boolean

Parameters

NameType
utxoTxInput

Returns

boolean

submitTx

submitTx(tx): Promise<TxId>

Parameters

NameType
txTx

Returns

Promise<TxId>

Implementation of

Network.submitTx

tick

tick(nSlots): void

Mint a block with the current mempool, and advance the slot by a number of slots.

Parameters

NameType
nSlotsbigint

Returns

void

warnMempool

warnMempool(): void

Returns

void