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.
Get the metadata of a fungible asset: the 0x1::fungible_asset::Metadata resource stored at the address of the
asset.
The address of the fungible asset.
A Promise that resolves to the metadata of the fungible asset.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const assetAddress = "0xa"; // the SUPRA fungible asset
const fungibleAssetMetadata = await supra.fungibleAsset.getFungibleAssetMetadata({ assetAddress: assetAddress });
console.log(fungibleAssetMetadata);
}
runExample().catch(console.error);
Beta
Reads the accounting of native SUPRA across the chain's two VMs (GET /rpc/v4/supply/native): native SUPRA on
SupraEVM, the value in flight between the two sides, the sub-quant remainder, the quants awaiting a burn, the
total those claim against the SupraMVM escrow, and the escrow's own balance, all as of the height the node had
executed to. Needs a node from supra_node_v12.0.0; Mainnet and Testnet nodes of supra_node_v11.7.x answer
HTTP 404, which is thrown as SupraRouteUnsupportedError.
Preview: wraps an API added in supra_node_v12.0.0, which may change until that release reaches Testnet.
A Promise that resolves to the NativeSupply. escrow_shortfall_wei is the amount claimed
beyond what the escrow holds and is "0" whenever the mirror is fully backed; escrow_balance_quants and
escrow_shortfall_wei are null only when the node could not read the escrow. Wei figures are decimal strings.
The *_quants figures are bigint and exact above Number.MAX_SAFE_INTEGER.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.DEVNET });
async function runExample() {
const supply = await supra.fungibleAsset.getNativeSupply();
console.log(supply.evm_supply_wei, supply.escrow_shortfall_wei, supply.in_flight.count);
}
runExample().catch(console.error);
Transfer the SUPRA fungible asset from one account to another (0x1::primary_fungible_store::transfer).
The transfer moves SUPRA held in the sender's primary fungible store only; SUPRA held in a CoinStore is not
part of it. The sender's fungible asset balance is read first, and when it is below amount the method throws
SupraInsufficientFungibleAssetBalanceError, naming the fungible asset balance and the coin balance,
without submitting a transaction. migrateCoinToFungibleStore moves the coin balance into the fungible
store; supra.coin.transferSupraCoin transfers SUPRA held in either form.
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 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 in its fungible asset store
async function runExample() {
const receiverAccountAddress = "0x2";
const amount = 100n;
const transactionResponse = await supra.fungibleAsset.transferSupraFungibleAsset({ senderAccount: senderAccount, receiverAccountAddress: receiverAccountAddress, amount: amount });
console.log(transactionResponse);
}
runExample().catch(console.error);
Migrates the sender's balance of a coin type from its CoinStore resource to the primary fungible store of the
paired fungible asset (0x1::coin::migrate_to_fungible_store). The coin store is removed; the balance is
unchanged as reported by 0x1::coin::balance and is available to fungible asset transfers afterwards. The
transaction aborts when the chain has the migration disabled or the coin type has no coin info.
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 whose balance is migrated.
OptionalcoinType?: `${string}::${string}::${string}`The coin type to migrate. Defaults to SUPRA, 0x1::supra_coin::SupraCoin.
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.
import { Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const senderAccount = new SupraAccount(); // an account that holds SUPRA in its CoinStore
async function runExample() {
const transactionResponse = await supra.fungibleAsset.migrateCoinToFungibleStore({
senderAccount: senderAccount,
optionalTransactionArgs: { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true } },
});
console.log(transactionResponse);
}
runExample().catch(console.error);
Transfer a fungible asset from one account to another (0x1::primary_fungible_store::transfer). When
assetAddress is the SUPRA fungible asset (0xa) the method behaves as transferSupraFungibleAsset:
it throws SupraInsufficientFungibleAssetBalanceError without submitting when the sender's fungible
asset balance is below amount.
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 fungible asset.
The address of the account receiving the fungible asset.
The amount of the fungible asset to transfer, in its smallest unit.
The address of the fungible asset 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 the fungible asset
async function runExample() {
const receiverAccountAddress = "0x2";
const amount = 100n;
const assetAddress = "0x000000000000000000000000000000000000000000000000000000000000000a";
const transactionResponse = await supra.fungibleAsset.transferFungibleAsset({ senderAccount: senderAccount, receiverAccountAddress: receiverAccountAddress, amount: amount, assetAddress: assetAddress });
console.log(transactionResponse);
}
runExample().catch(console.error);
The FungibleAsset class provides methods for interacting with the FungibleAsset on the Supra network.