The constructor function takes a SupraConfig object as a parameter and assigns it to the config property.
A SupraConfig object that contains information about the network on which the Supra client is running.
A predefined network (Network.MAINNET, Network.TESTNET or Network.DEVNET) sets the RPC URL and the
chain ID; any other node needs both rpcUrl and chainId.
import { Network, SupraClient } from "supra-ts-sdk";
// Options:1 (Predefined network: Network.MAINNET, Network.TESTNET or Network.DEVNET)
const supra = new SupraClient({ network: Network.TESTNET });
// Options:2 (Custom node)
const custom = new SupraClient({ network: Network.CUSTOM, rpcUrl: "http://localhost:27001", chainId: 255 });
// Options:3 (Custom node, without `network`)
const local = new SupraClient({ rpcUrl: "http://localhost:27001", chainId: 255 });
// Offline signing: no request reads the node's chain ID
const offline = new SupraClient({ network: Network.MAINNET, verifyChainId: false });
// Gas settings for every transaction of the client, and a longer request timeout
const configured = new SupraClient({
network: Network.TESTNET,
maxGas: 20_000n,
gasUnitPrice: 100_000n,
timeoutMs: 60_000,
});
The constructor sends no request. The node's chain ID is read before the first signature and checked against the configured one; see SupraConfig.
Checks the configured chain ID against the node's. The node's chain ID is the one the client keeps for its
signatures: read from the x-supra-chain-id header of an earlier response or with
GET /rpc/v3/transactions/chain_id, once per client. Every signature performs the same check, so calling this
method is optional; it reports a mismatch before any transaction is built. It reads the node's chain ID also
when verifyChainId is false.
Returns the chain ID of the node the client is configured for. It is read from the x-supra-chain-id header of
an earlier response or with GET /rpc/v3/transactions/chain_id, once per client, and it is the chain ID that
signatures are checked against. It is not compared with the configured chain ID; validateChainId() does that.
With verifyChainId: false the configured chain ID is returned and no request is sent.
Chain ID of the node
Reads the node's transaction parameters with GET /rpc/v3/transactions/parameters:
max_transaction_time_to_live_seconds is the most seconds after the node's clock that the node accepts as a
transaction's expiration time (600 on Mainnet, Testnet and Devnet). The client reads it once, when a builder
that sends requests or a signature first needs it, and checks expiration times against it; this method sends a
new request and the client uses the value it returns from then on.
The node's transaction parameters
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const parameters = await supra.getTransactionParameters();
console.log(parameters.max_transaction_time_to_live_seconds);
}
runExample().catch(console.error);
Reads the node's build information with GET /rpc/v3/version. release is the node release tag, for example
supra_node_v12.0.0.rc7; it is absent from the response of a node older than supra_node_v12.0.0, so it is
undefined for a v11 node.
version, release (when the node reports it), branch, commit_hash, build_time and build_env
Reads the median gas unit price, in quants, from GET /rpc/v3/transactions/estimate_gas_price
(median_gas_price): the median over the last transactions the RPC node executed, which can be below the node's
minimum. Transactions that set no price do not carry it as such; they carry getEstimatedGasUnitPrice(), the
larger of the median and the minimum.
The median gas unit price
Reads the minimum gas unit price that the node's gas schedule configures, in quants, from
GET /rpc/v3/transactions/estimate_gas_price (min_configured_gas_price). The node refuses a transaction with a
lower price (SupraGasUnitPriceBelowMinimumError). Transactions that set no price carry
getEstimatedGasUnitPrice(), which is not below it.
The minimum gas unit price
Reads the gas unit price that a transaction carries when neither the call nor SupraConfig.gasUnitPrice sets
one: the larger of the median gas price (median_gas_price) and the minimum gas price
(min_configured_gas_price) of GET /rpc/v3/transactions/estimate_gas_price, in quants. A caller can read it
and pass a price derived from it as gasUnitPrice, which the builders that make no request require.
The estimated gas unit price
Forgets the client's sequence-number counter of address and its records of the account's transactions that
the client submitted. The next transaction of that account that a helper builds reads the sequence number from
the chain again.
The client keeps, per account, the account's sequence number on the chain and a record of each transaction that
it submitted and that can still commit, for the transactions that its helpers (transferSupraCoin,
transferCoin, transferSupraFungibleAsset, transferFungibleAsset, migrateCoinToFungibleStore,
publishPackage, cancelAutomationTask, stopAutomationTasks, the multisig helpers and the entry functions of
Contract.fromABI) send, and for the transactions submitted through
its submit methods (see SupraConfig). The chain is read again automatically when the node reports a stale
number, including after the account has sent transactions by other means (another client or process, a wallet);
a call whose number such a transaction holds while it is pending is refused.
A reset also forgets the records of this client's pending transactions of the account: the next helper call takes the account's number on the chain, which such a transaction holds, and the node refuses it until that transaction has committed. Call this method when no transaction of this client from the account is pending, or when the expiration times of those that are have passed.
The account whose counter is reset.
Check whether given account exists onchain or not
The address of the account to query.
true if account exists otherwise false. The node reports an absent account with HTTP 404 on v12
and HTTP 400 with a "Resource not found" message on v11; both give false.
Any other failure, such as an unreachable node, a timeout, a rate limit (HTTP 429) or a node fault (HTTP 5xx), is thrown and does not mean the account is absent.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const isAccountExists = await supra.account.isAccountExists({ accountAddress });
console.log(isAccountExists);
}
runExample().catch(console.error);
Queries the current state of an account, including its sequence number and authentication key.
The address of the account to query.
A Promise that resolves to an AccountData object containing the sequence number and authentication key of the account.
For an account that does not exist: HTTP 404 on v12, HTTP 400 on v11. See "HTTP status codes by node version" in the README.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountData = await supra.account.getAccountInfo({ accountAddress: accountAddress });
console.log(accountData);
}
runExample().catch(console.error);
Queries the modules of an account.
The address of the account to query.
Optionaloptions?: { count?: number; start?: string }Optionalcount?: numberThe number of modules to return.
Optionalstart?: stringThe cursor of the previous page. Omit it, or pass undefined, for the first page.
A Promise that resolves to an array of MoveModuleBytecode objects representing the modules of the account with optional cursor.
cursor is undefined when there are no more modules; see PaginatedResponse.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const {response: accountModules, cursor} = await supra.account.getAccountModules({ accountAddress: accountAddress });
console.log(accountModules);
}
runExample().catch(console.error);
Queries a specific module of an account.
The address of the account to query.
The name of the module to query.
A Promise that resolves to a MoveModuleBytecode object representing the module of the account.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountModule = await supra.account.getAccountModule({ accountAddress: accountAddress, moduleName: "module_name" });
console.log(accountModule);
}
runExample().catch(console.error);
Queries the resources of an account.
The address of the account to query.
Optionaloptions?: { count?: number; start?: string }Optionalcount?: numberThe number of resources to return.
Optionalstart?: stringThe cursor of the previous page. Omit it, or pass undefined, for the first page.
A Promise that resolves to an array of MoveResource objects representing the resources of the account with optional cursor.
cursor is undefined when there are no more resources; see PaginatedResponse.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const {response: accountResources, cursor} = await supra.account.getAccountResources({ accountAddress: accountAddress });
console.log(accountResources);
}
runExample().catch(console.error);
Queries a specific resource of an account.
The type of the resource to be returned.
The address of the account to query.
The type of the resource to query.
A Promise that resolves to a MoveResource object representing the resource of the account.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountResource = await supra.account.getAccountResource({ accountAddress: accountAddress, resourceType: "0x1::account::Account" });
console.log(accountResource);
}
runExample().catch(console.error);
Queries the transactions of an account.
The type of the transaction to be returned.
The address of the account to query.
Optionaloptions?: { count?: number; start?: string | number | bigint; ascending?: boolean }Optionalcount?: numberThe number of transactions to return.
Optionalstart?: string | number | bigintThe sequence number to start from, inclusive in both orders, or the cursor of
the previous page. Omit it for the most recent transactions (descending) or the first ones (ascending).
Optionalascending?: booleanWhether to return the transactions in ascending order.
A Promise that resolves to an array of TransactionResponse objects representing the transactions of the account with optional cursor. The items are user transactions.
options.count defaults to 20 on the node; the SDK rejects a value outside 1 to 100.x-supra-cursor header. The SDK computes
cursor as the sequence number after the last transaction of the page in the requested order, so it is
passed back as start like the cursor of the other feeds. It is undefined when the page is empty, or ends
at sequence number 0 in descending order.import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const {response: accountTransactions, cursor} = await supra.account.getAccountTransactions({ accountAddress: accountAddress });
console.log(accountTransactions);
}
runExample().catch(console.error);
Queries the coin transactions of an account: the transactions that touched a CoinStore of the account. It does
not list SUPRA held in a primary fungible store (a chain created from the supra_node_v12.0.0 genesis, such as
Devnet, holds all SUPRA there), so the page is empty for an account whose only movements are of that SUPRA. For
those, use Account.getAccountFaTransactions on the account's primary store (all networks) or
Account.getAccountHistory (nodes from supra_node_v12.0.0).
The type of the transaction to be returned.
The address of the account to query.
Optionaloptions?: {Optionalcount?: numberThe number of transactions to return.
Optionalstart?: stringThe cursor of the previous page, exclusive. Omit it, or pass undefined, for the first page.
Optionalascending?: booleanWhether to return the transactions in ascending order.
Optionaltype?: TransactionQueryTypeReturn only transactions of this type. "settlement" requires a node from v12
onwards; older nodes reject it with HTTP 400. A page filtered by type can be empty and still carry a cursor.
A Promise that resolves to an array of TransactionResponse objects representing the coin transactions of the account with optional cursor.
Items can be of any txn_type, including settlement items, which have no header, payload or
authenticator; narrow on txn_type before reading them. cursor is undefined when there are no more
transactions; see PaginatedResponse.
options.count defaults to 20 on the node; the SDK rejects a value outside 1 to 100."0" ends the feed, as v11 nodes end it, except for the first request of an
ascending read with a type filter: block 0 has timestamp 0, so the cursor "0" can mean that the page
scanned only a genesis row that the filter excluded. The SDK then returns "0", and the request with
start "0" continues the feed or ends it, so the rule costs at most one more request.import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const {response: accountCoinTransactions , cursor} = await supra.account.getAccountCoinTransactions({ accountAddress: accountAddress });
console.log(accountCoinTransactions);
}
runExample().catch(console.error);
Queries the fungible asset transactions of one fungible store: the finalized transactions that withdrew from or
deposited to that store. The feed lists the movements of the store only; an account address returns an empty
page. Derive an account's primary store with Account.getPrimaryStoreAddress. To list everything that
concerns an account, use Account.getAccountHistory (nodes from supra_node_v12.0.0).
The type of the transaction to be returned.
The address of the fungible store to query, for example the result of Account.getPrimaryStoreAddress. It is not the address of the account that owns the store.
Optionaloptions?: {Optionalcount?: numberThe number of transactions to return.
Optionalstart?: stringThe cursor of the previous page, exclusive. Omit it, or pass undefined, for the first page.
Optionalascending?: booleanWhether to return the transactions in ascending order.
Optionaltype?: TransactionQueryTypeReturn only transactions of this type. "settlement" requires a node from v12
onwards; older nodes reject it with HTTP 400. A page filtered by type can be empty and still carry a cursor.
A Promise that resolves to the transactions of the store with an optional cursor. Items can be of
any txn_type; narrow on txn_type before reading header, payload or authenticator. cursor is
undefined when there are no more transactions; see PaginatedResponse.
options.count defaults to 20 on the node; the SDK rejects a value outside 1 to 100."0" ends the feed, as v11 nodes end it, except for the first request of an
ascending read with a type filter: block 0 has timestamp 0, so a store funded at genesis has a row with the
cursor 0, and the cursor "0" can mean that the page scanned only that row and the filter excluded it. The
SDK then returns "0", and the request with start "0" continues the feed or ends it, so the rule costs
at most one more request.import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const storeAddress = await supra.account.getPrimaryStoreAddress({ accountAddress: "0x1" });
const { response: faTransactions, cursor } = await supra.account.getAccountFaTransactions({ storeAddress });
console.log(faTransactions.length, cursor);
}
runExample().catch(console.error);
Returns the address of the primary fungible store of an account for a fungible asset, by calling
0x1::primary_fungible_store::primary_store_address. The address is computed from the owner and the metadata
and does not show that the store exists. It is the storeAddress that Account.getAccountFaTransactions
takes.
The address of the account that owns the store.
OptionalmetadataAddress?: AccountAddressInputThe address of the fungible asset's metadata object. Default: SUPRA (0xa).
A Promise that resolves to the store address, as the node renders it.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const storeAddress = await supra.account.getPrimaryStoreAddress({ accountAddress: "0x1" });
console.log(storeAddress);
}
runExample().catch(console.error);
Beta
Queries the transaction history of an account: every finalized transaction that concerns the account, once
each, with the categories it matched for the account. It lists the transfers of SUPRA held in primary
fungible stores (the fa category), which getAccountCoinTransactions does not.
Preview: wraps an API added in supra_node_v12.0.0, which may change until that release reaches Testnet.
The type of the transaction to be returned.
The address of the account to query.
Optionaloptions?: {Optionalcategories?: readonly AccountHistoryCategory[]Return only transactions that matched at least one of these categories:
"sent" (the account sent it), "coin" (coins moved in or out of the account), "fa" (a fungible asset
store the account owned moved), "da" (a digital asset or object event names the account). Default: all four.
Optionalcount?: numberThe number of entries to scan for, 1 to 100 (default 20 on the node).
Optionalascending?: booleanWhether to return the entries in ascending order. Default descending.
Optionalstart?: stringThe cursor of the previous page, exclusive. Omit it, or pass undefined, for the first page.
A Promise that resolves to the entries { categories, transaction } with an optional cursor, the
indexedFrom height (x-supra-history-indexed-from) and the oldestBlock height (x-supra-oldest-block)
when the node sends them; see AccountHistoryPage.
supra_node_v12.0.0 (Devnet). Mainnet and Testnet nodes at v11.7.x answer HTTP 404
for the route, which this method throws as SupraRouteUnsupportedError, a SupraNotFoundError.categories while it scans the account's history, and reads at most 8 rows for each
entry requested, so a page can hold fewer entries than count, or none, before the history is exhausted.
The feed ends only when cursor is undefined, that is, when the response has no x-supra-cursor header.
An empty page that has a cursor, and the cursor "0", do not end it.indexedFrom.import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.DEVNET });
async function runExample() {
const accountAddress = "0x1";
let cursor: string | undefined;
do {
const page = await supra.account.getAccountHistory({
accountAddress,
options: { categories: ["sent", "fa"], count: 50, start: cursor },
});
for (const { categories, transaction } of page.response) {
console.log(transaction.hash, categories);
}
cursor = page.cursor;
} while (cursor !== undefined);
}
runExample().catch(console.error);
Queries the auto transactions of an account.
The type of the transaction to be returned.
The address of the account to query.
Optionaloptions?: { count?: number; block_height?: number; cursor?: string; ascending?: boolean }Optionalcount?: numberThe number of transactions to return.
Optionalblock_height?: numberStarting block height (inclusive). Optional.
The block height at which to start lookup for transactions. If provided, returns options.count transactions starting from it in the order set by options.ascending.
Optionalcursor?: stringThe cursor of the previous page, exclusive. Omit it, or pass undefined, for the first page.
If provided, returns options.count transactions after this cursor in the order set by options.ascending.
If not specified, the lookup starts at options.block_height when it is given.
Optionalascending?: booleanWhether to return the transactions in ascending order.
A Promise that resolves to an array of AutoTransactionResponse objects representing the auto transactions of the account with optional cursor.
cursor is undefined when there are no more transactions; see PaginatedResponse.
options.count defaults to 20 on the node; the SDK rejects a value outside 1 to 100.options.block_height is ignored when options.cursor is given: if both are given, options.cursor has
precedence.import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const {response: accountAutoTransactions, cursor} = await supra.account.getAccountAutoTransactions({ accountAddress: accountAddress });
console.log(accountAutoTransactions);
}
runExample().catch(console.error);
Queries the number of coin types an account holds: the legacy coins (CoinStore resources of the account) plus
SUPRA when the account holds it as a fungible asset and has no CoinStore<SupraCoin> (an account that migrated
its SUPRA with migrateCoinToFungibleStore has none), so SUPRA counts once.
The node has no listing of an account's fungible asset stores, so fungible assets other than SUPRA are not
counted.
The address of the account to query.
A Promise that resolves to the number of legacy coins plus one when SUPRA is held as a fungible asset only.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountCoinsCount = await supra.account.getAccountCoinsCount({ accountAddress: accountAddress });
console.log(accountCoinsCount);
}
runExample().catch(console.error);
Queries the total SUPRA balance of an account in quants: the CoinStore<SupraCoin> balance plus the balance of the
account's SUPRA fungible asset store (0x1::coin::balance, which includes the paired fungible asset). The value
is the SUPRA the account owns whichever form it is held in; getAccountSupraBalance reports the two
forms separately. A fungible asset transfer (transferSupraFungibleAsset) moves only the fungible asset
part.
The address of the account to query.
A Promise that resolves to the total SUPRA balance of the account.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountSupraCoinBalance = await supra.account.getAccountSupraCoinBalance({ accountAddress: accountAddress });
console.log(accountSupraCoinBalance);
}
runExample().catch(console.error);
Queries the SUPRA balance of an account in quants, in total and by the form in which it is held: as a legacy coin
(CoinStore<SupraCoin>) and as a fungible asset (the primary store of the SUPRA fungible asset 0xa).
total is 0x1::coin::balance, which already includes the fungible asset balance, so the two parts are not
added twice. The two values are read by separate requests.
The address of the account to query.
A Promise that resolves to { total, coin, fungibleAsset }.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const { total, coin, fungibleAsset } = await supra.account.getAccountSupraBalance({ accountAddress: accountAddress });
console.log(total, coin, fungibleAsset);
}
runExample().catch(console.error);
Queries the balance of a coin or fungible asset owned by an account. What the balance covers depends on asset:
0x1::supra_coin::SupraCoin): 0x1::coin::balance, the CoinStore balance plus the balance of
the paired fungible asset store.0xa for SUPRA): 0x1::primary_fungible_store::balance, the account's primary store
of that asset only. SUPRA held in a CoinStore is not included, so the balance of 0xa is 0 for an account
that has not migrated its SUPRA.The address of the account to query.
The coin type or the address of the fungible asset to query.
A Promise that resolves to the balance of the coin or fungible asset owned by the account.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountSupraCoinBalance = await supra.account.getAccountCoinBalance({ accountAddress: accountAddress, asset: "0x1::supra_coin::SupraCoin" });
console.log(accountSupraCoinBalance);
}
runExample().catch(console.error);
Fund an account with the node's faucet. The request is sent on any network; a node that does not serve
the faucet answers with an error status, which is thrown as a SupraAPIError. The faucet answers before its
transaction executes: pass the returned hash to supra.transaction.waitForTransaction before spending the funds.
The address to fund.
A Promise that resolves to a FaucetTransactionResponse object, the hash of the faucet transaction.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const faucetResponse = await supra.faucet.fundAccountWithFaucet({ accountAddress: accountAddress });
console.log(faucetResponse);
}
runExample().catch(console.error);
Read a faucet transaction by its hash.
The hash returned by fundAccountWithFaucet.
A Promise that resolves to the faucet transaction.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const { hash } = await supra.faucet.fundAccountWithFaucet({ accountAddress: "0x1" });
const transaction = await supra.faucet.getFaucetTransaction({ transactionHash: hash });
console.log(transaction.status);
}
runExample().catch(console.error);
Queries on-chain transactions by their transaction hash, returning both pending and committed transactions.
The arguments for querying the transaction.
The transaction hash should be a hex-encoded bytes string with a 0x prefix.
Optionaltype?: TransactionQueryTypeThe type of transaction to query. "settlement" requires a node from v12 onwards; older
nodes reject it with HTTP 400.
Optionalexclude_uncommitted?: booleanWhether to exclude uncommitted transactions.
A Promise that resolves to a TransactionResponse object. Only user and automated transactions have
header, payload and authenticator; narrow on txn_type before reading them.
HTTP 404 for an unknown hash. A hash that is not hexadecimal is HTTP 400 on v12 and HTTP 404 on v11. See "HTTP status codes by node version" in the README.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
// Fetch a transaction by its hash
const transaction = await supra.transaction.getTransactionByHash({ transactionHash: "0x123" }); // replace with a real transaction hash
console.log(transaction);
}
runExample().catch(console.error);
Beta
Looks up several transactions by hash in one request (POST /rpc/v4/transactions/by_hashes). 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.
Each hash is resolved as Transaction.getTransactionByHash resolves it, with the same type and
exclude_uncommitted, and the transactions are the /rpc/v4 form of the single-hash route's body (events carry
hash; inclusion_proof is present with include_proof). A hash the node does not know does not fail the
request: its entry has transaction: null. A hash that is repeated is answered at each position.
The node bounds the request and the response (set by the operator; defaults below):
rest_limits.transactions_by_hashes.max_hashes), repeats included; anything else is HTTP 400.128 * max_hashes + 1024 bytes is HTTP 413.omitted. The first hash is always answered; request the omitted hashes again for the rest.The transaction hashes, each a hex-encoded string with a 0x prefix.
Optionaltype?: TransactionQueryTypeLook only for transactions of this type. "settlement" is accepted by this route.
Optionalexclude_uncommitted?: booleanWhether to exclude uncommitted transactions. Without it, a user transaction
that is submitted and not final has the status Pending or PendingAfterExecution and null block_header
and output.
Optionalinclude_proof?: booleanWhether to include the inclusion proof, computed against the latest transactions
inclusion certificate the node holds. inclusion_proof is null for a transaction of a block above it.
A Promise that resolves to { transactions, omitted }: transactions holds one { hash, transaction }
per answered hash in request order, and omitted the requested hashes that were not answered.
HTTP 400 for no hashes or more than the node's limit, HTTP 413 for a body above its
limit, and the status getTransactionByHash would report when the lookup of the first hash fails.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.DEVNET });
async function runExample() {
const { transactions, omitted } = await supra.transaction.getTransactionsByHashes({
transactionHashes: ["0x" + "11".repeat(32), "0x" + "22".repeat(32)], // replace with real transaction hashes
});
for (const { hash, transaction } of transactions) {
console.log(hash, transaction === null ? "unknown" : transaction.status);
}
console.log("not answered:", omitted);
}
runExample().catch(console.error);
Beta
Reads the lifecycle of one cross-VM crossing of native SUPRA between SupraMVM and SupraEVM
(GET /rpc/v4/transactions/settlements/{settlement_id}): every stage the node still holds (recorded, credited,
applied, refunded or cleared), its queue entry while it waits to be applied, and the height the node had
executed to. A crossing is recorded by one block and settled by a later one, so it is not a single transaction.
Needs a node from supra_node_v12.0.0; Mainnet and Testnet nodes of supra_node_v11.7.x answer HTTP 404 for
the route, which is thrown as SupraRouteUnsupportedError.
Preview: wraps an API added in supra_node_v12.0.0, which may change until that release reaches Testnet.
The crossing's identity: 0x followed by 64 hex digits.
A Promise that resolves to the Settlement.
When the node has no record of the crossing, which includes one it has not executed yet and an outbound crossing that predates its history.
When the crossing was recorded below the node's oldest retained block: whether it existed cannot be told.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.DEVNET });
async function runExample() {
const settlement = await supra.transaction.getSettlement({ settlementId: "0x" + "00".repeat(32) }); // replace with a real settlement id
console.log(settlement.stages.map((stage) => stage.stage), settlement.pending);
}
runExample().catch(console.error);
Beta
Lists the cross-VM crossings one address is party to, oldest first
(GET /rpc/v4/transactions/settlements). 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.
The address, 0x-prefixed: at most 32 bytes for domain "move" (a string or a
HexString), at most 20 bytes for "evm". A shorter address is left-padded with zeros to the domain's width,
so "0x1" is the Move address 0x0...01; a longer one is rejected before any request.
Which side of the chain the address belongs to. The two domains' addresses can share their bytes, so the domain is required.
Optionaloptions?: { role?: SettlementRole; count?: number; start?: string }Optionalrole?: SettlementRoleOnly the crossings the address sent ("sender") or received ("recipient"). Both by default.
Optionalcount?: numberThe number of crossings to return, 1 to 100; the node's default is 20.
Optionalstart?: stringThe cursor of the previous page, verbatim. Omit it, or pass undefined, for the
first page. An empty string is not sent.
A Promise that resolves to the crossings of the page, the cursor of the next page and the height of the
node's oldest block. cursor is undefined on the last page; a page can hold fewer than count crossings, or
none, and still carry a cursor, so follow the cursor until it is undefined.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.DEVNET });
async function runExample() {
let start: string | undefined;
do {
const page = await supra.transaction.getSettlements({
address: "0x" + "11".repeat(20), // replace with a real address
domain: "evm",
options: { start },
});
for (const settlement of page.response) {
console.log(settlement.settlement_id, settlement.stages.length);
}
start = page.cursor;
} while (start !== undefined);
}
runExample().catch(console.error);
Reads a transaction by its hash and tells whether it has no final status yet.
The arguments for querying the transaction.
The transaction hash should be a hex-encoded bytes string with a 0x prefix.
A Promise that resolves to true when the status is Pending or PendingAfterExecution, and to false
when it is Success, Fail or Invalid.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
// Read a transaction by its hash
const isPending = await supra.transaction.isPendingTransaction({ transactionHash: "0x123" }); // replace with a real transaction hash
console.log(isPending);
}
runExample().catch(console.error);
Waits until a transaction has a final status and returns it.
Statuses of a transaction:
Pending: the RPC node accepted the transaction and it is not executed yet. Not final.PendingAfterExecution: the transaction was executed and discarded with a status that may change in a later
execution (for example SEQUENCE_NUMBER_TOO_NEW). Not final. A transaction that keeps this status does not
commit; it can be submitted again once the cause is resolved.Success: executed successfully. Final.Fail: executed and failed (for example a Move abort or Out of gas); the sequence number was incremented and
the gas was charged. Final.Invalid: discarded, and discarded on every execution; the sequence number was not incremented. Final.The transaction is read again while its status is not final and while a read fails, including HTTP 404 for a transaction the node has not seen yet. The timeout is wall-clock time from the start of the call.
The transaction hash should be a hex-encoded bytes string with a 0x prefix.
Optionaloptions?: WaitForTransactionOptionsThe timeout and whether a final status other than Success throws; see
WaitForTransactionOptions. Optional.
A Promise that resolves to the transaction with its final status: Success, or any final status when
checkSuccess is false.
SupraTransactionFailedError (with hash, status, vm_status, major_status, sub_status and
transaction) when the final status is Fail or Invalid and checkSuccess is not false.
SupraTransactionTimeoutError (with hash and lastStatus) when there is no final status within the
timeout.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
// Wait for a transaction to commit
const transaction = await supra.transaction.waitForTransaction({
transactionHash: "0x123", // replace with a real transaction hash
options: { timeoutMs: 30_000 },
});
console.log(transaction);
}
runExample().catch(console.error);
Generates signature message for supra transaction using AnyRawTransaction
a RawTransaction, MultiAgentRawTransaction or FeePayerRawTransaction
Signature message
import { BCS, Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const account = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const rawTxn = supra.transaction.build.rawTxnObject({
senderAddress: account.address(),
senderSequenceNumber: 0n, // the account's sequence number
function: "0x1::supra_account::transfer",
functionTypeArgs: [],
functionArgs: [new SupraAccount().address().toUint8Array(), BCS.bcsSerializeUint64(10000n)],
optionalTransactionPayloadArgs: { gasUnitPrice: await supra.getEstimatedGasUnitPrice() },
});
const signatureMessage = supra.transaction.getTransactionSignatureMessage({ rawTxn });
console.log(signatureMessage);
}
runExample().catch(console.error);
Sign any supra transaction. signer authenticator to be used to submit the transaction.
the account to sign on the transaction
a RawTransaction, MultiAgentRawTransaction or FeePayerRawTransaction
A promise of the ed25519 signature as a HexString for a RawTransaction, and of the signer's
AccountAuthenticatorEd25519 for a MultiAgentRawTransaction or FeePayerRawTransaction.
SupraChainIdMismatchError before signing when the client's chain ID or the chain ID of rawTxn is not
the node's. The node's chain ID is read before the first signature of the client; with verifyChainId: false
nothing is read or checked and no request is sent.
RangeError before signing when the expiration time of rawTxn is more than the node's maximum time to
live after the current time (the maximum is read once per client; see getTransactionParameters(); not checked
with verifyChainId: false), and the error of a failed read of that maximum
import { BCS, Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const account = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const rawTxn = supra.transaction.build.rawTxnObject({
senderAddress: account.address(),
senderSequenceNumber: (await supra.account.getAccountInfo({ accountAddress: account.address() })).sequence_number,
function: "0x1::supra_account::transfer",
functionTypeArgs: [],
functionArgs: [new SupraAccount().address().toUint8Array(), BCS.bcsSerializeUint64(10000n)],
optionalTransactionPayloadArgs: { gasUnitPrice: await supra.getEstimatedGasUnitPrice() },
});
const signature = await supra.transaction.signTransaction({ senderAccount: account, rawTxn });
console.log(signature.toString());
}
runExample().catch(console.error);
Sign any supra transaction. signer authenticator to be used to submit the transaction.
the account to sign on the transaction
a RawTransaction, MultiAgentRawTransaction or FeePayerRawTransaction
A promise of the ed25519 signature as a HexString for a RawTransaction, and of the signer's
AccountAuthenticatorEd25519 for a MultiAgentRawTransaction or FeePayerRawTransaction.
SupraChainIdMismatchError before signing when the client's chain ID or the chain ID of rawTxn is not
the node's. The node's chain ID is read before the first signature of the client; with verifyChainId: false
nothing is read or checked and no request is sent.
RangeError before signing when the expiration time of rawTxn is more than the node's maximum time to
live after the current time (the maximum is read once per client; see getTransactionParameters(); not checked
with verifyChainId: false), and the error of a failed read of that maximum
import { BCS, Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const account = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const rawTxn = supra.transaction.build.rawTxnObject({
senderAddress: account.address(),
senderSequenceNumber: (await supra.account.getAccountInfo({ accountAddress: account.address() })).sequence_number,
function: "0x1::supra_account::transfer",
functionTypeArgs: [],
functionArgs: [new SupraAccount().address().toUint8Array(), BCS.bcsSerializeUint64(10000n)],
optionalTransactionPayloadArgs: { gasUnitPrice: await supra.getEstimatedGasUnitPrice() },
});
const signature = await supra.transaction.signTransaction({ senderAccount: account, rawTxn });
console.log(signature.toString());
}
runExample().catch(console.error);
Sign any supra transaction. signer authenticator to be used to submit the transaction.
the account to sign on the transaction
a RawTransaction, MultiAgentRawTransaction or FeePayerRawTransaction
A promise of the ed25519 signature as a HexString for a RawTransaction, and of the signer's
AccountAuthenticatorEd25519 for a MultiAgentRawTransaction or FeePayerRawTransaction.
SupraChainIdMismatchError before signing when the client's chain ID or the chain ID of rawTxn is not
the node's. The node's chain ID is read before the first signature of the client; with verifyChainId: false
nothing is read or checked and no request is sent.
RangeError before signing when the expiration time of rawTxn is more than the node's maximum time to
live after the current time (the maximum is read once per client; see getTransactionParameters(); not checked
with verifyChainId: false), and the error of a failed read of that maximum
import { BCS, Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const account = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const rawTxn = supra.transaction.build.rawTxnObject({
senderAddress: account.address(),
senderSequenceNumber: (await supra.account.getAccountInfo({ accountAddress: account.address() })).sequence_number,
function: "0x1::supra_account::transfer",
functionTypeArgs: [],
functionArgs: [new SupraAccount().address().toUint8Array(), BCS.bcsSerializeUint64(10000n)],
optionalTransactionPayloadArgs: { gasUnitPrice: await supra.getEstimatedGasUnitPrice() },
});
const signature = await supra.transaction.signTransaction({ senderAccount: account, rawTxn });
console.log(signature.toString());
}
runExample().catch(console.error);
Derives the transaction hash from a signed transaction: the Keccak-256 of its BCS bytes, the hash the node gives
the transaction. The submit helpers derive the hash the same way before they submit, and report it in
SupraSubmissionOutcomeUnknownError when the outcome of the submission request is unknown.
The signed transaction.
The transaction hash as a 0x-prefixed lower-case hex string, the form getTransactionByHash and
waitForTransaction accept.
Publish a package or module on the Supra network with 0x1::code::publish_package_txn. 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.
Module Publisher KeyPair
The BCS-encoded package metadata (the package-metadata.bcs file of a build)
The bytecode of each module of the package
OptionaloptionalTransactionArgs?: OptionalTransactionArgsoptional arguments for transaction. The gas settings in
optionalTransactionPayloadArgs apply to the transaction; without maxGas it is estimated
(see OptionalTransactionPayloadArgs). The object is not modified.
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 { readFileSync } from "node:fs";
import { Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const account = new SupraAccount(); // an account that holds SUPRA
async function runExample() {
const response = await supra.transaction.publishPackage({
senderAccount: account,
packageMetadata: readFileSync("build/MyPackage/package-metadata.bcs"),
modulesCode: [readFileSync("build/MyPackage/bytecode_modules/my_module.mv")],
});
console.log(response);
}
runExample().catch(console.error);
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);
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);
Queries a Move view function. The arguments are encoded and the results converted to TypeScript values by the
function's ABI, which the method reads from the node unless args.abi is given (u64, u128 and u256
results are bigint).
A parameter or return type that is or contains a type parameter (T, vector<T>, 0x1::option::Option<T>, a
struct over T) is converted with each type parameter replaced by its type argument: identity<T>(x: T): T
called with the type argument u64 takes a bigint and returns a bigint. An 0x1::object::Object<…> argument
is given as its address; inside a vector or an Option it is sent as { inner: <address> }, the form the
node reads there.
A node before supra_node_v12.0.0 reads every type parameter as address. A generic view whose type parameter
occurs in a parameter or return type (outside 0x1::object::Object<…>) therefore needs a node from
supra_node_v12.0.0 unless its type argument is address or signer, or is 0x1::object::Object<…> and the
type parameter is the whole parameter or return type. For such a call the client reads GET /rpc/v3/version
and keeps a release once the node reports one; on a node that reports none the call throws SupraError before
the view request is sent, and the next such call reads the version again. Behind a load balancer whose nodes run
different releases, as during an upgrade, the node that answers the version request need not be the node that
answers the view. Calls with only address-like type arguments make no version request and work on both.
The type of the MoveValue array to be returned.
The data needed to generate a View Function payload.
OptionaltypeArguments?: TypeArgument[]OptionalfunctionArguments?: SimpleEntryFunctionArgumentTypes[]Optionalabi?: MoveModuleA Promise that resolves to an array of MoveValue objects.
If a type argument that needs a node from supra_node_v12.0.0 (see above) is given and the
node reports no release.
import { Network, SupraClient, TypeTagParser } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const supraCoin = new TypeTagParser("0x1::supra_coin::SupraCoin").parseTypeTag();
const accountSupraBalance = await supra.methods.view({
function: "0x1::coin::balance",
functionArguments: [accountAddress],
typeArguments: [supraCoin]
});
console.log("Account supra balance:", accountSupraBalance[0]);
}
runExample().catch(console.error);
Queries a Move view function without type conversion or parsing: the arguments are sent as given and the
results are returned as the node's JSON, where u64, u128 and u256 values are strings. It does not check the
node's release: a node before supra_node_v12.0.0 reads an argument of a type parameter as an address whatever
the type argument.
The type of the array to be returned.
The data needed to generate a View Function payload.
OptionaltypeArguments?: string[]OptionalfunctionArguments?: SimpleEntryFunctionArgumentTypesRaw[]A Promise that resolves to an array of values.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const accountAddress = "0x1";
const accountSupraBalance = await supra.methods.viewRaw({
function: "0x1::coin::balance",
functionArguments: [accountAddress],
typeArguments: ["0x1::supra_coin::SupraCoin"]
});
console.log("Account supra balance:", accountSupraBalance[0]);
}
runExample().catch(console.error);
Beta
Executes several Move view functions in one request (POST /rpc/v4/view/batch). 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.
Each element takes the arguments of Methods.view: the SDK reads the ABI of each module once for the
whole batch (unless the element has abi), encodes the arguments and converts the results to TypeScript
values (u64, u128 and u256 results are bigint). All elements run against one snapshot of the node's
Move state, in request order, and share a gas budget; an element reached after the budget is spent is not
executed and its entry is an error with status 400.
An element the node fails when it executes it (a Move abort, OUT_OF_GAS) does not fail the others: its entry
holds error, with the status and message POST /rpc/v4/view gives for it, and no exception is thrown. An
element that names a module or function that does not exist throws while the SDK reads the ABI, before any
request is sent, unless the caller passes abi; so does an element whose arguments do not match its ABI, as
view does. The ABI reads happen before the route is called, so on a v11.7.x node they run before the 404 is
answered.
The view functions, as for Methods.view. The node accepts 1 to 20 by default
(rest_limits.view_batch.max_view_functions, set by the operator) and answers HTTP 400 outside its range.
A Promise that resolves to { state_height, results }: state_height is the height of the last block
the node had executed in the snapshot (null before any), and results has one entry per request, in order,
holding result or error.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.DEVNET });
async function runExample() {
const { state_height, results } = await supra.methods.viewBatch({
requests: [
{ function: "0x1::timestamp::now_microseconds" },
{ function: "0x1::coin::balance", typeArguments: ["0x1::supra_coin::SupraCoin"], functionArguments: ["0x1"] },
],
});
for (const entry of results) {
if (entry.error) {
console.log("failed", entry.error.status, entry.error.message);
} else {
console.log(entry.result[0]);
}
}
console.log("as of block", state_height);
}
runExample().catch(console.error);
Query a table item on Supra.
The type of the response data to be returned.
The table handle.
The key type, the value type and the key of the item; see TableItemRequest.
A Promise that resolves to the table item's value as the node returns it, without type conversion.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const handle = "0x1";
const key = "0x1";
const keyType = "address";
const valueType = "u64";
const tableItem = await supra.table.getTableItem({ handle: handle, data: { key_type: keyType, value_type: valueType, key: key }});
console.log(tableItem);
}
runExample().catch(console.error);
Get the events of the given type.
SUPRA deposits are 0x1::coin::CoinDeposit events (field account) where SUPRA is held in a CoinStore, and
0x1::fungible_asset::Deposit events (field store, the fungible store, not the account) where it is held in
a primary fungible store.
Type of event
The options object is required and can be empty.
OptionalstartHeight?: numberStarting block height (inclusive)
OptionalendHeight?: numberEnding block height (exclusive)
Optionallimit?: numberMaximum number of events to return. Defaults to 20, max 100.
Optionalstart?: stringThe cursor of the previous page, a hex string. Omit it, or pass undefined, for the first page.
A Promise that resolves to an array of events, with the cursor of the next page. cursor is
undefined when there are no more events; a page can hold fewer than limit events and still carry a
cursor. See PaginatedResponse.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const eventType = "0x1::coin::CoinDeposit";
const {response: events, cursor} = await supra.events.getEventsByType({ eventType: eventType, options: {} });
console.log(events);
}
runExample().catch(console.error);
Get the meta information of the most recently finalized and executed block.
A Promise that resolves to a FinalizedBlockHeader object.
Get information about the block that has been finalized at the given height.
The height of the block to retrieve.
Optionaloptions?: { withFinalizedTransactions?: boolean; type?: TransactionQueryType }OptionalwithFinalizedTransactions?: booleanWhether to include the transactions in the block.
Optionaltype?: TransactionQueryTypeInclude only the transactions of this type. "settlement" requires a node from
v12 onwards; older nodes reject it with HTTP 400.
A Promise that resolves to a FinalizedBlockHeader object. Its transactions can contain any
txn_type, including settlement items, which have no header, payload or authenticator.
Get the header and execution output statistics of the block with the given hash.
The hash of the block to retrieve.
A Promise that resolves to a FinalizedBlockHeader object.
HTTP 404 for an unknown block. A hash that is not hexadecimal is HTTP 400 on v12 and HTTP 404 on v11. See "HTTP status codes by node version" in the README.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const blockHash = "0x1";
const block = await supra.block.getBlockByHash({ blockHash: blockHash });
console.log(block);
}
runExample().catch(console.error);
Get a list containing the hashes of the transactions that were finalized in the block with the given hash in the order that they were executed.
The hash of the block to retrieve.
Optionaloptions?: { type?: TransactionQueryType }Optionaltype?: TransactionQueryTypeReturn only the hashes of transactions of this type. "settlement" requires a
node from v12 onwards; older nodes reject it with HTTP 400.
A Promise that resolves to a string array.
HTTP 404 for an unknown block. A hash that is not hexadecimal is HTTP 400 on v12 and HTTP 404 on v11. See "HTTP status codes by node version" in the README.
import { SupraClient,Network } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const blockHash = "0x1";
const transactions = await supra.block.getTransactionsByBlockHash({ blockHash: blockHash });
console.log(transactions);
}
runExample().catch(console.error);
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);
Cancels a user automation task of the sender with 0x1::automation_registry::cancel_task. A task that has not
run yet is removed and half of its deposit is refunded. An active task is marked cancelled: it runs until the end
of the current automation cycle, and its deposit is refunded then. The transaction aborts when the task does not
exist, is not the sender's, is a system task or is already cancelled, and while the registry moves to the next
cycle.
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 owner of the task.
The index of the task in the automation registry, a u64: the task_index of the
0x1::automation_registry::AutomationTaskMetaData event of its registration.
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.
Before any request, when taskIndex is not an integer from 0 to 2^64 - 1 (a number must
be a safe integer).
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 owner = new SupraAccount(); // the account that registered the task
async function runExample() {
const response = await supra.automation.cancelAutomationTask({
senderAccount: owner,
taskIndex: 42n,
optionalTransactionArgs: { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true } },
});
console.log(response.hash, response.status);
}
runExample().catch(console.error);
Stops user automation tasks of the sender at once with 0x1::automation_registry::stop_tasks. Each task is
removed from the registry; its deposit is refunded (half of it for a task that has not run yet) together with half
of its fee for the rest of the current automation cycle. Indexes of tasks that do not exist are skipped. The
transaction aborts when a task is not the sender's or is a system task, and while the registry moves to the next
cycle.
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 owner of the tasks.
The indexes of the tasks in the automation registry, each a u64: the task_index of
the 0x1::automation_registry::AutomationTaskMetaData event of the task's registration. At least one.
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.
Before any request, when taskIndexes is empty or one of its elements is not an integer
from 0 to 2^64 - 1 (a number must be a safe integer).
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 owner = new SupraAccount(); // the account that registered the tasks
async function runExample() {
const response = await supra.automation.stopAutomationTasks({
senderAccount: owner,
taskIndexes: [42n, 43n],
optionalTransactionArgs: { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true } },
});
console.log(response.hash, response.status);
}
runExample().catch(console.error);
Creates a multisig account (0x1::multisig_account::create_with_owners) owned by the sender and
additionalOwners, and returns its address.
The address is derived from the sender's address and the sequence number of the creating transaction, as the
framework derives it (deriveMultisigAccountAddress); it is returned whether or not the call waits for the
commit, and the account exists once the transaction has executed successfully. When the submission's outcome is
unknown (SupraSubmissionOutcomeUnknownError) no address is returned; the error's sender and sequenceNumber
give it. The account holds no SUPRA at first; send SUPRA to its address to fund transactions it executes.
The account that creates the multisig account and becomes one of its owners.
OptionaladditionalOwners?: AccountAddressInput[]The addresses of the other owners. The sender must not be in the list and the list must hold no duplicates.
The number of approvals a proposal needs, from 1 to the number of owners (the sender included).
OptionaltimeoutDurationSecs?: number | bigintThe time in seconds that a proposal can be executed after its creation, at
least MIN_MULTISIG_TIMEOUT_DURATION_SECS (300). Default DEFAULT_MULTISIG_TIMEOUT_DURATION_SECS (seven days).
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
A Promise that resolves to the account's address and the SubmitTransactionResponse of the creating
transaction. Submit describes the statuses and errors of a submission.
When the estimating simulation or an enabled simulation does not succeed,
for example when signaturesRequired exceeds the number of owners.
import { Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const senderAccount = new SupraAccount(); // an account that holds SUPRA
const secondOwner = new SupraAccount().address();
async function runExample() {
const { multisigAddress } = await supra.multisig.createMultisigAccount({
senderAccount: senderAccount,
additionalOwners: [secondOwner],
signaturesRequired: 2,
optionalTransactionArgs: { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true } },
});
console.log(multisigAddress);
}
runExample().catch(console.error);
Proposes a transaction of a multisig account with its payload stored on chain
(0x1::multisig_account::create_transaction). The proposal has the sender's approval. Any owner can execute it
once it has enough approvals, with executeMultisigTransaction, which sends no payload for it.
The proposal's number is the next of getMultisigSequenceNumbers before the call (when no other owner
proposes at the same time).
An owner of the multisig account.
The address of the multisig account.
The entry function the multisig account runs.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
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 owner of the multisig account, holding SUPRA
const multisigAddress = "0x1234"; // replace with the address of the multisig account
async function runExample() {
const response = await supra.multisig.proposeMultisigTransaction({
senderAccount: senderAccount,
multisigAddress: multisigAddress,
payload: { function: "0x1::supra_account::transfer", functionArgs: ["0x2", 1000n] },
optionalTransactionArgs: { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true } },
});
console.log(response);
}
runExample().catch(console.error);
Proposes a transaction of a multisig account storing only the SHA3-256 hash of its payload on chain
(0x1::multisig_account::create_transaction_with_hash). The executor provides the payload:
executeMultisigTransaction with the same payload checks it against the stored hash and sends it.
An owner of the multisig account.
The address of the multisig account.
The entry function the multisig account runs.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
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 owner of the multisig account, holding SUPRA
const multisigAddress = "0x1234"; // replace with the address of the multisig account
async function runExample() {
const response = await supra.multisig.proposeMultisigTransactionWithHash({
senderAccount: senderAccount,
multisigAddress: multisigAddress,
payload: { function: "0x1::supra_account::transfer", functionArgs: ["0x2", 1000n] },
});
console.log(response);
}
runExample().catch(console.error);
Approves a proposal of a multisig account (0x1::multisig_account::approve_transaction). An owner who has
rejected the proposal changes the vote to an approval.
An owner of the multisig account.
The address of the multisig account.
The proposal's number, from 1.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
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 owner of the multisig account, holding SUPRA
const multisigAddress = "0x1234"; // replace with the address of the multisig account
async function runExample() {
const response = await supra.multisig.approveMultisigTransaction({
senderAccount: senderAccount,
multisigAddress: multisigAddress,
sequenceNumber: 1,
});
console.log(response);
}
runExample().catch(console.error);
Rejects a proposal of a multisig account (0x1::multisig_account::reject_transaction). An owner who has
approved the proposal changes the vote to a rejection. With enough rejections, any owner can remove the proposal
with executeRejectedMultisigTransaction.
An owner of the multisig account.
The address of the multisig account.
The proposal's number, from 1.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
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 owner of the multisig account, holding SUPRA
const multisigAddress = "0x1234"; // replace with the address of the multisig account
async function runExample() {
const response = await supra.multisig.rejectMultisigTransaction({
senderAccount: senderAccount,
multisigAddress: multisigAddress,
sequenceNumber: 1,
});
console.log(response);
}
runExample().catch(console.error);
Executes the next proposal of a multisig account, the one after the last executed or removed. The method reads the proposal first and sends the transaction that matches it:
proposeMultisigTransaction) is executed without a payload when the call
gives none; the node reads it from the proposal. When the call gives a payload, it must encode to the stored
bytes, and it is sent, so that the node checks the match when it executes the transaction.proposeMultisigTransactionWithHash) is executed with the call's
payload, whose SHA3-256 hash must be the stored one.The sender pays the gas and the proposal runs as the multisig account. The node executes the proposal only when
it has enough approvals (counting the sender's implicit approval) and has not timed out; otherwise it refuses
the transaction. The proposal can change between the read and the submission (another owner executes it first).
A call that gave a payload is then refused by the node, because the payload is not the next proposal's; a call
without a payload runs the proposal that is next when the node executes it, or is refused when that is a
proposal that stores only a hash. Give the payload when the queue is shared.
The nodes of v11.7.0 and v12.0.0.rc6 do not simulate an execution without a payload (they report
MISSING_DATA). The max gas estimate and enableTransactionSimulation therefore simulate the execution with the
stored payload carried, and the sent transaction, its signature and its hash are those of the execution without
a payload. A simulation skips the multisig checks of the node: it does not detect missing approvals, an expired
proposal or a payload that is not the stored one, so enableTransactionSimulation does not tell whether the node
will accept the execution.
An owner of the multisig account.
The address of the multisig account.
Optionalpayload?: MultisigEntryFunctionPayloadThe entry function of the proposal. Required for a proposal that stores only a hash; optional for one that stores its payload.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
A Promise that resolves to a SubmitTransactionResponse. Submit describes the statuses and
errors of a submission. A final status of Success means the multisig transaction was executed; whether the
proposal's own function succeeded is in the transaction's events.
Before submitting, when the proposal stores only a hash and payload is
missing or hashes to another value, when the proposal stores its payload and payload encodes to other bytes, or
when the stored payload cannot be decoded and the call needs a simulation (it has no maxGas, or enables
enableTransactionSimulation; give maxGas and leave the simulation off).
import { Network, SupraAccount, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const senderAccount = new SupraAccount(); // an owner of the multisig account, holding SUPRA
const multisigAddress = "0x1234"; // replace with the address of the multisig account
async function runExample() {
const response = await supra.multisig.executeMultisigTransaction({
senderAccount: senderAccount,
multisigAddress: multisigAddress,
optionalTransactionArgs: { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true } },
});
console.log(response);
}
runExample().catch(console.error);
Removes the next proposal of a multisig account when it has enough rejections or has timed out
(0x1::multisig_account::execute_rejected_transaction). The sender's own rejection is counted. Proposals are
resolved in order, so a proposal that cannot be executed blocks the queue until it is removed this way.
An owner of the multisig account.
The address of the multisig account.
OptionaloptionalTransactionArgs?: OptionalTransactionArgsOptional transaction arguments (see OptionalTransactionArgs).
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 owner of the multisig account, holding SUPRA
const multisigAddress = "0x1234"; // replace with the address of the multisig account
async function runExample() {
const response = await supra.multisig.executeRejectedMultisigTransaction({
senderAccount: senderAccount,
multisigAddress: multisigAddress,
});
console.log(response);
}
runExample().catch(console.error);
Reads the positions in a multisig account's queue of proposals: the number of the last executed or removed proposal and the number the next new proposal gets. The two are read with two requests.
The address of the multisig account.
A Promise that resolves to { lastResolved, next }; proposals lastResolved + 1 to next - 1 are
pending.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const { lastResolved, next } = await supra.multisig.getMultisigSequenceNumbers({ multisigAddress: "0x1234" });
console.log(lastResolved, next);
}
runExample().catch(console.error);
Reads a proposal of a multisig account with its votes (0x1::multisig_account::get_transaction).
The address of the multisig account.
The proposal's number, from 1.
A Promise that resolves to the MultisigProposal.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const proposal = await supra.multisig.getMultisigProposal({ multisigAddress: "0x1234", sequenceNumber: 1 });
console.log(proposal.votes);
}
runExample().catch(console.error);
Reads the next proposal of a multisig account to execute or remove, with its votes.
The address of the multisig account.
A Promise that resolves to the MultisigProposal, or undefined when the queue is empty.
import { Network, SupraClient } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
async function runExample() {
const proposal = await supra.multisig.getNextMultisigProposal({ multisigAddress: "0x1234" });
console.log(proposal?.sequenceNumber);
}
runExample().catch(console.error);
ReadonlyconfigA copy of the SupraConfig the client was constructed with: either a predefined network (Mainnet, Testnet or
Devnet) or the rpcUrl and chainId of a custom node, with the optional settings described by SupraConfig.
ReadonlynetworkThe networkInformation property is A NetworkConfig object that contains information about the network on which the Supra client is running.
ReadonlyaccountAccount instance provides methods for interacting with accounts related operations on the Supra network.
ReadonlytransactionTransaction instance provides methods for interacting with transactions related operations on the Supra network.
ReadonlycontractContract instance provides methods for interacting with contracts related operations on the Supra network.
ReadonlyfaucetFaucet instance provides methods for interacting with faucets related operations on the Supra network.
ReadonlymethodsMethods instance provides general functions for interacting with the Supra network.
ReadonlytableTable instance provides methods for interacting with tables related operations on the Supra network.
ReadonlycoinCoin instance provides methods for interacting with coin related operations on the Supra network.
ReadonlyeventsEvents instance provides methods for interacting with events related operations on the Supra network.
ReadonlyblockBlock instance provides methods for interacting with block related operations on the Supra network.
ReadonlyfungibleFungibleAsset instance provides methods for interacting with fungible asset related operations on the Supra network.
ReadonlymultisigMultisig instance provides methods for the lifecycle of multisig accounts on the Supra network.
ReadonlyautomationAutomation instance provides methods for managing the automation tasks of an account on the Supra network.
The SupraClient class is the main entry point for interacting with the SupraClient sdk. It takes a SupraConfig object as a parameter and use the NetworkConfig property to interact with the Supra rest api.