### Clone and Run OneBalance Privy Demo Application Source: https://docs.onebalance.io/getting-started/setup This script automates the setup of the OneBalance Privy demo. It clones the repository, navigates into it, installs project dependencies using pnpm, copies the example environment file, and starts the development server. This provides a quick way to get the application running for exploration. ```shell # Clone the repository git clone https://github.com/OneBalance-io/onebalance-privy-demo.git cd onebalance-privy-demo # Install dependencies pnpm install # Copy environment variables cp .env.example .env # Start the development server pnpm dev ``` -------------------------------- ### OneBalance MCP Server Installation Output Source: https://docs.onebalance.io/ai/mcp-server-setup Expected output after successfully installing the OneBalance MCP server, showing the installed tools, API key prompt, server location, client selection, and the command to start the server. ```Shell 🛠 Installing Tools: search - Documentation search predict-smart-account-address - Get smart account addresses list-supported-aggregated-assets - View supported assets get-aggregated-balance - Fetch account balances list-supported-chains - View supported networks get-quote-status - Check quote execution status get-transaction-history - Retrieve transaction history get-quote - Request transfer/swap quotes prepare-call-quote - Prepare contract calls get-call-quote - Get contract call quotes execute-quote - Execute quotes ✔ What is the API Key for "OneBalance API"? … ✔ Created new MCP server at ~/.mcp/onebalance-d7e5d4d0 ✔ Select MCP client: › All ✔ Successfully installed MCP server to Cursor, Claude Desktop To start your MCP server, run: node ~/.mcp/onebalance-d7e5d4d0/src/index.js ``` -------------------------------- ### OneBalance API Keys and Authentication Setup Source: https://docs.onebalance.io/overview/onboarding-checklist Outlines the process for obtaining production API keys from OneBalance, implementing proper authentication in applications, and requesting higher rate limits. ```APIDOC API Keys & Authentication: - Request production API keys from the OneBalance team - Implement proper authentication in your app (refer to /api-reference/authentication) - Contact us if you need higher rate limits (refer to /api-reference/rate-limits) ``` -------------------------------- ### Install OneBalance MCP Server Source: https://docs.onebalance.io/ai/mcp-server-setup Command to add the OneBalance Model Context Protocol (MCP) server, which integrates OneBalance documentation and API with AI tools. ```Shell npx mint-mcp add onebalance-d7e5d4d0 ``` -------------------------------- ### OneBalance Core APIs Reference Source: https://docs.onebalance.io/llms-full A list of core OneBalance APIs used in the getting started guide, including endpoints for account prediction, balance aggregation, quote retrieval, quote execution, and transaction status checking. ```APIDOC Predict Account Address: Get your smart contract account address before deployment Get Aggregated Balance: View your token balances across all chains Get Quote: Request quotes for cross-chain swaps or transfers Execute Quote: Execute your signed quotes Check Status: Track your transaction status ``` -------------------------------- ### Install Node.js and pnpm using nvm for OneBalance Development Source: https://docs.onebalance.io/getting-started/setup This script provides commands to set up the recommended Node.js environment. It first installs nvm (Node Version Manager) if not present, then uses nvm to install and activate Node.js version 20, and finally installs the pnpm package manager globally. This ensures the necessary prerequisites for OneBalance development are met. ```shell # Install nvm (if not already installed) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash # Install and use Node.js 20 nvm install 20 nvm use 20 # Install pnpm globally ``` -------------------------------- ### Clone and Run OneBalance Privy Demo Repository Source: https://docs.onebalance.io/llms-full A Bash script to clone the OneBalance Privy demo repository, navigate into it, install project dependencies using pnpm, and copy the example environment variables file to prepare the project for local development. ```Bash # Clone the repository git clone https://github.com/OneBalance-io/onebalance-privy-demo.git cd onebalance-privy-demo # Install dependencies pnpm install # Copy environment variables cp .env.example .env ``` -------------------------------- ### Install pnpm globally using npm Source: https://docs.onebalance.io/getting-started/setup This command installs pnpm, a fast, disk space efficient package manager, globally on your system using npm. ```shell npm install -g pnpm ``` -------------------------------- ### OneBalance API: Example Initial Paginated Request (Bash) Source: https://docs.onebalance.io/llms-full This Bash snippet provides a practical example of an initial GET request to retrieve paginated transaction history from the OneBalance API. It demonstrates how to specify the `user` address and the `limit` for the number of transactions to be returned in the first page of results. ```bash GET /api/status/get-tx-history?user=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&limit=10 ``` -------------------------------- ### Install Project Dependencies Source: https://docs.onebalance.io/guides/contract-calls/getting-started Commands to install necessary runtime dependencies (viem, axios) and development dependencies (typescript, @types/node, ts-node, tslib) for the TypeScript project. ```Shell pnpm add viem axios pnpm add -D typescript @types/node ts-node tslib ``` -------------------------------- ### Install OneBalance Model Context Protocol (MCP) Server Source: https://docs.onebalance.io/ai/building-with-llms Execute this command to install the OneBalance MCP server, which facilitates direct documentation search and live OneBalance API function access within your AI tools. ```bash npx mint-mcp add onebalance-d7e5d4d0 ``` -------------------------------- ### Install Core Dependencies for Wallet Connection and Auth Source: https://docs.onebalance.io/llms-full Installs necessary packages for wallet connection, transaction signing, and authentication using Privy, including @tanstack/react-query, wagmi, viem, and @privy-io/react-auth. ```bash pnpm add @tanstack/react-query wagmi viem @privy-io/react-auth ``` -------------------------------- ### Install Node.js, nvm, and pnpm Source: https://docs.onebalance.io/llms-full Instructions for installing Node.js version 20 using nvm (Node Version Manager) and then installing the pnpm package manager globally. This ensures the correct development environment is set up before proceeding with project creation. ```bash # Install nvm (if not already installed) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash # Install and use Node.js 20 nvm install 20 nvm use 20 # Install pnpm globally # Using npm to install pnpm as a one-time step npm install -g pnpm ``` -------------------------------- ### Install Core Libraries for Wallet and Data Management Source: https://docs.onebalance.io/guides/chain-abstracted-swap-with-privy Installs essential npm packages: @tanstack/react-query for data fetching, wagmi and viem for Ethereum blockchain interactions, and @privy-io/react-auth for Privy authentication and wallet integration. ```Shell pnpm add @tanstack/react-query wagmi viem @privy-io/react-auth ``` -------------------------------- ### API Reference: Authentication Setup Source: https://docs.onebalance.io/concepts/aggregated-assets Documentation covering API key setup and authentication procedures for accessing aggregated assets. ```APIDOC Endpoint: /api-reference/authentication Description: API key setup and authentication for accessing aggregated assets. ``` -------------------------------- ### Install OneBalance Project Dependencies Source: https://docs.onebalance.io/llms-full Commands to install required npm packages for the OneBalance project, including `viem`, `axios`, `typescript`, and related development dependencies. ```bash pnpm add viem axios pnpm add -D typescript @types/node ts-node tslib ``` -------------------------------- ### Generate OneBalance TypeScript SDK Source: https://docs.onebalance.io/ai/mcp-prompts This prompt instructs the AI to generate a TypeScript SDK wrapper for the OneBalance API, complete with type definitions, error handling, and example usage for all endpoints. ```Natural Language Generate a TypeScript SDK wrapper for OneBalance API that includes type definitions, error handling, and example usage for all endpoints. ``` -------------------------------- ### Starting Local Development Server with pnpm Source: https://docs.onebalance.io/getting-started/setup This command initiates the development server for the application using pnpm. It allows developers to run the application locally and access it via a web browser, typically at http://localhost:3000. ```bash pnpm dev ``` -------------------------------- ### Create a new Next.js project with pnpm Source: https://docs.onebalance.io/getting-started/setup Initializes a new Next.js application using pnpm, setting up the project structure and default configurations. The subsequent command navigates into the newly created project directory. ```shell pnpm create next-app onebalance-privy-demo cd onebalance-privy-demo ``` -------------------------------- ### Example Quote Status API Response Source: https://docs.onebalance.io/api-reference/status/get-quote-status An example JSON response body returned by the Get Quote Status API endpoint, detailing the quote ID, status, user, recipient account, and associated origin/destination chain operations. ```JSON { "quoteId": "0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d", "status": { "status": "COMPLETED" }, "user": "0x9b747cC14A5672a7166b4eccdc92d7F4003f8081", "recipientAccountId": "eip155:1/0x9b747cC14A5672a7166b4eccdc92d7F4003f8081", "originChainOperations": [ { "hash": "0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d", "chainId": 1, "explorerUrl": "https://etherscan.io/tx/0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d" } ], "destinationChainOperations": [ { "hash": "0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d", "chainId": 1, "explorerUrl": "https://etherscan.io/tx/0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d" } ] } ``` -------------------------------- ### cURL Example: Get Aggregated Balance Source: https://docs.onebalance.io/api-reference/balances/aggregated-balance Demonstrates how to make a GET request to the OneBalance aggregated balance API using cURL, including the required 'x-api-key' header for authentication. ```cURL curl --request GET \ --url https://be.onebalance.io/api/v2/balances/aggregated-balance \ --header 'x-api-key: ' ``` -------------------------------- ### Example OneBalance API GET Request with x-api-key Source: https://docs.onebalance.io/api-reference/quotes/get-quote Demonstrates how to make a GET request to a OneBalance API endpoint using `curl`, including the necessary `x-api-key` header for authentication. Replace `${ONEBALANCE_API_KEY}` with your actual API key. ```shell curl -X 'GET' \ 'https://be.onebalance.io/api/path-to/endpoint' \ -H 'x-api-key: ${ONEBALANCE_API_KEY}' \ ... ``` -------------------------------- ### Install project dependencies with pnpm Source: https://docs.onebalance.io/getting-started/setup Adds essential libraries for authentication (Privy), blockchain interaction (Viem), data fetching (TanStack Query), environment variable management (dotenv), and HTTP requests (axios) to the project. ```shell pnpm add @privy-io/react-auth viem @tanstack/react-query dotenv axios ``` -------------------------------- ### Authenticate GET Request with x-api-key using Curl Source: https://docs.onebalance.io/api-reference/quotes/get-call-quote Example Curl command demonstrating how to make a GET request to a OneBalance API endpoint by including the 'x-api-key' in the request header for authentication. Replace '${ONEBALANCE_API_KEY}' with your actual API key. ```curl curl -X 'GET' \ 'https://be.onebalance.io/api/path-to/endpoint' \ -H 'x-api-key: ${ONEBALANCE_API_KEY}' \ ... ``` -------------------------------- ### cURL Example: Authenticate OneBalance API Request Source: https://docs.onebalance.io/api-reference/balances/aggregated-balance Provides a cURL example demonstrating how to include the 'x-api-key' header for authenticating a generic OneBalance API endpoint. ```cURL curl -X 'GET' \ 'https://be.onebalance.io/api/path-to/endpoint' \ -H 'x-api-key: ${ONEBALANCE_API_KEY}' \ ... ``` -------------------------------- ### cURL Example for Aggregated Balance API Source: https://docs.onebalance.io/api-reference/balances/aggregated-balance This cURL command demonstrates how to make a GET request to the OneBalance aggregated balance API endpoint. It includes the necessary URL and an 'x-api-key' header for authentication. ```cURL curl --request GET \ --url https://be.onebalance.io/api/v2/balances/aggregated-balance \ --header 'x-api-key: ' ``` -------------------------------- ### Create an empty .env file Source: https://docs.onebalance.io/getting-started/setup Provides an alternative command-line method to create an empty .env file in the project root, which can then be populated with API keys. ```shell # Create .env file touch .env ``` -------------------------------- ### Quick setup for OneBalance MCP server Source: https://docs.onebalance.io/faq/ai This command quickly sets up the Model Context Protocol (MCP) server, connecting OneBalance's documentation and API directly to your AI tools. It enables documentation search and live API access to OneBalance functions. ```Shell npx mint-mcp add onebalance-d7e5d4d0 ``` -------------------------------- ### EIP-712 Typed Data Structure Example Source: https://docs.onebalance.io/api-reference/quotes/get-call-quote A JSON example of a partial EIP-712 typed data structure, commonly used for off-chain message signing in blockchain applications. It defines the domain, types, primary type, and message for a specific approval operation. ```JSON { "verifyingContract": "0xA24bD06230f3F54e5bf266AE7A41750eE3b789FA" }, "types": { "Approve": [ { "name": "callDataAndNonceHash", "type": "bytes32" } ] }, "primaryType": "Approve", "message": { "callDataAndNonceHash": "0xaab2ddac63e4a7e25b7d339cacdff2f9280025cef27699ffe5f5e9e9625b15eb" } } ``` -------------------------------- ### Get Latest Account Transaction Source: https://docs.onebalance.io/ai/mcp-prompts Prompt to retrieve the most recent transaction associated with the user's account. ```AI Prompt What's the latest transaction for my account? ``` -------------------------------- ### Example JSON Response for Get Transaction History Source: https://docs.onebalance.io/api-reference/status/get-transaction-history Provides a sample JSON structure returned by the /status/get-tx-history endpoint, illustrating the format of transaction details, including quote IDs, statuses, user and recipient accounts, chain operations, token details (origin/destination), and timestamps. ```JSON { "transactions": [ { "quoteId": "0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d", "status": { "status": "COMPLETED" }, "user": "0x9b747cC14A5672a7166b4eccdc92d7F4003f8081", "recipientAccountId": "eip155:1/0x9b747cC14A5672a7166b4eccdc92d7F4003f8081", "originChainOperations": [ { "hash": "0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d", "chainId": 1, "explorerUrl": "https://etherscan.io/tx/0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d" } ], "destinationChainOperations": [ { "hash": "0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d", "chainId": 1, "explorerUrl": "https://etherscan.io/tx/0xfa6094cd9d65416c975e3498cc5c2ca17df6c4cfa37e16f84f2736296dd98b5d" } ], "type": "SWAP", "originToken": { "aggregatedAssetId": "ds:eth", "amount": "1000000000000000000", "assetType": [ "eip155:1/erc20:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "eip155:1/slip44:60" ], "fiatValue": [ { "assetType": "eip155:1/erc20:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "fiatValue": "1800" } ] }, "destinationToken": { "aggregatedAssetId": "ds:usdc", "amount": "1800000000", "assetType": "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "fiatValue": "1800" }, "timestamp": "2024-01-01T12:00:00.000Z" }, { "quoteId": "0xed8c3dd2455c0569c63aef2ac8fa63d94a9b35caed36e3a70ee3af01cec3a7d5", "status": { "status": "COMPLETED" }, "user": "0x9b747cC14A5672a7166b4eccdc92d7F4003f8081", "recipientAccountId": "eip155:10/0x7654321aBC987654321DEF12345678901234567", "originChainOperations": [ { "hash": "0xed8c3dd2455c0569c63aef2ac8fa63d94a9b35caed36e3a70ee3af01cec3a7d5", "chainId": 1, "explorerUrl": "https://etherscan.io/tx/0xed8c3dd2455c0569c63aef2ac8fa63d94a9b35caed36e3a70ee3af01cec3a7d5" } ], "destinationChainOperations": [ { "hash": "0xa1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", "chainId": 10, "explorerUrl": "https://optimistic.etherscan.io/tx/0xa1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2" } ], "type": "TRANSFER", "originToken": { "aggregatedAssetId": "ds:usdc", "amount": "500000000", "assetType": [ "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" ], "fiatValue": [ { "assetType": "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "fiatValue": "500" } ] }, "destinationToken": { "aggregatedAssetId": "ds:usdc", "amount": "495000000", "assetType": "eip155:10/erc20:0x7f5c764cbc14f9669b88837ca1490cca17c31607", "fiatValue": "495" }, "timestamp": "2023-12-31T18:30:00.000Z" } ], "continuation": "txn_00123456789abcdef" } ``` -------------------------------- ### Initialize OneBalance Calldata Project Source: https://docs.onebalance.io/guides/contract-calls/getting-started Commands to create a new directory for the OneBalance calldata project and initialize it using pnpm. ```Shell mkdir onebalance-calldata && cd onebalance-calldata pnpm init ``` -------------------------------- ### Example Cross-Origin Fetch Request to OneBalance API Source: https://docs.onebalance.io/api-reference/cors Demonstrates how to make a GET request to the OneBalance API's assets list endpoint from a client-side JavaScript application. This example includes necessary headers for authentication ('x-api-key') and content type ('Content-Type: application/json'), and handles the promise-based response. ```JavaScript // Example of a cross-origin fetch request fetch('https://be.onebalance.io/api/assets/list', { method: 'GET', headers: { 'x-api-key': 'your-api-key', 'Content-Type': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### OneBalance Gas Abstraction Configuration Source: https://docs.onebalance.io/overview/onboarding-checklist Details the steps for configuring Paymaster settings for gas sponsorship, setting up fee structures and limits, and testing gas abstraction in a staging environment. ```APIDOC Gas Abstraction Setup: - Configure Paymaster settings for gas sponsorship - Set up fee structures and limits - Test gas abstraction in staging environment ``` -------------------------------- ### OneBalance API Pagination Example: Initial Request Source: https://docs.onebalance.io/api-reference/pagination Demonstrates an initial GET request to the `/api/status/get-tx-history` endpoint. It specifies a user address and a `limit` for the maximum number of transactions to return in the first page. ```APIDOC GET /api/status/get-tx-history?user=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&limit=10 ``` -------------------------------- ### OneBalance MCP: Simple Account & Balance Queries Source: https://docs.onebalance.io/llms-full Examples of basic prompts to query account balances, supported chains, available assets, and predict smart account addresses using the OneBalance MCP server. ```bash What is my aggregated balance across all chains for address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045? ``` ```bash Show me all supported chains on OneBalance ``` ```bash What aggregated assets are available on OneBalance? ``` ```bash Predict a smart account address for session signer 0x1cBFbFd62a276BF6D79d504eA4CA75a7baDcf5b1 and admin signer 0xc162a3cE45ad151eeCd0a5532D6E489D034aB3B8 ``` -------------------------------- ### Generate Token Swap Quote Source: https://docs.onebalance.io/ai/mcp-prompts Prompt to get a quote for swapping a specified amount of one token (USDC) to another (ETH) using aggregated balance. ```AI Prompt Get a quote to swap 10 USDC to ETH using my aggregated balance ``` -------------------------------- ### OneBalance API Pagination Example: Subsequent Request Source: https://docs.onebalance.io/api-reference/pagination Illustrates how to make a subsequent request to fetch the next page of results. This is achieved by including the `continuation` token obtained from the previous response in the new GET request. ```APIDOC GET /api/status/get-tx-history?user=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&limit=10&continuation=txn_00123456789abcdef ``` -------------------------------- ### OneBalance MCP Server Setup Command Source: https://docs.onebalance.io/llms-full Command to set up the OneBalance Model Context Protocol (MCP) server, enabling direct API access and documentation search within AI tools. ```bash npx mint-mcp add onebalance-d7e5d4d0 ``` -------------------------------- ### Install Project Dependencies Source: https://docs.onebalance.io/llms-full Command to add the necessary packages for the project, including @privy-io/react-auth for authentication, viem for Ethereum interactions, @tanstack/react-query for data fetching, dotenv for environment variables, and axios for HTTP requests. ```bash pnpm add @privy-io/react-auth viem @tanstack/react-query dotenv axios ``` -------------------------------- ### Create Main TypeScript File Source: https://docs.onebalance.io/guides/contract-calls/getting-started Initializes the main TypeScript file for the project where API integration code will reside. ```shell touch index.ts ``` -------------------------------- ### OneBalance API Key Authentication Source: https://docs.onebalance.io/api-reference/status/get-transaction-history Explains the authentication method for the OneBalance API, which uses an API key in the 'x-api-key' header. It specifies the parameter details and provides a cURL example for demonstration. ```APIDOC Parameter: x-api-key Type: string Location: header Required: true Description: The OneBalance API uses API keys to authenticate requests. All API requests require authentication using an API key passed in the 'x-api-key' header. A public API key is available for testing purposes with limited usage: 42bb629272001ee1163ca0dbbbc07bcbb0ef57a57baf16c4b1d4672db4562c11. All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail. ``` ```cURL curl -X 'GET' \ 'https://be.onebalance.io/api/path-to/endpoint' \ -H 'x-api-key: ${ONEBALANCE_API_KEY}' \ ... ``` -------------------------------- ### Install OneBalance MCP Server Source: https://docs.onebalance.io/llms-full Install the OneBalance Model Context Protocol (MCP) server using npx. This command sets up the necessary tools to connect OneBalance's documentation and API to AI clients. ```bash npx mint-mcp add onebalance-d7e5d4d0 ``` -------------------------------- ### cURL Example for Listing Supported Chains Source: https://docs.onebalance.io/api-reference/chains/list Demonstrates how to make a GET request using cURL to the '/chains/supported-list' endpoint to retrieve supported blockchain networks. Requires an API key for authentication. ```cURL curl --request GET \ --url https://be.onebalance.io/api/chains/supported-list \ --header 'x-api-key: ' ``` -------------------------------- ### Get DeFi Protocol Interaction Quote Source: https://docs.onebalance.io/ai/mcp-prompts This prompt asks for a quote to interact with a DeFi protocol, specifically depositing USDC into AAVE on Base, using a cross-chain balance for the transaction. ```Natural Language Get a quote for interacting with a DeFi protocol: deposit 500 USDC into AAVE on Base using my cross-chain balance. ``` -------------------------------- ### Starting Development Server Source: https://docs.onebalance.io/llms-full This bash command initiates the local development server for the application using pnpm. It allows developers to run and test the application locally, typically accessible via http://localhost:3000. ```bash pnpm dev ``` -------------------------------- ### Set Up OneBalance MCP Server Source: https://docs.onebalance.io/llms-full This command quickly sets up the Model Context Protocol (MCP) server for OneBalance, connecting its documentation and API to your AI tools. The MCP server provides documentation search and live API access. ```bash npx mint-mcp add onebalance-d7e5d4d0 ``` -------------------------------- ### Authenticate OneBalance API Requests with cURL Source: https://docs.onebalance.io/llms-full Demonstrates how to authenticate requests to the OneBalance API using an API key passed in the `x-api-key` header. This example shows a GET request to list assets. ```bash curl -X 'GET' \ 'https://be.onebalance.io/api/assets/list' \ -H 'x-api-key: 42bb629272001ee1163ca0dbbbc07bcbb0ef57a57baf16c4b1d4672db4562c11' ``` -------------------------------- ### OneBalance Transaction Monitoring Implementation Source: https://docs.onebalance.io/overview/onboarding-checklist Describes how to implement transaction status monitoring using OneBalance's status endpoints and set up error handling and logging for applications. ```APIDOC Monitoring: - Implement transaction status monitoring using our status endpoints (refer to /api-reference/status/get-quote-status) - Set up error handling and logging ``` -------------------------------- ### Get Call Quote for Contract Operations Source: https://docs.onebalance.io/api-reference/quotes/get-call-quote This example demonstrates how to send a POST request to the /api/quotes/call-quote endpoint using cURL. It includes a comprehensive JSON payload detailing account information, a user operation (userOp) with various blockchain-specific parameters like sender, nonce, factory, callData, gas limits, and a signature, along with typed data for signing. An 'x-api-key' header is required for authentication. ```cURL curl --request POST \ --url https://be.onebalance.io/api/quotes/call-quote \ --header 'Content-Type: application/json' \ --header 'x-api-key: ' \ --data '{ "account": { "accountAddress": "0xb8e4b017f4a8870E3eB4eb15c5e180D2a34D877B", "adminAddress": "0x8FA09fc75bC2619e594cCb720096627DCaA7c5C4", "sessionAddress": "0xBbef1E2dEA96c1c2001Eb48136e513A855F46097" }, "chainOperation": { "userOp": { "sender": "0xb8e4b017f4a8870e3eb4eb15c5e180d2a34d877b", "nonce": "1120126849530300722547379539971600052481264750391572034956634531672621056", "factory": "0xd703aae79538628d27099b8c4f621be4ccd142d5", "factoryData": "0xc5265d5d000000000000000000000000aac5d4240af87249b3f71bc8e4a2cae074a3e4190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002443c3b752b01a24bd06230f3f54e5bf266ae7a41750ee3b789fa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000bbef1e2dea96c1c2001eb48136e513a855f460970000000000000000000000008fa09fc75bc2619e594ccb720096627dcaa7c5c400000000000000000000000078264308ad049116f52162822801b5ebfd8f5cea00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "callData": "0xe9ae5c53010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000340000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000b8e4b017f4a8870e3eb4eb15c5e180d2a34d877b00000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000000000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000bbef1e2dea96c1c2001eb48136e513a855f460970000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000b8e4b017f4a8870e3eb4eb15c5e180d2a34d877b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "callGasLimit": "737280", "verificationGasLimit": "3076170", "preVerificationGas": "0", "maxFeePerGas": "0", "maxPriorityFeePerGas": "0", "paymaster": "0xa784e6482bd5edbfe5991b18cbd545ebd46e1cc4", "paymasterVerificationGasLimit": "19219", "paymasterPostOpGasLimit": "0", "paymasterData": "0x", "signature": "0x8cbd9df26744e2a02cde9fb8832d2b5fbf5224261061a92bddb673cbfeb9849737cb80c5b5ae535007a1d57a377294c5a61033baef242b93faede408322feb651c" }, "typedDataToSign": { "domain": { "name": "RoleBasedECDSAValidator", "version": "1.4.3" } } } }' ``` -------------------------------- ### Configure environment variables in .env file Source: https://docs.onebalance.io/getting-started/setup Creates a .env file to store sensitive API keys for Privy and OneBalance, essential for the application's functionality. These keys are marked for quickstart use only and should be replaced in production. ```env # .env NEXT_PUBLIC_PRIVY_APP_ID=cmb94tjcj001xle0mdeerz9vp # For quickstart only; use your own in production NEXT_PUBLIC_ONEBALANCE_API_KEY=42bb629272001ee1163ca0dbbbc07bcbb0ef57a57baf16c4b1d4672db4562c11 # For quickstart only ``` -------------------------------- ### JSON Example: Aggregated Balance API Response Source: https://docs.onebalance.io/api-reference/balances/aggregated-balance Illustrates the structure and content of a successful JSON response from the aggregated balance API, showing balances by aggregated asset, individual asset details, and total fiat value. ```JSON { "balanceByAggregatedAsset": [ { "aggregatedAssetId": "ds:eth", "balance": "26720629499317191152", "individualAssetBalances": [ { "assetType": "eip155:42161/slip44:60", "balance": "43872973277400073", "fiatValue": 77.727114 }, { "assetType": "eip155:8453/slip44:60", "balance": "26488136306212020002", "fiatValue": 46927.441806 }, { "assetType": "eip155:10/slip44:60", "balance": "188620219827771077", "fiatValue": 334.167126 } ], "fiatValue": 47339.336046 }, { "aggregatedAssetId": "ds:usdc", "balance": "843936437", "individualAssetBalances": [ { "assetType": "eip155:42161/erc20:0xaf88d065e77c8cc2239327c5edb3a432268e5831", "balance": "62459466", "fiatValue": 62.456468 }, { "assetType": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", "balance": "774598041", "fiatValue": 774.563184 }, { "assetType": "eip155:10/erc20:0x0b2c639c533813f4aa9d7837caf62653d097ff85", "balance": "5845251", "fiatValue": 5.844988 }, { "assetType": "eip155:43114/erc20:0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e", "balance": "1033679", "fiatValue": 1.033632 } ], "fiatValue": 843.898272 } ], "balanceBySpecificAsset": [ { "assetType": "eip155:1/erc20:0xae7ab96520de3a18e5e111b5eaab095312d7fe84", "balance": "0", "fiatValue": 0 } ], "totalBalance": { "fiatValue": 78138.51832 } } ``` -------------------------------- ### Request Quote for Asset Transfer/Swap Source: https://docs.onebalance.io/api-reference/quotes/get-quote This cURL example demonstrates how to send a POST request to the `/v1/quote` endpoint. It specifies the 'from' account and asset details, along with the desired 'to' asset, to initiate a quote generation for asset transfer or swap. ```curl curl --request POST \ --url https://be.onebalance.io/api/v1/quote \ --header 'Content-Type: application/json' \ --header 'x-api-key: ' \ --data '{ "from": { "account": { "sessionAddress": "0x1cBFbFd62a276BF6D79d504eA4CA75a7baDcf5b1", "adminAddress": "0xc162a3cE45ad151eeCd0a5532D6E489D034aB3B8", "accountAddress": "0xE20295ec513DEf805D9c3083b0C8EaB64692D764" }, "asset": { "assetId": "ds:eth" }, "amount": "1000000000000000" }, "to": { "asset": { "assetId": "ds:usdc" } } }' ``` -------------------------------- ### Initialize OneBalance Calldata Project Directory Source: https://docs.onebalance.io/llms-full Commands to create and navigate into a new directory for the OneBalance calldata project and initialize pnpm. ```bash mkdir onebalance-calldata && cd onebalance-calldata pnpm init ``` -------------------------------- ### Key OneBalance APIs Used in This Guide Source: https://docs.onebalance.io/getting-started/introduction This section lists the core OneBalance APIs essential for building chain-abstracted applications, covering account prediction, balance aggregation, quote management, and transaction status tracking. ```APIDOC Predict Account Address: Get your smart contract account address before deployment Get Aggregated Balance: View your token balances across all chains Get Quote: Request quotes for cross-chain swaps or transfers Execute Quote: Execute your signed quotes Check Status: Track your transaction status ``` -------------------------------- ### Initialize Project File Source: https://docs.onebalance.io/llms-full This snippet demonstrates how to create the main TypeScript file for the project using a bash command. ```bash touch index.ts ```