### Install Supra-L1-SDK Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/index.html Install the supra-l1-sdk using npm. This command is used to add the SDK to your project dependencies. ```bash npm install supra-l1-sdk ``` -------------------------------- ### Example SupraAccountObject Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html An example of the SupraAccountObject structure returned by toPrivateKeyObject. It includes the account address, public key, and private key in hexadecimal format. ```javascript { address: "0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591", publicKeyHex: "0xf56d8524faf79fbc0f48c13aeed3b0ce5dd376b4db93b8130a107c0a5e04ba04", privateKeyHex: `0x009c9f7c992a06cfafe916f125d8adb7a395fca243e264a8e56a4b3e6accf940 d2b11e9ece3049ce60e3c7b4a1c58aebfa9298e29a30a58a67f1998646135204` } ``` -------------------------------- ### Get Account Resources Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve all resources held by an account, with support for pagination to fetch resources in batches. ```typescript const resourcesResponse = await supraClient.getAccountResources( account.address(), { count: 10 } ); resourcesResponse.resources.forEach((resource) => { console.log("Type:", resource.type); console.log("Data:", JSON.stringify(resource.data)); }); console.log("Cursor:", resourcesResponse.cursor); ``` -------------------------------- ### HexString Constructor Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/HexString.html Initializes a new HexString instance. If the provided string already starts with '0x', it will not add another prefix. ```APIDOC ## new HexString(hexString) ### Description Creates a new HexString instance from a regular string. If the specified string already starts with "0x" prefix, it will not add another one. ### Parameters #### Path Parameters * **hexString** (string) - Required - String to convert ### Returns [HexString](HexString.html) ### Example ```javascript const string = "string"; new HexString(string); // "0xstring" ``` ``` -------------------------------- ### Get Coin Info Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves information about a specific coin type. ```APIDOC ## GET /api/coin/info ### Description Get coin info of the given coin type. ### Method GET ### Endpoint /api/coin/info ### Parameters #### Query Parameters - **coinType** (string) - Required - Type of a coin resource ### Response #### Success Response (200) - **coinInfo** (CoinInfo) - Information about the coin #### Response Example ```json { "coinInfo": { "name": "Bitcoin", "symbol": "BTC", "decimals": 8 } } ``` ``` -------------------------------- ### Get Gas Price Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves the current median gas price for the Supra Network. ```APIDOC ## GET /api/gas/price ### Description Get current `median_gas_price`. ### Method GET ### Endpoint /api/gas/price ### Response #### Success Response (200) - **medianGasPrice** (bigint) - Current `median_gas_price` #### Response Example ```json { "medianGasPrice": "1000000000" } ``` ``` -------------------------------- ### Get Minimum Gas Unit Price Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves the current minimum gas unit price for the Supra Network. ```APIDOC ## GET /api/gas/min-unit-price ### Description Get current `min_price_per_gas_unit`. ### Method GET ### Endpoint /api/gas/min-unit-price ### Response #### Success Response (200) - **minGasUnitPrice** (bigint) - Current `min_price_per_gas_unit` #### Response Example ```json { "minGasUnitPrice": "500000000" } ``` ``` -------------------------------- ### Get Gas Price Estimates Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve current gas price estimates using the Supra client. Use this to estimate transaction costs. ```typescript const gasPrice = await supraClient.getGasPrice(); const minGasPrice = await supraClient.getMinGasUnitPrice(); console.log("Median Gas Price:", gasPrice.toString()); console.log("Minimum Gas Price:", minGasPrice.toString()); // Output: // Median Gas Price: 100000 // Minimum Gas Price: 100000 ``` -------------------------------- ### OrderedPaginationArgs Interface Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/interfaces/OrderedPaginationArgs.html Defines the structure for arguments used in ordered pagination, including ascending order, count, and start cursor. ```APIDOC ## Interface OrderedPaginationArgs ### Description Represents arguments for pagination with ordering capabilities. It extends `PaginationArgs` and adds an `ascending` boolean property. ### Properties #### `Optional` ascending - **Type**: `boolean` - **Description**: Specifies the sort order. If true, results are ascending; otherwise, descending. - **Defined in**: [src/types.ts:210](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/0ab1d526c1855c89aa27e30e88efdfb4b404658d/src/types.ts#L210) #### `Optional` count - **Type**: `number` - **Description**: The maximum number of items to return. - **Inherited from**: [PaginationArgs](PaginationArgs.html#count) - **Defined in**: [src/types.ts:205](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/0ab1d526c1855c89aa27e30e88efdfb4b404658d/src/types.ts#L205) #### `Optional` start - **Type**: `string` - **Description**: The cursor for the starting point of the pagination. - **Inherited from**: [PaginationArgs](PaginationArgs.html#start) - **Defined in**: [src/types.ts:206](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/0ab1d526c1855c89aa27e30e88efdfb4b404658d/src/types.ts#L206) ### Hierarchy * [PaginationArgs](PaginationArgs.html) * OrderedPaginationArgs ``` -------------------------------- ### Get Account Information Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve detailed information about an account, including its sequence number and authentication key. This data is essential for transaction creation. ```typescript const accountInfo = await supraClient.getAccountInfo(account.address()); console.log("Sequence Number:", accountInfo.sequence_number); console.log("Authentication Key:", accountInfo.authentication_key); // Output: // Sequence Number: 42n // Authentication Key: 0x... ``` -------------------------------- ### Get Account Resource Data Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves data for a specific resource held by a Supra account. Requires the account address and resource type as input. ```typescript let supraCoinInfo = await supraClient.getResourceData( new HexString("0x1"), "0x1::coin::CoinInfo<0x1::supra_coin::SupraCoin>") ``` -------------------------------- ### Get Custom Coin Balance Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve the balance of any custom coin type for an account. You need to provide the coin type identifier string. ```typescript const coinType = "0x1::supra_coin::SupraCoin"; const coinBalance = await supraClient.getAccountCoinBalance(account.address(), coinType); console.log("Coin Balance:", coinBalance.toString()); // Output: Coin Balance: 1000000000 ``` -------------------------------- ### Get Coin Information Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve metadata for a specific coin type, including its name, symbol, and decimal places. This helps in displaying coin information to users. ```typescript const coinType = "0x1::supra_coin::SupraCoin"; const coinInfo = await supraClient.getCoinInfo(coinType); console.log("Name:", coinInfo.name); console.log("Symbol:", coinInfo.symbol); console.log("Decimals:", coinInfo.decimals); // Output: // Name: Supra Coin // Symbol: SUPRA // Decimals: 8 ``` -------------------------------- ### Theme Initialization Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/index.html Initializes the theme for the application by checking local storage or defaulting to 'os'. It then hides the body and shows the app page after a short delay. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### fromDerivePath Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Creates a new account using a BIP44 path and mnemonics. ```APIDOC ## Static fromDerivePath ### Description Creates new account with bip44 path and mnemonics. ### Method POST ### Endpoint /api/accounts/derive ### Parameters #### Request Body - **path** (string) - Required - The BIP44 path. - **mnemonics** (string) - Required - The mnemonic phrase. ### Returns SupraAccount SupraAccount instance. ### Request Example ```json { "path": "m/44'/60'/0'/0/0", "mnemonics": "test test test test test test test test test test test test" } ``` ### Response #### Success Response (200) - **account** (SupraAccount) - The newly created SupraAccount object. ``` -------------------------------- ### Get Chain ID Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves the Chain ID of the Supra Network. ```APIDOC ## GET /api/chain/id ### Description Get Chain Id Of Supra Network. ### Method GET ### Endpoint /api/chain/id ### Response #### Success Response (200) - **chainId** (ChainId) - Chain Id of the network #### Response Example ```json { "chainId": 101 } ``` ``` -------------------------------- ### Get Transaction Insights Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves insights for a given transaction. This is a private method. ```typescript getTransactionInsights(userAddress: string, txData: any): TransactionInsights ``` -------------------------------- ### SupraClient Initialization Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Functions for initializing and interacting with the SupraClient. ```APIDOC ## POST /api/client/init ### Description Creates and initializes a `SupraClient` instance. The chain ID will be fetched from the provided URL. ### Method POST ### Endpoint /api/client/init ### Parameters #### Request Body - **url** (string) - Required - RPC URL of the Supra RPC node. ### Response #### Success Response (200) - **SupraClient** - An initialized `SupraClient` instance. ### Request Example ```json { "url": "http://localhost:27001/" } ``` ### Response Example ```json { "rpcUrl": "http://localhost:27001/", "chainId": 1 } ``` ``` -------------------------------- ### Create Supra Account from Private Key Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Create a SupraAccount instance from a private key. This allows you to manage and interact with an existing account. ```typescript import { SupraAccount, HexString } from "supra-l1-sdk"; // Create account from private key const account = new SupraAccount( Uint8Array.from( Buffer.from( "2b9654793a999d1d487dabbd1b8f194156e15281fa1952af121cc97b27578d89", "hex" ) ) ); console.log("Address:", account.address().toString()); console.log("Public Key:", account.pubKey().toString()); ``` -------------------------------- ### Get Transaction Payload JSON Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Converts a transaction payload into its JSON representation. This is a private method. ```typescript getTransactionPayloadJSON(txPayload: TransactionPayload): TransactionPayloadJSON ``` -------------------------------- ### SDK Parameters Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Details on key parameters used within the Supra L1 SDK. ```APIDOC ## SDK Parameters ### `minGasUnitPrice` - **Type**: `bigint` - **Description**: Represents the minimum gas unit price for transactions. ### `supraNodeURL` - **Type**: `string` - **Description**: The URL for the Supra Node endpoint. ``` -------------------------------- ### Get Raw Transaction JSON Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Converts a raw transaction into its JSON representation. This is a private method. ```typescript getRawTxnJSON(rawTxn: RawTransaction): RawTxnJSON ``` -------------------------------- ### SupraClient Constructor Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Initializes a new instance of the SupraClient class. ```APIDOC ## new SupraClient() ### Description Initializes a new instance of the SupraClient class. ### Method constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "url": "string", "chainId": "number (optional)" } ``` ### Response #### Success Response (200) - **SupraClient** (SupraClient) - An instance of the SupraClient. #### Response Example ```json { "instance": "SupraClient" } ``` ``` -------------------------------- ### Get ED25519 Authenticator JSON Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Converts an Ed25519 authenticator to its JSON representation. This is a private method. ```APIDOC ## POST /api/authenticator/ed25519/json ### Description Convert an Ed25519 authenticator to its JSON representation. ### Method POST ### Endpoint /api/authenticator/ed25519/json ### Parameters #### Request Body - **authenticator** (AccountAuthenticatorEd25519) - Required - The Ed25519 authenticator object ### Response #### Success Response (200) - **authenticatorJson** (Ed25519AuthenticatorJSON) - The JSON representation of the authenticator #### Response Example ```json { "authenticatorJson": { "type": "ed25519", "publicKey": "...", "signature": "..." } } ``` ``` -------------------------------- ### Get Coin Transactions Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve all coin transfer transactions associated with an account, with pagination support. ```typescript const coinTxs = await supraClient.getCoinTransactionsDetail( account.address(), { count: 10 } ); console.log("Transactions:", coinTxs.transactions.length); console.log("Cursor for pagination:", coinTxs.cursor); ``` -------------------------------- ### SupraAccount Methods Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Documentation for the methods available on the SupraAccount class, including retrieving keys, signing data, and verifying signatures. ```APIDOC ## SupraAccount Methods ### address * **Description**: This is the key by which Supra account is referenced. It is the 32-byte of the SHA-3 256 cryptographic hash of the public key(s) concatenated with a signature scheme identifier byte. * **Returns**: [HexString] - Address associated with the given account. * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1494 ### authKey * **Description**: This key enables account owners to rotate their private key(s) associated with the account without changing the address that hosts their account. * **Returns**: [HexString] - Authentication key for the associated account. * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1500 ### pubKey * **Description**: This key is generated with Ed25519 scheme. Public key is used to check a signature of transaction, signed by given account. * **Returns**: [HexString] - The public key for the associated account. * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1522 ### signBuffer * **Description**: Signs specified `buffer` with account's private key. * **Parameters**: * `buffer` (Uint8Array) - A buffer to sign. * **Returns**: [HexString] - A signature HexString. * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1528 ### signHexString * **Description**: Signs specified `hexString` with account's private key. * **Parameters**: * `hexString` (MaybeHexString) - A regular string or HexString to sign. * **Returns**: [HexString] - A signature HexString. * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1534 ``` -------------------------------- ### SupraAccount Constructor Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Initializes a new SupraAccount instance. It can generate a new key pair or use provided private key bytes. An optional address can be provided to handle account key rotation. ```APIDOC ## new SupraAccount ### Description Creates new account instance. Constructor allows passing in an address, to handle account key rotation, where auth_key != public_key. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Constructor Signature `new SupraAccount(privateKeyBytes?: Uint8Array, address?: MaybeHexString): SupraAccount` #### Parameters * `privateKeyBytes` (Uint8Array) - Optional - Private key from which account key pair will be generated. If not specified, new key pair is going to be created. * `address` (MaybeHexString) - Optional - Account address (e.g. 0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591). If not specified, a new one will be generated from public key ### Returns * SupraAccount - An instance of the SupraAccount class. ``` -------------------------------- ### Get Account Transactions Detail Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves a list of transactions sent by a specific account, with optional pagination. ```APIDOC ## GET /api/account/transactions/detail ### Description Get transactions sent by the account. ### Method GET ### Endpoint /api/account/transactions/detail ### Parameters #### Query Parameters - **account** (HexString) - Required - Supra account address - **paginationArgs** (OrderedPaginationArgs) - Optional - Arguments for ordered pagination response ### Response #### Success Response (200) - **transactions** (Array) - List of TransactionDetail #### Response Example ```json { "transactions": [ { "hash": "0x...", "from": "0x...", "to": "0x...", "value": "1000000000000000000", "timestamp": 1678886400 } ] } ``` ``` -------------------------------- ### Initialize SupraClient Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Initialize the SupraClient for interacting with the Supra blockchain. The `init` method automatically fetches chain ID and gas price. Alternatively, initialize manually with a known chain ID. ```typescript import { SupraClient, SupraAccount, HexString, BCS } from "supra-l1-sdk"; // Initialize client with automatic chain ID detection const supraClient = await SupraClient.init("https://rpc-testnet.supra.com/"); // Alternative: Manual initialization with known chain ID const manualClient = new SupraClient("https://rpc-testnet.supra.com/", 6); ``` -------------------------------- ### Get Account Transactions Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve a list of all transactions sent by a specific account, with options for pagination and sorting. ```typescript const transactions = await supraClient.getAccountTransactionsDetail( account.address(), { count: 10, ascending: false } ); transactions.forEach((tx) => { console.log(`Hash: ${tx.txHash}, Status: ${tx.status}, Gas: ${tx.gasUsed}`); }); ``` -------------------------------- ### Initialize SupraClient Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Initializes and returns an instance of SupraClient. The chain ID is fetched from the provided RPC URL. ```typescript let supraClient = await SupraClient.init( "http://localhost:27001/"); ``` -------------------------------- ### Fund Account with Faucet Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Fund a test account with SUPRA tokens using the faucet. This is only available on the testnet and is useful for development and testing. ```typescript const faucetResponse = await supraClient.fundAccountWithFaucet(account.address()); console.log("Transaction Hash:", faucetResponse.transactionHash); console.log("Status:", faucetResponse.status); // Output: // Transaction Hash: 0x... // Status: Success ``` -------------------------------- ### Get Coin Transactions Detail Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves coin transfer related transactions associated with an account, with optional pagination. ```APIDOC ## GET /api/account/coin/transactions/detail ### Description Get Coin Transfer related transactions associated with the account. ### Method GET ### Endpoint /api/account/coin/transactions/detail ### Parameters #### Query Parameters - **account** (HexString) - Required - Supra account address - **paginationArgs** (OrderedPaginationArgs) - Optional - Arguments for ordered pagination response ### Response #### Success Response (200) - **transactions** (AccountCoinTransactionsResponse) - AccountCoinTransactionsResponse #### Response Example ```json { "transactions": { "assetTransfers": [ { "from": "0x...", "to": "0x...", "amount": "1000000000000000000", "asset": "BTC" } ] } } ``` ``` -------------------------------- ### Derive Account from Derive Path and Mnemonics Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Creates a new SupraAccount using a specified BIP44 derive path and mnemonics. Ensure the path and mnemonics are valid before use. ```typescript fromDerivePath(path: string, mnemonics: string): SupraAccount ``` -------------------------------- ### publishPackage Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Publishes a new package or module onto the Supra network. ```APIDOC ## POST /publishPackage ### Description Publish package or module on supra network. ### Method POST ### Endpoint /publishPackage ### Parameters #### Request Body - **senderAccount** (SupraAccount) - Required - Module Publisher KeyPair - **packageMetadata** (Uint8Array) - Required - Package Metadata - **modulesCode** (Uint8Array[]) - Required - module code - **optionalTransactionArgs** (OptionalTransactionArgs) - Optional - optional arguments for transaction ### Response #### Success Response (200) - **transactionResponse** (TransactionResponse) - `TransactionResponse` #### Response Example ```json { "hash": "0x...", "success": true } ``` ``` -------------------------------- ### PaginationArgs Interface Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/interfaces/PaginationArgs.html The PaginationArgs interface defines the structure for pagination parameters, including optional count and start values. ```APIDOC ## Interface PaginationArgs ### Description An interface that defines arguments for pagination, allowing for optional `count` and `start` parameters. ### Properties #### count - **count** (number) - Optional - Specifies the number of items to retrieve. #### start - **start** (string) - Optional - Specifies the starting point for retrieving items, often an ID or cursor. ### Request Example ```json { "count": 10, "start": "some_cursor_id" } ``` ### Response Example (Note: This interface defines request parameters, not direct response structures. Response structures would typically contain lists of items and potentially next/previous cursors.) ```json { "items": [ // ... list of items ... ], "nextCursor": "another_cursor_id" } ``` ``` -------------------------------- ### Get Supra Transaction Signature Message Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Generates the signature message for a Supra transaction using `AnyRawTransaction`. This is used for signing. ```typescript getSupraTransactionSignatureMessage(rawTxn: AnyRawTransaction) ``` -------------------------------- ### Create SupraAccount from Object Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Initializes a SupraAccount instance from a provided SupraAccountObject. This is useful for reconstructing account data. ```typescript fromSupraAccountObject(obj: SupraAccountObject): SupraAccount ``` -------------------------------- ### Get Coin Change Amount Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Calculates coin change amounts based on user address and events. This is a private method. ```APIDOC ## POST /api/coin/change/amount ### Description Calculate coin change amounts. ### Method POST ### Endpoint /api/coin/change/amount ### Parameters #### Request Body - **userAddress** (string) - Required - The user's address - **events** (Array) - Required - A list of events ### Response #### Success Response (200) - **coinChanges** (Array) - List of CoinChange #### Response Example ```json { "coinChanges": [ { "coinType": "BTC", "amount": "1000000000000000000" } ] } ``` ``` -------------------------------- ### toPrivateKeyObject Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Derives account address, public key, and private key from an account object. ```APIDOC ## toPrivateKeyObject ### Description Derives account address, public key, and private key. ### Method (Implicitly a method of an account object) ### Returns SupraAccountObject SupraAccountObject instance. ### Example: An example of the returned SupraAccountObject object ```json { "address": "0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591", "publicKeyHex": "0xf56d8524faf79fbc0f48c13aeed3b0ce5dd376b4db93b8130a107c0a5e04ba04", "privateKeyHex": "0x009c9f7c992a06cfafe916f125d8adb7a395fca243e264a8e56a4b3e6accf940d2b11e9ece3049ce60e3c7b4a1c58aebfa9298e29a30a58a67f1998646135204" } ``` ``` -------------------------------- ### Get Chain ID Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve the current chain ID of the Supra network. This is a simple query to identify the active network. ```typescript const chainId = await supraClient.getChainId(); console.log("Chain ID:", chainId.value); ``` -------------------------------- ### Get Complete Transaction History Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve a combined list of all sent and coin transfer transactions for an account, up to a specified count. ```typescript const allTransactions = await supraClient.getAccountCompleteTransactionsDetail( account.address(), 20 // count ); console.log("Total Combined Transactions:", allTransactions.length); ``` -------------------------------- ### getAccountResources Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Fetches a list of all resources held by a given Supra account, with optional pagination. ```APIDOC ## GET /getAccountResources ### Description Get list of all resources held by given supra account. ### Method GET ### Endpoint /getAccountResources ### Parameters #### Path Parameters None #### Query Parameters - **account** (HexString) - Required - Hex-encoded 32 byte Supra account address - **paginationArgs** (PaginationArgs) - Optional - Arguments for pagination response ### Request Example ```json { "account": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "paginationArgs": { "limit": 10, "offset": 0 } } ``` ### Response #### Success Response (200) - **AccountResourcesResponse** (object) - An object containing the account's resources and pagination information. #### Response Example ```json { "resources": [ { "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", "data": { "coin": { "value": "1000000000000000000" } } } ], "hasNextPage": true, "endCursor": "cursor123" } ``` ``` -------------------------------- ### SupraClient Methods Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Provides methods for interacting with supra rpc node. ```APIDOC ## SupraClient Methods ### Description This section details the various methods available within the SupraClient class for interacting with the Supra RPC node. ### Methods List - [createRawTxObject](#) - [createRawTxObjectInner](#) - [createSerializedAutomationRegistrationTxPayloadRawTxObject](#) - [createSerializedMultisigPayloadRawTxObject](#) - [createSerializedRawTxObject](#) - [createSerializedRawTxObjectToCreateMultisigTx](#) - [createSerializedScriptTxPayloadRawTxObject](#) - [fundAccountWithFaucet](#) - [getAccountCoinBalance](#) - [getAccountCompleteTransactionsDetail](#) - [getAccountInfo](#) - [getAccountResources](#) - [getAccountSupraCoinBalance](#) - [getAccountTransactionsDetail](#) - [getChainId](#) - [getCoinChangeAmount](#) - [getCoinInfo](#) - [getCoinTransactionsDetail](#) - [getED25519AuthenticatorJSON](#) - [getGasPrice](#) - [getMinGasUnitPrice](#) - [getRawTxnJSON](#) - [getResourceData](#) - [getSendTxPayload](#) - [getTableItemByKey](#) - [getTransactionDetail](#) - [getTransactionInsights](#) - [getTransactionPayloadJSON](#) - [getTransactionStatus](#) - [invokeViewMethod](#) - [isAccountExists](#) - [publishPackage](#) - [sendMultiAgentTransaction](#) - [sendRequest](#) - [sendSponsorTransaction](#) - [sendTx](#) - [sendTxUsingSerializedRawTransaction](#) - [sendTxUsingSerializedRawTransactionAndSignature](#) - [simulateTx](#) - [simulateTxUsingSerializedRawTransaction](#) - [transferCoin](#) - [transferSupraCoin](#) - [unsetAuthenticatorSignatures](#) - [waitForTransactionCompletion](#) - [createSignedTransaction](#) - [deriveTransactionHash](#) - [getSupraTransactionSignatureMessage](#) - [init](#) - [signSupraMultiTransaction](#) - [signSupraTransaction](#) *Note: Detailed documentation for each method, including parameters and return values, can be found by following the respective links.* ``` -------------------------------- ### fromSupraAccountObject Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraAccount.html Creates a SupraAccount instance from a SupraAccountObject. ```APIDOC ## Static fromSupraAccountObject ### Description Creates a SupraAccount instance from a SupraAccountObject. ### Method POST ### Endpoint /api/accounts/fromObject ### Parameters #### Request Body - **obj** (SupraAccountObject) - Required - The SupraAccountObject to convert. ### Returns SupraAccount SupraAccount instance. ``` -------------------------------- ### Get Transaction Detail Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Retrieves detailed information about a specific transaction using its hash. Requires the account address and transaction hash. ```typescript getTransactionDetail(account: HexString, transactionHash: string): Promise ``` -------------------------------- ### EnableTransactionWaitAndSimulationArgs Interface Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/interfaces/EnableTransactionWaitAndSimulationArgs.html This interface defines optional boolean properties to control transaction simulation and waiting. ```APIDOC ## Interface EnableTransactionWaitAndSimulationArgs ### Description This interface allows for the configuration of transaction simulation and waiting behavior. ### Properties #### enableTransactionSimulation - **enableTransactionSimulation** (boolean) - Optional - Controls whether transaction simulation is enabled. #### enableWaitForTransaction - **enableWaitForTransaction** (boolean) - Optional - Controls whether to wait for transaction confirmation. ### Request Example ```json { "enableTransactionSimulation": true, "enableWaitForTransaction": false } ``` ### Response This interface is used for request configuration and does not have a direct success response body defined in this context. ``` -------------------------------- ### Variable DEFAULT_ENABLE_SIMULATION Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/variables/DEFAULT_ENABLE_SIMULATION.html Information about the DEFAULT_ENABLE_SIMULATION constant. ```APIDOC ## Variable DEFAULT_ENABLE_SIMULATION ### Description This constant is used to control simulation settings within the Supra-L1-SDK. ### Type `Const` ### Value `false` ### Defined in `src/constants.ts:14` ### Source Link [https://github.com/Entropy-Foundation/supra-l1-sdk/blob/0ab1d526c1855c89aa27e30e88efdfb4b404658d/src/constants.ts#L14](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/0ab1d526c1855c89aa27e30e88efdfb4b404658d/src/constants.ts#L14) ### Settings * Member Visibility: Protected, Private, Inherited, External ``` -------------------------------- ### Publish Move Package to Supra Blockchain Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Deploy compiled Move modules to the Supra blockchain. Ensure package metadata and module bytecode are prepared as Uint8Arrays. Transaction simulation and waiting are enabled for robust deployment. ```typescript const packageMetadata = Uint8Array.from(/* compiled package metadata */); const modulesCode = [ Uint8Array.from(/* compiled module 1 bytecode */), Uint8Array.from(/* compiled module 2 bytecode */), ]; const txResponse = await supraClient.publishPackage( senderAccount, packageMetadata, modulesCode, { enableTransactionWaitAndSimulationArgs: { enableWaitForTransaction: true, enableTransactionSimulation: true, }, optionalTransactionPayloadArgs: { maxGas: BigInt(50000), }, } ); console.log("Package Published:", txResponse.txHash); console.log("Status:", txResponse.result); // Output: // Package Published: 0x... // Status: Success ``` -------------------------------- ### BCS Namespace Overview Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/modules/BCS.html Provides an overview of the BCS namespace, its available types, variables, and functions for data serialization and deserialization. ```APIDOC ## BCS Namespace This namespace provides functionalities for Binary Canonical Serialization (BCS) within the Supra-L1-SDK. ### Type Aliases - **AnyNumber**: Represents any number type. - **Bytes**: Represents byte data. - **Deserializer**: Represents a deserializer object. - **Seq**: Represents a sequence. - **Serializer**: Represents a serializer object. - **Uint128**: Represents an unsigned 128-bit integer. - **Uint16**: Represents an unsigned 16-bit integer. - **Uint256**: Represents an unsigned 256-bit integer. - **Uint32**: Represents an unsigned 32-bit integer. - **Uint64**: Represents an unsigned 64-bit integer. - **Uint8**: Represents an unsigned 8-bit integer. ### Variables - **Deserializer**: An instance of the Deserializer. - **Serializer**: An instance of the Serializer. ### Functions - **bcsSerializeBool**: Serializes a boolean value. - **bcsSerializeBytes**: Serializes byte data. - **bcsSerializeFixedBytes**: Serializes fixed-size byte data. - **bcsSerializeStr**: Serializes a string. - **bcsSerializeU128**: Serializes a Uint128 value. - **bcsSerializeU16**: Serializes a Uint16 value. - **bcsSerializeU256**: Serializes a Uint256 value. - **bcsSerializeU32**: Serializes a Uint32 value. - **bcsSerializeU8**: Serializes a Uint8 value. - **bcsSerializeUint64**: Serializes a Uint64 value. - **bcsToBytes**: Converts BCS data to bytes. - **deserializeVector**: Deserializes a vector. - **deserializeVectorOfBytes**: Deserializes a vector of bytes. - **serializeVector**: Serializes a vector. - **serializeVectorOfBytes**: Serializes a vector of bytes. - **serializeVectorWithFunc**: Serializes a vector using a provided function. ``` -------------------------------- ### Get SUPRA Coin Balance Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve the native SUPRA token balance for a given account address. The balance is returned in the smallest unit of the token. ```typescript const balance = await supraClient.getAccountSupraCoinBalance(account.address()); console.log("SUPRA Balance:", balance.toString()); // Output: SUPRA Balance: 1000000000 ``` -------------------------------- ### DEFAULT_WAIT_FOR_TX_COMPLETION Constant Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/variables/DEFAULT_WAIT_FOR_TX_COMPLETION.html Information about the DEFAULT_WAIT_FOR_TX_COMPLETION constant. ```APIDOC ## Variable DEFAULT_WAIT_FOR_TX_COMPLETION ### Description This constant is used to determine the default behavior for waiting for transaction completion. ### Type `Const` ### Value `false` ### Source * Defined in `src/constants.ts:15` ``` -------------------------------- ### Get Shortened HexString Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/HexString.html Trims leading zeros from the hex string, returning a shorter representation while keeping the '0x' prefix. Useful for display purposes. ```typescript new HexString("0x000000string").toShortString(); // result = "0xstring" ``` -------------------------------- ### Create HexString Instance Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/HexString.html Instantiates a HexString object from a regular string. If the string already has a '0x' prefix, it will not be added again. ```typescript const string = "string"; new HexString(string); // "0xstring" ``` -------------------------------- ### Get HexString Without Prefix Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/HexString.html Retrieves the inner hex string value without the '0x' prefix. Useful when the prefix is not desired for certain operations. ```typescript const hexString = new HexString("string"); // "0xstring" hexString.noPrefix(); // "string" ``` -------------------------------- ### HexString Static Methods Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/HexString.html Static utility methods for the HexString class. ```APIDOC ## HexString Static Methods ### ensure(hexString) * **Description**: Ensures that the provided value is an instance of the `HexString` class. * **Parameters**: * **hexString** (MaybeHexString) - Required - The string to check or convert. * **Returns**: [HexString](HexString.html) - A `HexString` instance. * **Example**: ```javascript const regularString = "string"; const hexStringInstance = new HexString("string"); // "0xstring" HexString.ensure(regularString); // "0xstring" HexString.ensure(hexStringInstance); // "0xstring" ``` * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1401 ``` ```APIDOC ### fromBuffer(buffer) * **Description**: Creates a new `HexString` from a `Buffer` (Uint8Array). * **Parameters**: * **buffer** (Uint8Array) - Required - The buffer to convert. * **Returns**: [HexString](HexString.html) - A new `HexString` instance. * **Defined in**: node_modules/supra-l1-sdk-core/dist/index.d.ts:1382 ``` -------------------------------- ### EntryFunctionPayloadJSON Interface Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/interfaces/EntryFunctionPayloadJSON.html Details the structure and properties of the EntryFunctionPayloadJSON interface. ```APIDOC ## Interface EntryFunctionPayloadJSON ### Description Represents the payload structure for an entry function, containing details about the entry function itself. ### Properties #### EntryFunction - **EntryFunction** (EntryFunctionJSON) - Required - The entry function details. - Defined in [src/types.ts:83](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/0ab1d526c1855c89aa27e30e88efdfb4b404658d/src/types.ts#L83) ### Request Example ```json { "EntryFunction": { "module": "string", "function": "string", "type_arguments": [], "arguments": [] } } ``` ### Response #### Success Response (200) - **EntryFunction** (EntryFunctionJSON) - The details of the entry function. #### Response Example ```json { "EntryFunction": { "module": "0x1::coin", "function": "transfer", "type_arguments": ["0x1::aptos_coin::AptosCoin"], "arguments": ["0x123", "0x456", "100"] } } ``` ``` -------------------------------- ### Get Table Item Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Access data stored within Move tables by providing the table handle, key type, value type, and the specific key. ```typescript const tableItem = await supraClient.getTableItemByKey( "0x1234567890abcdef...", // Table handle "address", // Key type "u64", // Value type "0x1" // Key value ); console.log("Table Value:", tableItem); ``` -------------------------------- ### Get Transaction Detail Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve comprehensive details about a specific transaction, including its hash, sender, status, gas used, cost, block number, and insights. ```typescript const txDetail = await supraClient.getTransactionDetail(account.address(), txHash); if (txDetail) { console.log("Transaction Hash:", txDetail.txHash); console.log("Sender:", txDetail.sender); console.log("Status:", txDetail.status); console.log("Gas Used:", txDetail.gasUsed); console.log("Transaction Cost:", txDetail.transactionCost); console.log("Block Number:", txDetail.blockNumber); console.log("Insights Type:", txDetail.transactionInsights.type); } ``` -------------------------------- ### fundAccountWithFaucet Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Airdrops test Supra tokens to a specified account. ```APIDOC ## POST /fundAccountWithFaucet ### Description Airdrops test Supra tokens to a specified account. ### Method POST ### Endpoint /fundAccountWithFaucet ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **account** (HexString) - Required - Hex-encoded 32 byte Supra account address ### Request Example ```json { "account": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" } ``` ### Response #### Success Response (200) - **FaucetRequestResponse** (object) - Response object containing faucet request details. #### Response Example ```json { "status": "success", "message": "Tokens airdropped successfully." } ``` ``` -------------------------------- ### Get Transaction Status Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Check the current status of a submitted transaction using its hash. Possible statuses include Success, Failed, Pending, or null if not found. ```typescript const status = await supraClient.getTransactionStatus(txHash); console.log("Status:", status); ``` -------------------------------- ### EntryFunctionJSON Properties Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/interfaces/EntryFunctionJSON.html Detailed breakdown of each property within the EntryFunctionJSON interface. ```APIDOC ## Properties of EntryFunctionJSON ### args * **Type**: `number[][]` * **Description**: An array of arrays of numbers representing function arguments. * **Defined in**: `src/types.ts:93` ### function * **Type**: `string` * **Description**: The name of the entry function. * **Defined in**: `src/types.ts:91` ### module * **Type**: `object` * **Description**: Contains information about the module. * **address** (string): The address of the module. * **name** (string): The name of the module. * **Defined in**: `src/types.ts:87` ### ty_args * **Type**: `FunctionTypeArgs[]` * **Description**: An array of `FunctionTypeArgs` representing the type arguments for the function. * **Defined in**: `src/types.ts:92` ``` -------------------------------- ### Transaction Simulation API Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Simulate transactions before submitting them to the network to verify their success and estimate gas usage. ```APIDOC ## POST /simulate/transaction ### Description Simulate transactions before submitting to verify they will succeed. ### Method POST ### Endpoint /simulate/transaction ### Parameters #### Request Body - **senderAccount** (object) - Required - The account sending the transaction. - **sequence_number** (number) - Required - The sequence number of the sender's account. - **gas_payment** (string) - Required - The gas payment for the transaction. - **gas_budget** (string) - Required - The gas budget for the transaction. - **function** (string) - Required - The function to be called. - **type_arguments** (array) - Optional - Type arguments for the function. - **arguments** (array) - Required - Arguments for the function. ### Request Example ```json { "senderAccount": { "address": "0x123...", "pubKey": "0xabc..." }, "sequence_number": 1, "gas_payment": "0x1", "gas_budget": "10000", "function": "0x1::coin::transfer", "arguments": [ "0x456...", "1000" ] } ``` ### Response #### Success Response (200) - **output** (object) - The simulation output. - **Move** (object) - **vm_status** (string) - The VM status of the simulation. - **gas_used** (number) - The gas used during the simulation. #### Response Example ```json { "output": { "Move": { "vm_status": "Executed successfully", "gas_used": 8 } } } ``` ``` -------------------------------- ### Get Table Item by Key Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Accesses an item within a table using its associated key. Requires the table handle, key type, value type, and the key itself. ```typescript getTableItemByKey(tableHandle: string, keyType: string, valueType: string, key: string): Promise ``` -------------------------------- ### Get Specific Resource Data Source: https://context7.com/entropy-foundation/supra-l1-sdk/llms.txt Retrieve the data for a specific resource type owned by an account. Requires the resource's address and its fully qualified type string. ```typescript const coinStore = await supraClient.getResourceData( new HexString("0x1"), "0x1::coin::CoinInfo<0x1::supra_coin::SupraCoin>" ); console.log("Resource Type:", coinStore.type); console.log("Data:", coinStore.data); ``` -------------------------------- ### AccountInfo Interface Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/interfaces/AccountInfo.html Defines the structure for account information, including authentication key and sequence number. ```APIDOC ## Interface AccountInfo ### Description Represents the structure for account information within the Supra-L1-SDK. ### Properties #### authentication_key - **Type**: string - **Description**: The authentication key associated with the account. #### sequence_number - **Type**: bigint - **Description**: The sequence number for the account. ### Source - Defined in `src/types.ts:3` ``` -------------------------------- ### Get Send Transaction Payload Source: https://github.com/entropy-foundation/supra-l1-sdk/blob/master/docs/classes/SupraClient.html Generates a SendTxPayload from a RawTransaction, suitable for direct submission via the RPC endpoint. Requires sender account details and raw transaction data. ```typescript getSendTxPayload(senderAccount: SupraAccount, rawTxn: RawTransaction): SendTxPayload ```