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
Name | Type |
---|---|
seed? | number |
Accessors
currentSlot
• get
currentSlot(): bigint
Returns
bigint
Methods
createUtxo
▸ createUtxo(wallet
, lovelace
, assets?
): void
Creates a UTxO using a GenesisTx.
Parameters
Name | Type |
---|---|
wallet | SimpleWallet |
lovelace | bigint |
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
Name | Type |
---|---|
lovelace? | bigint |
assets? | Assets |
Returns
dump
▸ dump(): void
Returns
void
getParameters
▸ getParameters(): Promise
<NetworkParams
>
Returns
Promise
<NetworkParams
>
Implementation of
getUtxo
▸ getUtxo(id
): Promise
<TxInput
>
Throws an error if the UTxO isn't found
Parameters
Name | Type |
---|---|
id | TxOutputId |
Returns
Promise
<TxInput
>
Implementation of
getUtxos
▸ getUtxos(address
): Promise
<TxInput
[]>
Parameters
Name | Type |
---|---|
address | Address |
Returns
Promise
<TxInput
[]>
Implementation of
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
Name | Type |
---|---|
networkParams | NetworkParams |
Returns
isConsumed
▸ isConsumed(utxo
): boolean
Parameters
Name | Type |
---|---|
utxo | TxInput |
Returns
boolean
submitTx
▸ submitTx(tx
): Promise
<TxId
>
Parameters
Name | Type |
---|---|
tx | Tx |
Returns
Promise
<TxId
>
Implementation of
tick
▸ tick(nSlots
): void
Mint a block with the current mempool, and advance the slot by a number of slots.
Parameters
Name | Type |
---|---|
nSlots | bigint |
Returns
void
warnMempool
▸ warnMempool(): void
Returns
void