BetaBeta
The constructor function takes a NetworkConfig object as a parameter and assigns it to the networkInformation property.
A NetworkConfig object that contains information about the network on which the Supra client is running.
Beta
The fromABI function takes an array of MoveModule (Contract ABI) objects as input.
contracts.<module name>.view.<function>(args) calls a view function and returns its results converted to
TypeScript values, as methods.view does, including the type parameters of generic views: a type argument that
an earlier node reads differently needs a node from supra_node_v12.0.0, and the call throws SupraError before
the view request on an earlier node (see methods.view). contracts.<module name>.entry.<function>(args) builds,
signs and submits an entry function
transaction: the &signer argument is the sender's SupraAccount, optionalTransactionPayloadArgs and
enableTransactionWaitAndSimulationArgs are optional, the sequence number comes from the client's counter unless
optionalTransactionPayloadArgs.sequenceNumber is set, the client submits its calls from one account one after
another, and the client checks the chain ID of its node before it signs; see SupraConfig. Without a maxGas the max gas is estimated (see
OptionalTransactionPayloadArgs).
An array of MoveModule (Contract ABI) objects.
An object with a contracts property which contains view and entry properties.
import { Network, SupraClient } from "supra-ts-sdk";
const COIN_ABI = {
address: "0x1",
name: "coin",
friends: [],
exposed_functions: [
{
name: "balance",
visibility: "public",
is_entry: false,
is_view: true,
generic_type_params: [{ constraints: [] }],
params: ["address"],
return: ["u64"],
},
],
structs: [],
} as const;
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const instance = supra.contract.fromABI([COIN_ABI] as const);
let balance = await instance.contracts.coin.view.balance({
functionArguments: ["0x10cdf6e0c4c5c762bb23be3eac5c7eaa272c1b4abe0573cd1386c5632b7992ca"],
typeArguments: ["0x1::supra_coin::SupraCoin"]
})
console.log("Balance:", balance[0]);
}
runExample().catch(console.error);
The Contract class provides methods for interacting with the Supra network.