createContractClient
ContractClient
provides a set of methods for interacting with TON smart contracts: deploy them, call their methods, read state, and more.
Import
import { createContractClient } from '@fotonjs/core';
Usage
Initialize the client with provided contract, public and wallet clients:
import { walletClient, publicClient, createContractClient } from './client';
import Contract from './Contract';
const contractClient = createContractClient({
contract: Contract,
publicClient,
walletClient,
address: '0:123...def',
});
Then you can call any of the contract's methods:
const state = await counterClient.read({
getter: 'getState',
arguments: [],
});
Parameters
contract
- Type:
CompiledContract
A contract class compiled from Tact or FunC language files. It must implement the Contract
interface.
const contractClient = createContractClient({
contract: Contract,
publicClient,
walletClient,
});
publicClient
- Type:
PublicClient
An instance of the PublicClient
.
const contractClient = createContractClient({
contract: Contract,
publicClient,
walletClient,
});
walletClient
- Type:
WalletClient
An instance of the WalletClient
.
const contractClient = createContractClient({
contract: Contract,
publicClient,
walletClient,
});
address (optional)
- Type:
string
- Default:
undefined
The address of the deployed contract on the blockchain. If not provided, write
and read
methods on the CounterClient
will throw an error.