Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Basic Example

Icon LinkBasic Example

Let's use launchTestNode with the counter contract from the Fuel dApp tutorial .

Note: you will have to change the import paths of the contract factory and bytecode to match your folder structure.

// #import { launchTestNode };
 
import { TestContract__factory } from 'path/to/typegen/output';
import bytecode from 'path/to/typegen/output/TestContract.hex.ts';
 
using launched = await launchTestNode({
  contractsConfigs: [
    {
      deployer: TestContract__factory,
      bytecode,
    },
  ],
});
 
const {
  contracts: [contract],
  provider,
  wallets,
} = launched;
 
const response = await contract.functions.get_count().call();

Icon LinkSummary

  1. The launched variable was instantiated with the using Icon Link keyword.
  2. launchTestNode spun up a short-lived fuel-core node, deployed a contract to it and returned it for testing.
  3. The deployed contract is fully typesafe because of launchTestNode's type-level integration with typegen outputs.
  4. Besides the contract, you've got the provider and wallets at your disposal.