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.
Reads the name, symbol and decimals of a coin type from the 0x1::coin::CoinInfo resource that the account
defining the coin holds.
Type of the coin, for example 0x1::supra_coin::SupraCoin
CoinInfo
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const coinType = "0x1::supra_coin::SupraCoin";
const coinInfo = await supra.coin.getCoinInfo({ coinType: coinType });
console.log(coinInfo);
}
runExample().catch(console.error);
Transfer SUPRA from one account to another with 0x1::supra_account::transfer_coins. The transfer moves SUPRA
held in the sender's CoinStore or in its fungible asset store.
The sequence number comes from the client's counter unless optionalTransactionPayloadArgs.sequenceNumber is
set, and the client submits its calls from one account one after another. The client checks the chain ID of its
node before it signs; see SupraConfig.
The account sending the SUPRA.
The address of the account receiving the SUPRA. The account is created when it does not exist.
The amount of SUPRA to transfer, in quants.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments. The gas settings in
optionalTransactionPayloadArgs apply to the transaction; without maxGas it is estimated
(see OptionalTransactionPayloadArgs). The object is not modified.
A Promise that resolves to a SubmitTransactionResponse. Submit describes the statuses and
errors of a submission.
When the node refuses the submission or a simulation because the gas
unit price is below its minimum (this replaces SupraSimulationFailedError and SupraAPIError for that refusal).
When the submission request times out, fails before the node
answers or is answered with a 5xx status other than 503 (after the wait, with enableWaitForTransaction).
import { Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const senderAccount = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const receiverAccountAddress = "0x2";
const amount = 100n;
const transactionResponse = await supra.coin.transferSupraCoin({ senderAccount: senderAccount, receiverAccountAddress: receiverAccountAddress, amount: amount });
console.log(transactionResponse);
}
runExample().catch(console.error);
Transfer a coin from one account to another with 0x1::supra_account::transfer_coins.
The sequence number comes from the client's counter unless optionalTransactionPayloadArgs.sequenceNumber is
set, and the client submits its calls from one account one after another. The client checks the chain ID of its
node before it signs; see SupraConfig.
The account sending the coin.
The address of the account receiving the coin.
The amount of the coin to transfer, in the smallest unit of the coin (quants for SUPRA).
The type of the coin to transfer.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments. The gas settings in
optionalTransactionPayloadArgs apply to the transaction; without maxGas it is estimated
(see OptionalTransactionPayloadArgs). The object is not modified.
A Promise that resolves to a SubmitTransactionResponse. Submit describes the statuses and
errors of a submission.
When the node refuses the submission or a simulation because the gas
unit price is below its minimum (this replaces SupraSimulationFailedError and SupraAPIError for that refusal).
When the submission request times out, fails before the node
answers or is answered with a 5xx status other than 503 (after the wait, with enableWaitForTransaction).
import { Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const senderAccount = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const receiverAccountAddress = "0x2";
const amount = 100n;
const coinType = "0x1::supra_coin::SupraCoin";
const transactionResponse = await supra.coin.transferCoin({ senderAccount: senderAccount, receiverAccountAddress: receiverAccountAddress, amount: amount, coinType: coinType });
console.log(transactionResponse);
}
runExample().catch(console.error);
The Coin class provides methods for interacting with the legacy coins on the Supra network.