Advanced Example
A more complex example showcasing genesis block state configuration with walletsConfig
and deployment of multiple contracts is shown below.
ts
See code in contextconst assets = TestAssetId.random(2);
const message = new TestMessage({ amount: 1000 });
using counterContractNode = await launchTestNode({
walletsConfig: {
count: 4,
assets,
coinsPerAsset: 2,
amountPerCoin: 1_000_000,
messages: [message],
},
contractsConfigs: [
{
factory: CounterFactory,
walletIndex: 3,
options: { storageSlots: [] },
},
],
});
const {
contracts: [counterContract],
wallets: [wallet1, wallet2, wallet3, wallet4],
} = counterContractNode;
console.assert(
counterContract instanceof CounterFactory,
'CounterFactory is not instance of CounterFactory'
);
console.assert(wallet1 instanceof WalletUnlocked, 'Wallet1 is not instance of WalletUnlocked');
console.assert(wallet2 instanceof WalletUnlocked, 'Wallet2 is not instance of WalletUnlocked');
console.assert(wallet3 instanceof WalletUnlocked, 'Wallet3 is not instance of WalletUnlocked');
console.assert(wallet4 instanceof WalletUnlocked, 'Wallet4 is not instance of WalletUnlocked');
Summary
- All points listed in the basic example apply here as well.
- Multiple wallets were generated with highly-specific coins and messages.
- It's possible to specify the wallet to be used for contract deployment via
walletIndex
. - The test contract can be deployed with all the options available for real contract deployment.