### Install Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Install the Fireblocks JS/TS SDK using npm or yarn. ```bash npm install fireblocks-sdk --save # or yarn add fireblocks-sdk ``` -------------------------------- ### Get Device Setup Status Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieves the setup status of a device associated with a Non-Custodial Wallet. ```APIDOC ## getDeviceSetupStatus ### Description Gets the setup status for a device associated with an NCW wallet. ### Method `ncw.getDeviceSetupStatus(walletId: string, deviceId: string)` ### Parameters #### Path Parameters - **walletId** (string) - Required - The ID of the wallet. - **deviceId** (string) - Required - The ID of the device. ``` -------------------------------- ### Get Wallet Setup Status Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieves the setup status of a Non-Custodial Wallet. ```APIDOC ## getWalletSetupStatus ### Description Gets the setup status for an NCW wallet. ### Method `ncw.getWalletSetupStatus(walletId: string)` ### Parameters #### Path Parameters - **walletId** (string) - Required - The ID of the wallet. ### Response #### Success Response (200) - **isBackedUp** (boolean) - Indicates whether the wallet is backed up. ``` -------------------------------- ### Get Paginated Wallet Assets Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of retrieving assets for a specific internal wallet with pagination. This is essential for handling wallets with a large number of assets. ```typescript // Get paginated assets for a single internal wallet const pagedAssets = await fireblocks.getInternalWalletAssets( internalWallet.id, 50, // pageSize (max 200) undefined // pageCursor ); console.log(pagedAssets.data); // WalletContainerResponse console.log(pagedAssets.next); // cursor for next page ``` -------------------------------- ### Create Contract Wallet Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of creating a contract wallet, which is typically a smart contract address. Requires a name and then assets can be added. ```typescript // Create a contract wallet const contractWallet = await fireblocks.createContractWallet("My Smart Contract"); await fireblocks.createContractWalletAsset( contractWallet.id, "ETH", "0xContractAddress..." ); ``` -------------------------------- ### Get NCW Wallet and Device Setup Status Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieves the backup status for an NCW wallet and the setup status for a specific device associated with a wallet. Useful for checking wallet readiness. ```typescript // Get wallet setup status const setupStatus = await ncw.getWalletSetupStatus(wallet.walletId); console.log(setupStatus.isBackedUp); // true/false // Get device setup status const deviceStatus = await ncw.getDeviceSetupStatus(wallet.walletId, "device-id"); ``` -------------------------------- ### Manage Staking Operations with Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt This comprehensive example demonstrates various staking operations. Ensure you have imported the necessary types from 'fireblocks-sdk'. ```typescript import { StakingChain, StakeRequestDto } from "fireblocks-sdk"; // List supported staking chains const chains = await fireblocks.getStakingChains(); console.log(chains); // ["ETH", "SOL", "MATIC", ...] // Get chain-specific staking info const ethInfo = await fireblocks.getStakingChainInfo(StakingChain.ETHEREUM); console.log(ethInfo.currentEpoch); // 12345 console.log(ethInfo.epochDuration); // 32 // Get available staking providers const providers = await fireblocks.getStakingProviders(); console.log(providers[0].providerName); // "Lido" console.log(providers[0].isTermsOfServiceApproved); // false // Approve terms of service for a provider await fireblocks.approveStakingProviderTermsOfService(providers[0].id); // Stake ETH from vault "0" const stakeBody: StakeRequestDto = { vaultAccountId: "0", providerId: providers[0].id, stakeAmount: "32", feeLevel: "MEDIUM", txNote: "ETH staking position", }; const stakeResponse = await fireblocks.executeStakingStake(StakingChain.ETHEREUM, stakeBody); console.log(stakeResponse.id); // position ID // List all staking positions const positions = await fireblocks.getStakingPositions(); console.log(positions[0].status); // "active" console.log(positions[0].amount); // "32" console.log(positions[0].rewardsAmount); // "0.123" // Get positions for a specific chain const ethPositions = await fireblocks.getStakingPositions(StakingChain.ETHEREUM); // Get summary of all staking positions const summary = await fireblocks.getStakingPositionsSummary(); console.log(summary.active); // [{ chainDescriptor: "ETH", amount: "32" }] console.log(summary.rewardsAmount); // [{ chainDescriptor: "ETH", amount: "0.123" }] // Unstake a position (by position ID) await fireblocks.executeStakingUnstake(StakingChain.ETHEREUM, { id: stakeResponse.id, feeLevel: "MEDIUM", }); // Withdraw after unbonding period await fireblocks.executeStakingWithdraw(StakingChain.ETHEREUM, { id: stakeResponse.id, feeLevel: "MEDIUM", }); // Split a Solana staking position const split = await fireblocks.executeStakingSplit(StakingChain.SOLANA, { id: "position-id", amount: "16", feeLevel: "MEDIUM", }); ``` -------------------------------- ### Create External Wallet Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of creating an external wallet, which represents a whitelisted wallet address outside of Fireblocks. Requires a name. ```typescript // Create an external wallet (for a non-Fireblocks address) const externalWallet = await fireblocks.createExternalWallet("Exchange Hot Wallet"); const externalAsset = await fireblocks.createExternalWalletAsset( externalWallet.id, "ETH", "0xExchangeAddress...", ); ``` -------------------------------- ### Get Asset Network Fee Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of retrieving the current network fee estimate for a specific asset. Useful for understanding gas prices or network congestion. ```typescript // Get network fee estimate for asset const networkFee = await fireblocks.getFeeForAsset("ETH"); console.log(networkFee.medium.gasPrice); // "20000000000" ``` -------------------------------- ### List Wallets Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Examples of retrieving lists of all internal and external wallets managed by Fireblocks. Useful for auditing or managing wallet inventory. ```typescript // List all wallets const allInternalWallets = await fireblocks.getInternalWallets(); const allExternalWallets = await fireblocks.getExternalWallets(); ``` -------------------------------- ### Create Internal Wallet Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of creating an internal wallet, which is used for transfers between different Fireblocks tenants or accounts. Requires a name and a reference ID. ```typescript // Create an internal wallet (for another Fireblocks tenant) const internalWallet = await fireblocks.createInternalWallet( "Partner Wallet", "partner-ref-001" ); console.log(internalWallet.id); // "wallet-uuid" ``` -------------------------------- ### Create ETH Transaction Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of creating a simple vault-to-vault ETH transfer. Ensure the FireblocksSDK is initialized before use. ```typescript import { FireblocksSDK, TransactionArguments, TransactionOperation, FeeLevel, PeerType, TransactionFilter } from "fireblocks-sdk"; // Simple vault-to-vault ETH transfer const txArgs: TransactionArguments = { assetId: "ETH", source: { type: PeerType.VAULT_ACCOUNT, id: "0" }, destination: { type: PeerType.VAULT_ACCOUNT, id: "1" }, amount: "0.1", feeLevel: FeeLevel.MEDIUM, note: "Internal transfer", customerRefId: "order-123" }; const tx = await fireblocks.createTransaction(txArgs); console.log(tx.id); // "tx-uuid" console.log(tx.status); // "SUBMITTED" ``` -------------------------------- ### Delete Wallet Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Examples of deleting external and internal wallets. This action is irreversible and should be used with caution. ```typescript // Delete wallet await fireblocks.deleteExternalWallet(externalWallet.id); await fireblocks.deleteInternalWallet(internalWallet.id); ``` -------------------------------- ### Manage Exchange Accounts with Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt These examples demonstrate how to interact with connected exchange accounts, including listing, retrieving details, converting assets, and transferring funds. Ensure the exchange account is properly configured in Fireblocks. ```typescript // List all exchange accounts const exchanges = await fireblocks.getExchangeAccounts(); console.log(exchanges[0].id); // "exchange-account-id" console.log(exchanges[0].name); // "Binance" ``` ```typescript // Get paged exchange accounts const pagedExchanges = await fireblocks.getExchangeAccountsPaged({ limit: 10, before: undefined, after: undefined, }); ``` ```typescript // Get single exchange account const exchange = await fireblocks.getExchangeAccountById("exchange-account-id"); ``` ```typescript // Get a specific asset balance on an exchange const btcBalance = await fireblocks.getExchangeAsset("exchange-account-id", "BTC"); console.log(btcBalance.total); // "0.5" ``` ```typescript // Convert BTC to USDT on exchange const conversion = await fireblocks.convertExchangeAsset( "exchange-account-id", "BTC", // srcAsset "USDT", // destAsset 0.1 // amount ); console.log(conversion.status); // "SUBMITTED" ``` ```typescript // Transfer funds to a subaccount await fireblocks.transferToSubaccount( "exchange-account-id", "subaccount-123", "BTC", 0.05 ); ``` ```typescript // Transfer funds back from subaccount await fireblocks.transferFromSubaccount( "exchange-account-id", "subaccount-123", "BTC", 0.05 ); ``` -------------------------------- ### Get Supported Assets Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieves a list of assets supported by the Non-Custodial Wallet system, with optional filtering. ```APIDOC ## getSupportedAssets ### Description Gets the list of assets supported by the NCW system. ### Method `ncw.getSupportedAssets(options?: { pageSize?: number; onlyBaseAssets?: boolean; })` ### Parameters #### Query Parameters - **pageSize** (number) - Optional - The number of assets to return per page. - **onlyBaseAssets** (boolean) - Optional - If true, only returns base assets. ### Response #### Success Response (200) - **supportedAssets** (array) - An array of supported asset objects. ``` -------------------------------- ### Add Asset to Internal Wallet Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of adding a specific asset (like BTC) to an existing internal wallet. Requires the wallet ID, asset ID, and the external address for the asset. ```typescript // Add BTC asset to the internal wallet const internalAsset = await fireblocks.createInternalWalletAsset( internalWallet.id, "BTC", "1A1zP1eP5QGefi2DMPTfTL5SLmv7Divf Na", ); ``` -------------------------------- ### Create External Wallet Transfer Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of creating a transaction to a whitelisted external wallet. Requires the external wallet ID to be pre-configured. ```typescript // Transfer to an external (whitelisted) wallet const extTx = await fireblocks.createTransaction({ assetId: "BTC", source: { type: PeerType.VAULT_ACCOUNT, id: "0" }, destination: { type: PeerType.EXTERNAL_WALLET, id: "wallet-id" }, amount: "0.01", feeLevel: FeeLevel.HIGH, }); ``` -------------------------------- ### Get Supported Assets for NCW Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Fetches a list of assets supported by the NCW system. Supports filtering by `pageSize` and `onlyBaseAssets`. ```typescript // Get NCW supported assets const supportedAssets = await ncw.getSupportedAssets({ pageSize: 50, onlyBaseAssets: false, }); ``` -------------------------------- ### Estimate Transaction Fee Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of estimating the network fee for a transaction before it is created. This helps in planning and setting appropriate fee levels. ```typescript // Estimate fee before sending const feeEstimate = await fireblocks.estimateFeeForTransaction(txArgs); console.log(feeEstimate.low.networkFee); // "0.001" console.log(feeEstimate.medium.networkFee); // "0.002" console.log(feeEstimate.high.networkFee); // "0.005" ``` -------------------------------- ### Query Transactions Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of querying transactions based on various filters like date range, status, and limit. This is useful for retrieving transaction history. ```typescript // Query transactions const filter: TransactionFilter = { after: Date.now() - 86400000, // last 24h status: "COMPLETED", limit: 50, }; const txList = await fireblocks.getTransactions(filter); ``` -------------------------------- ### Manage Vault Assets with Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Use these methods to manage crypto assets within vault accounts. This includes creating new asset wallets, querying balances, refreshing on-chain balances, and getting aggregated balance views. ```typescript // Add ETH to vault account "12" const asset = await fireblocks.createVaultAsset("12", "ETH"); console.log(asset); // { id: "ETH", address: "0xabc...", legacyAddress: "", tag: "" } // Get current balance const balance = await fireblocks.getVaultAccountAsset("12", "ETH"); console.log(balance.total); // "1.5" console.log(balance.available); // "1.5" // Force refresh balance from blockchain const refreshed = await fireblocks.refreshVaultAssetBalance("12", "ETH"); // Aggregate balance across all vaults for a specific asset const ethTotal = await fireblocks.getVaultBalanceByAsset("ETH"); console.log(ethTotal.total); // total ETH across all vaults // List asset wallets with paging const assetWallets = await fireblocks.getAssetWallets({ assetId: "ETH", before: "100", after: "0", limit: 200, }); console.log(assetWallets.assetWallets); // AssetWallet[] ``` -------------------------------- ### SDK Initialization Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Demonstrates how to initialize the Fireblocks SDK with basic and advanced options, including custom authentication providers and request timeouts. ```APIDOC ## SDK Initialization **Constructor:** `new FireblocksSDK(privateKey, apiKey, apiBaseUrl?, authProvider?, sdkOptions?) Creates a new Fireblocks API client. Accepts an RS256 private key string, a UUID API key, an optional base URL, an optional custom auth provider, and optional `SDKOptions`. ```typescript import { FireblocksSDK, SDKOptions } from "fireblocks-sdk"; import * as fs from "fs"; import { AxiosError } from "axios"; const privateKey = fs.readFileSync("./fireblocks_secret.key", "utf8"); const apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; // Basic initialization const fireblocks = new FireblocksSDK(privateKey, apiKey); // Full initialization with all options const options: SDKOptions = { timeoutInMs: 30000, anonymousPlatform: false, userAgent: "MyApp/1.0", customAxiosOptions: { interceptors: { response: { onFulfilled: (response) => { console.log(`Request ID: ${response.headers["x-request-id"]} `); return response; }, onRejected: (error: AxiosError) => { console.error(`Fireblocks error code: ${(error.response?.data as any)?.code}`); console.error(`Message: ${(error.response?.data as any)?.message}`); console.error(`Request ID: ${error.response?.headers["x-request-id"]} `); throw error; } } } } }; const fireblocksWithOptions = new FireblocksSDK( privateKey, apiKey, "https://api.fireblocks.io", undefined, options ); ``` ``` -------------------------------- ### Create and Manage NCW Wallets Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Demonstrates creating a new NCW wallet, enabling/disabling it, and creating accounts (sub-accounts) within a wallet. Requires the `fireblocks-sdk` import. ```typescript import { FireblocksSDK, PeerType, NCW } from "fireblocks-sdk"; const ncw = fireblocks.NCW; // Create a new NCW wallet const wallet = await ncw.createWallet(); console.log(wallet.walletId); // "ncw-wallet-uuid" console.log(wallet.enabled); // true // Enable or disable a wallet await ncw.enableWallet(wallet.walletId, false); // Create an account (sub-account) within the wallet const account = await ncw.createWalletAccount(wallet.walletId); console.log(account.accountId); // 0 ``` -------------------------------- ### Initialize SDK with Travel Rule Support Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Initialize the Fireblocks SDK with Notabene credentials for Travel Rule PII encryption. Ensure Notabene credentials are provided in the travelRuleOptions. ```typescript import { FireblocksSDK, TravelRuleOptions } from "fireblocks-sdk"; // Initialize SDK with Travel Rule PII encryption support const fireblocksWithTR = new FireblocksSDK(privateKey, apiKey, undefined, undefined, { travelRuleOptions: { notabeneCredentials: { clientId: "your-notabene-client-id", clientSecret: "your-notabene-client-secret", } } }); ``` -------------------------------- ### Get Single Transaction by ID Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of retrieving details for a specific transaction using its unique ID. This is useful for checking the status or details of a known transaction. ```typescript // Get single transaction const txDetail = await fireblocks.getTransactionById("tx-uuid"); console.log(txDetail.status); // "COMPLETED" ``` -------------------------------- ### Initialize Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Initialize the Fireblocks SDK with private key and API key. Supports full initialization with options like timeout, custom base URL, and interceptors. ```typescript import { FireblocksSDK, SDKOptions } from "fireblocks-sdk"; import * as fs from "fs"; import { AxiosError } from "axios"; const privateKey = fs.readFileSync("./fireblocks_secret.key", "utf8"); const apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; // Basic initialization const fireblocks = new FireblocksSDK(privateKey, apiKey); // Full initialization with all options const options: SDKOptions = { timeoutInMs: 30000, anonymousPlatform: false, userAgent: "MyApp/1.0", customAxiosOptions: { interceptors: { response: { onFulfilled: (response) => { console.log(`Request ID: ${response.headers["x-request-id"]}`); return response; }, onRejected: (error: AxiosError) => { console.error(`Fireblocks error code: ${(error.response?.data as any)?.code}`); console.error(`Message: ${(error.response?.data as any)?.message}`); console.error(`Request ID: ${error.response?.headers["x-request-id"]}`); throw error; } } } } }; const fireblocksWithOptions = new FireblocksSDK( privateKey, apiKey, "https://api.fireblocks.io", undefined, options ); ``` -------------------------------- ### Get Wallets Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieves a list of Non-Custodial Wallets with pagination. ```APIDOC ## getWallets ### Description Lists all NCW wallets with pagination. ### Method `ncw.getWallets(options?: { pageSize?: number; pageCursor?: string; sort?: string; order?: string; })` ### Parameters #### Query Parameters - **pageSize** (number) - Optional - The number of wallets to return per page. - **pageCursor** (string) - Optional - A cursor for paginating through results. - **sort** (string) - Optional - The field to sort the results by (e.g., "createdAt"). - **order** (string) - Optional - The order of sorting (e.g., "DESC"). ### Response #### Success Response (200) - **data** (array) - An array of wallet objects. - **walletId** (string) - The ID of the wallet. ``` -------------------------------- ### Import Fireblocks SDK (JavaScript) Source: https://github.com/fireblocks/fireblocks-sdk-js/blob/master/README.md Instantiate the Fireblocks SDK using your private key and API key for JavaScript applications. ```javascript const FireblocksSDK = require("fireblocks-sdk").FireblocksSDK; const fireblocks = new FireblocksSDK(privateKey, apiKey); ``` -------------------------------- ### Import Fireblocks SDK with Options (TypeScript) Source: https://github.com/fireblocks/fireblocks-sdk-js/blob/master/README.md Instantiate the Fireblocks SDK with additional options such as a custom base URL, authentication provider, or other SDK configurations. ```typescript const baseUrl = "https://api.fireblocks.io"; const authProvider: IAuthProvider = { /* Custom implementation */ }; const fireblocks = new FireblocksSDK(privateKey, apiKey, baseUrl, authProvider, options); ``` -------------------------------- ### Get Wallet Asset Balance Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieves the balance of a specific asset within a Non-Custodial Wallet account. ```APIDOC ## getWalletAssetBalance ### Description Gets the asset balance for an NCW account. ### Method `ncw.getWalletAssetBalance(walletId: string, accountId: number, assetId: string)` ### Parameters #### Path Parameters - **walletId** (string) - Required - The ID of the wallet. - **accountId** (number) - Required - The ID of the account within the wallet. - **assetId** (string) - Required - The ID of the asset (e.g., "ETH"). ### Response #### Success Response (200) - **total** (string) - The total balance of the asset. ``` -------------------------------- ### Cancel Transaction by ID Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of canceling a transaction that has been submitted but not yet processed by the network. This operation is irreversible. ```typescript // Cancel a pending transaction const cancel = await fireblocks.cancelTransactionById("tx-uuid"); console.log(cancel.success); // true ``` -------------------------------- ### Get Travel Rule VASP Details Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Retrieve detailed information about a specific VASP using its Decentralized Identifier (DID). ```typescript // Look up a VASP by DID const vasp = await fireblocks.getTravelRuleVASPDetails("did:vasp:myvasp"); console.log(vasp.name); // "My VASP Name" ``` -------------------------------- ### Import Fireblocks SDK (TypeScript) Source: https://github.com/fireblocks/fireblocks-sdk-js/blob/master/README.md Instantiate the Fireblocks SDK using your private key and API key for TypeScript applications. ```typescript import { FireblocksSDK } from "fireblocks-sdk"; const fireblocks = new FireblocksSDK(privateKey, apiKey); ``` -------------------------------- ### List NCW Wallets with Pagination Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Shows how to list all NCW wallets using pagination. Specify `pageSize` and `pageCursor` for efficient retrieval of large numbers of wallets. Sorting by creation date in descending order is demonstrated. ```typescript // List all NCW wallets with pagination const wallets = await ncw.getWallets({ pageSize: 20, pageCursor: undefined, sort: "createdAt", order: "DESC", }); console.log(wallets.data[0].walletId); ``` -------------------------------- ### Create One-Time Address Transfer Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of creating a transaction to a one-time address, which is not pre-whitelisted. The recipient address is provided directly. ```typescript // One-time address (non-whitelisted) transfer const otaTx = await fireblocks.createTransaction({ assetId: "USDC", source: { type: PeerType.VAULT_ACCOUNT, id: "0" }, destination: { type: PeerType.ONE_TIME_ADDRESS, oneTimeAddress: { address: "0xRecipient..." } }, amount: "100", feeLevel: FeeLevel.LOW, }); ``` -------------------------------- ### Manage Tokenization with Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Use these functions to list contract templates, deploy contracts, issue new tokens, link existing tokens, and manage NFT collections. Ensure you have the correct assetId and vaultAccountId. ```typescript import { SupportedContractTemplateType } from "fireblocks-sdk"; // List available contract templates const templates = await fireblocks.getContractTemplates({ type: "FUNGIBLE_TOKEN", pageSize: 20, }); console.log(templates.data[0].id); // "template-uuid" ``` ```typescript // Get deploy function ABI for a template const deployFn = await fireblocks.getContractTemplateDeployFunction("template-uuid", true); ``` ```typescript // Deploy a contract from template const deployment = await fireblocks.deployContract("template-uuid", { vaultAccountId: "0", assetId: "ETH_TEST3", constructorParameters: [ { value: "MyToken", type: "string" }, { value: "MTK", type: "string" }, ] }); console.log(deployment.txId); // transaction ID console.log(deployment.contractId); // deployed contract ID ``` ```typescript // Issue a new token linked to a deployed contract const tokenLink = await fireblocks.issueNewToken({ assetId: "ETH_TEST3", vaultAccountId: "0", createParams: { name: "My Token", symbol: "MTK", } }); console.log(tokenLink.id); // token link ID console.log(tokenLink.status); // "PENDING" ``` ```typescript // Link an existing on-chain token by contract address const linked = await fireblocks.linkContractByAddress( SupportedContractTemplateType.ERC20, "ETH", "0xTokenContractAddress", "My Existing Token" ); ``` ```typescript // Get all linked tokens const linkedTokens = await fireblocks.getLinkedTokens({ pageSize: 50 }); console.log(linkedTokens.data.length); ``` ```typescript // Create an NFT collection and mint/burn const collection = await fireblocks.createNewCollection({ assetId: "ETH_TEST3", vaultAccountId: "0", name: "My NFT Collection", symbol: "MNFT", }); const minted = await fireblocks.mintNFT(collection.id, { vaultAccountId: "0", to: "0xRecipient...", tokenId: "1", amount: "1", }); await fireblocks.burnNFT(collection.id, { vaultAccountId: "0", tokenId: "1", amount: "1", }); ``` -------------------------------- ### SDK Options Interface Source: https://github.com/fireblocks/fireblocks-sdk-js/blob/master/README.md Defines the structure for optional configurations when initializing the Fireblocks SDK, including timeout, proxy, and user-agent settings. ```typescript interface SDKOptions { /** HTTP request timeout */ timeoutInMs?: number; /** Proxy configurations */ proxy?: AxiosProxyConfig | false; /** Whether to remove platform from User-Agent header */ anonymousPlatform?: boolean; /** Additional product identifier to be prepended to the User-Agent header */ userAgent?: string; /** TravelRule Provider options to initialize PII Client for PII encryption */ travelRuleOptions?: TravelRuleOptions; } ``` -------------------------------- ### Paginated Transaction Retrieval Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of retrieving transactions with pagination details. This allows for efficient retrieval of large transaction sets by fetching them in chunks. ```typescript // Paginated transaction retrieval const txPage = await fireblocks.getTransactionsWithPageInfo({ after: Date.now() - 86400000, limit: 25, orderBy: "createdAt", sort: "DESC", }); console.log(txPage.transactions); // TransactionResponse[] const nextPage = await fireblocks.getTransactionsWithPageInfo( undefined, txPage.pageDetails.nextPage ); ``` -------------------------------- ### Manage Assets and Blockchains with Fireblocks SDK Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Use these methods to discover supported assets and blockchains, register custom tokens, and set asset prices. The `listAssets` endpoint supports pagination and filtering. ```typescript // Get all supported assets (legacy endpoint) const supportedAssets = await fireblocks.getSupportedAssets(); console.log(supportedAssets[0]); // { id: "ETH", name: "Ethereum", type: "ETH", ... } ``` ```typescript // List assets with filters (new paginated endpoint) const assets = await fireblocks.listAssets({ blockchainId: "ETH", assetClass: "FT", symbol: "USDC", pageSize: 20, }); console.log(assets.data[0].id); // "USDC" console.log(assets.next); // pagination cursor ``` ```typescript // Get a specific asset by ID or legacyId const usdcDetails = await fireblocks.getAssetById("USDC"); console.log(usdcDetails.displayName); // "USD Coin" console.log(usdcDetails.onchain?.address); // "0xa0b86991..." ``` ```typescript // Register a new custom token const registered = await fireblocks.registerNewAsset( "ETH", // blockchainId (native asset) "0xTokenContractAddress", // contract address "MYTOKEN" // symbol ); console.log(registered.legacyId); // "MYTOKEN_ETH" ``` ```typescript // List blockchains const blockchains = await fireblocks.listBlockchains({ test: false }); console.log(blockchains.data[0].displayName); // "Ethereum" ``` ```typescript // Get blockchain by ID const ethChain = await fireblocks.getBlockchainById("ETH"); console.log(ethChain.onchain.protocol); // "EVM" ``` ```typescript // Set custom asset price (for reporting) await fireblocks.setAssetPrice("MYTOKEN_ETH", "USD", 1.5); ``` -------------------------------- ### Configure Gas Station for Vault Accounts Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Automate ETH/gas funding for vault accounts using the gas station. This feature automatically tops up assets when balances fall below a specified threshold. Configuration requires setting thresholds, caps, and maximum gas prices. ```typescript // Get current gas station config const gasInfo = await fireblocks.getGasStationInfo(); console.log(gasInfo.configuration); // { gasThreshold: "0.001", gasCap: "0.01", maxGasPrice: "100" } console.log(gasInfo.balance.ETH); // { balance: "0.5" } ``` ```typescript // Get gas station info for a specific asset const maticGasInfo = await fireblocks.getGasStationInfo("MATIC"); ``` ```typescript // Update gas station config await fireblocks.setGasStationConfiguration( "0.002", // gasThreshold: auto-fill when below this amount "0.02", // gasCap: maximum to hold in gas station "150", // maxGasPrice: in Gwei undefined // assetId: omit for default ETH config ); ``` -------------------------------- ### Manage WalletConnect Sessions Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Use these methods to create, submit, get, and remove WalletConnect sessions for linking Fireblocks vault accounts to dApps. Ensure the correct Web3ConnectionType is specified. ```typescript import { Web3ConnectionType } from "fireblocks-sdk"; // Initiate a WalletConnect session const session = await fireblocks.createWeb3Connection( Web3ConnectionType.WALLET_CONNECT, { vaultAccountId: 0, feeLevel: "MEDIUM", uri: "wc:77752975-906f-48f5-b59f-047826ee947e@1?bridge=https%3A%2F%2F0.bridge.walletconnect.org&key=abc123", chainIds: ["ETH", "ETH_TEST3"], } ); console.log(session.id); // "session-uuid" console.log(session.status); // "PENDING_APPROVAL" // Approve the connection await fireblocks.submitWeb3Connection( Web3ConnectionType.WALLET_CONNECT, session.id, true // approve = true, false = reject ); // List all active connections const connections = await fireblocks.getWeb3Connections({ pageSize: 20, sort: "createdAt", order: "DESC", filter: { vaultAccountId: "0" }, }); console.log(connections.data[0].id); // Disconnect a session await fireblocks.removeWeb3Connection(Web3ConnectionType.WALLET_CONNECT, session.id); ``` -------------------------------- ### Interact with Deployed Smart Contracts Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Fetch contract ABIs, read contract state, or write to contracts by creating Fireblocks transactions. Use getTransactionReceipt to check the status of a transaction. ```typescript // Fetch or scrape ABI from block explorer const contractWithABI = await fireblocks.fetchOrScrapeABI( "ETH", "0xContractAddress..." ); console.log(contractWithABI.abi.length); // number of ABI functions ``` ```typescript // Get contract ABI for all functions const abi = await fireblocks.getContractAbi("ETH", "0xContractAddress..."); console.log(abi.abi[0].name); // "balanceOf" ``` ```typescript // Read from contract (no transaction required) const result = await fireblocks.readContractCallFunction( "ETH", "0xContractAddress...", { functionSignature: "balanceOf(address)", callData: [{ value: "0xUserAddress...", type: "address" }], } ); console.log(result[0].value); // "1000000000000000000" ``` ```typescript // Write to contract (creates a Fireblocks transaction) const writeResult = await fireblocks.writeContractCallFunction( "ETH", "0xContractAddress...", { vaultAccountId: "0", functionSignature: "transfer(address,uint256)", callData: [ { value: "0xRecipient...", type: "address" }, { value: "1000000000000000000", type: "uint256" }, ], feeLevel: "MEDIUM", note: "Token transfer via SDK", } ); console.log(writeResult.id); // transaction ID console.log(writeResult.status); // "SUBMITTED" ``` ```typescript // Get transaction receipt const receipt = await fireblocks.getTransactionReceipt("ETH", "0xTxHash..."); console.log(receipt.status); // "0x1" (success) console.log(receipt.gasUsed); // "21000" ``` -------------------------------- ### Drop Transaction (Replace-by-Fee) Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Example of dropping an ETH transaction using the replace-by-fee mechanism. This is used to cancel or speed up a pending transaction by submitting a new one with a higher fee. ```typescript // Drop ETH transaction (replace-by-fee) const drop = await fireblocks.dropTransaction("tx-uuid", FeeLevel.HIGH); ``` -------------------------------- ### Manage Fireblocks Network Connections Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Use these methods to list, create, update, and remove network connections. Also includes functionality to create and manage discoverable network profiles. ```typescript // List all network connections const connections = await fireblocks.getNetworkConnections(); console.log(connections[0].id); // "conn-uuid" ``` ```typescript // Create a network connection between two profiles const newConn = await fireblocks.createNetworkConnection( "local-profile-id", "remote-profile-id", { cryptoScheme: "UNIDIRECTIONAL", numOfSigners: "1" } ); ``` ```typescript // Update routing policy await fireblocks.setNetworkConnectionRoutingPolicy( newConn.id, { cryptoScheme: "BIDIRECTIONAL", numOfSigners: "2" } ); ``` ```typescript // Remove connection await fireblocks.removeNetworkConnection(newConn.id); ``` ```typescript // Create a discoverable network profile const networkId = await fireblocks.createNetworkId( "My Public Profile", { cryptoScheme: "UNIDIRECTIONAL", numOfSigners: "1" } ); ``` ```typescript // Set discoverability await fireblocks.setNetworkIdDiscoverability(networkId.id, true); ``` ```typescript // List all discoverable profiles const profiles = await fireblocks.getDiscoverableNetworkIds(); ``` -------------------------------- ### Create Wallet Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Creates a new Non-Custodial Wallet. ```APIDOC ## createWallet ### Description Creates a new NCW wallet. ### Method `ncw.createWallet()` ### Response #### Success Response (200) - **walletId** (string) - The unique identifier for the newly created wallet. - **enabled** (boolean) - Indicates if the wallet is enabled. ``` -------------------------------- ### Vault Asset Operations Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Manage crypto assets within vault accounts: create new asset wallets, query balances, refresh on-chain balances, and get aggregated balance views. ```APIDOC ## Vault Asset Operations Manage crypto assets within vault accounts: create new asset wallets, query balances, refresh on-chain balances, and get aggregated balance views. ### `createVaultAsset(vaultAccountId: string, assetId: string)` Adds a specified asset to a vault account, creating a new wallet if one does not exist. **Parameters** - **vaultAccountId** (string) - The ID of the vault account. - **assetId** (string) - The ID of the asset to add (e.g., "ETH"). **Returns** - An object containing the asset details, including `id`, `address`, `legacyAddress`, and `tag`. ### `getVaultAccountAsset(vaultAccountId: string, assetId: string)` Retrieves the current balance and details for a specific asset within a vault account. **Parameters** - **vaultAccountId** (string) - The ID of the vault account. - **assetId** (string) - The ID of the asset. **Returns** - An object containing `total` and `available` balance for the asset. ### `refreshVaultAssetBalance(vaultAccountId: string, assetId: string)` Forces a refresh of the asset's balance from the blockchain. **Parameters** - **vaultAccountId** (string) - The ID of the vault account. - **assetId** (string) - The ID of the asset. **Returns** - A promise that resolves when the balance refresh is initiated. ### `getVaultBalanceByAsset(assetId: string)` Aggregates the total balance for a specific asset across all vault accounts. **Parameters** - **assetId** (string) - The ID of the asset. **Returns** - An object containing the `total` balance of the asset across all vaults. ### `getAssetWallets(params: { assetId: string, before?: string, after?: string, limit?: number })` Lists asset wallets with support for pagination. **Parameters** - **params** (object) - **assetId** (string) - The ID of the asset. - **before** (string, optional) - Cursor for before pagination. - **after** (string, optional) - Cursor for after pagination. - **limit** (number, optional) - The maximum number of results to return. **Returns** - An object containing an array of `AssetWallet` objects. ``` -------------------------------- ### Create Vault Accounts and Assets in Bulk Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Use these methods to create large numbers of vault accounts or assets asynchronously. Monitor job status using jobId. ```typescript // Create 100 vault accounts in one bulk call const job = await fireblocks.createVaultAccountsBulk(100, "ETH"); console.log(job.jobId); // "job-uuid" // Create ETH wallets for vault accounts 0 through 99 const assetJob = await fireblocks.createVaultAssetsBulk("ETH", "0", "99"); // Monitor job status const jobInfo = await fireblocks.getJobById(job.jobId); console.log(jobInfo.status); // "EXECUTING" console.log(jobInfo.total); // 100 console.log(jobInfo.completed); // 42 // Get all tasks for a job const tasks = await fireblocks.getTasksByJobId(job.jobId); // List jobs in a time range const jobs = await fireblocks.getJobsForTenant( Date.now() - 86400000, // 24h ago (Unix ms) Date.now() ); // Control job execution await fireblocks.pauseJob(job.jobId); await fireblocks.continueJob(job.jobId); await fireblocks.cancelJob(job.jobId); ``` -------------------------------- ### Gas Station Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Configure automatic ETH/gas funding for vault accounts. The gas station automatically tops up assets when they fall below a threshold. ```APIDOC ## getGasStationInfo ### Description Retrieves the current gas station configuration and balance for a specified asset or the default ETH asset. ### Method `getGasStationInfo(assetId?: string)` ### Parameters #### Path Parameters - **assetId** (string) - Optional - The ID of the asset for which to get gas station info (defaults to ETH). ### Request Example ```typescript const gasInfo = await fireblocks.getGasStationInfo(); console.log(gasInfo.configuration); console.log(gasInfo.balance.ETH); const maticGasInfo = await fireblocks.getGasStationInfo("MATIC"); ``` ### Response Example ```json { "configuration": { "gasThreshold": "0.001", "gasCap": "0.01", "maxGasPrice": "100" }, "balance": { "ETH": { "balance": "0.5" } }, "...": "..." } ``` ``` ```APIDOC ## setGasStationConfiguration ### Description Updates the gas station configuration for automatic gas funding. ### Method `setGasStationConfiguration(gasThreshold: string, gasCap: string, maxGasPrice: string, assetId?: string)` ### Parameters #### Path Parameters - **gasThreshold** (string) - Required - The amount below which the asset will be topped up. - **gasCap** (string) - Required - The maximum amount of gas to hold. - **maxGasPrice** (string) - Required - The maximum gas price (in Gwei). - **assetId** (string) - Optional - The ID of the asset to configure (omit for default ETH configuration). ### Request Example ```typescript await fireblocks.setGasStationConfiguration( "0.002", "0.02", "150", undefined ); ``` ``` -------------------------------- ### Manage Fireblocks Users and Groups Source: https://context7.com/fireblocks/fireblocks-sdk-js/llms.txt Manage console users, API users, and user groups. Ensure correct role types are used when creating users. User IDs are required for group membership. ```typescript import { TRole } from "fireblocks-sdk"; // List all API users const { users: apiUsers } = await fireblocks.getApiUsers(); console.log(apiUsers[0].name); // "Automation Bot" // List all console users const { users: consoleUsers } = await fireblocks.getConsoleUsers(); // Create a new console user await fireblocks.createConsoleUser( "Jane", "Doe", "jane.doe@company.com", "VIEWER" as TRole ); // Create an API user with a CSR await fireblocks.createApiUser( "Automation Service", "EDITOR" as TRole, "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----" ); // Create a user group const group = await fireblocks.createUserGroup("Approvers Team", ["user-id-1", "user-id-2"]); console.log(group.id); // "group-uuid" // Update group membership await fireblocks.updateUserGroup(group.id, "Approvers Team v2", ["user-id-1", "user-id-3"]); // Delete a group await fireblocks.deleteUserGroup(group.id); // Get OTA (One-Time-Address) configuration const otaConfig = await fireblocks.getOtaConfiguration(); console.log(otaConfig.enabled); // false // Enable OTA await fireblocks.updateOtaConfiguration(true); ```