### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/supported-providers Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/supported-chains Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example/swaps-from-bitcoin Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example/swaps-from-evm Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/tokens-api Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example/swaps-from-solana Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic/swap-to-earn-program-on-rubic Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example/swaps-via-deposit Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example/swaps-from-tron Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic/roadmap Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Install Rubic SDK with NPM for Angular Source: https://docs.rubic.finance/integrate-sdk/install-sdk Install the Rubic SDK for Angular projects via NPM. This guide includes the installation command and specific adjustments needed for `tsconfig.json` and `polyfills.ts` to ensure compatibility, particularly concerning browser polyfills for Node.js modules. ```shell npm install rubic-sdk ``` ```shell npm install --save-dev stream-browserify assert https-browserify os-browserify stream-http crypto-browserify process buffer browserify-zlib browserify-fs querystring-es3 ``` ```json { "compilerOptions": { ... "paths": { ... "stream": ["./node_modules/stream-browserify"], "assert": ["./node_modules/assert"], "https": ["./node_modules/https-browserify"], "os": ["./node_modules/os-browserify"], "http": ["./node_modules/stream-http"], "crypto": ["./node_modules/crypto-browserify"], "querystring": ["./node_modules/querystring-es3"], "fs": ["node_modules/browserify-fs"], "zlib": ["node_modules/browserify-zlib"] } } } ``` ```typescript import Process = NodeJS.Process; export interface AppWindow extends Window { process: Process; Buffer: Buffer; global?: unknown; } (window as AppWindow).global = window; (window as AppWindow).process = window.process || require('process'); (window as AppWindow).Buffer = (window as any).Buffer || require('buffer').Buffer; ``` -------------------------------- ### SDK Initiation (NPM) Source: https://docs.rubic.finance/integrate-sdk/set-up-sdk Initializes the Rubic SDK after installation via npm. Requires importing the SDK and providing a configuration object with RPC providers. ```typescript import SDK, { BLOCKCHAIN_NAME, Configuration } from 'rubic-sdk'; const config: Configuration = { rpcProviders: { BSC: { rpcList: ['https://bsc-dataseed.binance.org/', ...] }, POLYGON: { rpcList: ['https://polygon-rpc.com', ...] }, TRON: { rpcList: [ { fullHost: '', headers: { "TRON-PRO-API-KEY": 'your api key' } } ] } } }; const rubicSDK = await SDK.createSDK(config) ``` -------------------------------- ### Get Best Cross-Chain Swap Quote (cURL) Source: https://docs.rubic.finance/rubic-api/rubic-api/request-quote Provides an example of how to call the quoteBest API endpoint using cURL. This command-line tool is useful for testing API interactions and demonstrates the required headers and JSON payload for the request. ```bash curl -X 'POST' \ 'https://api-v2.rubic.exchange/api/routes/quoteBest' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ \ "dstTokenAddress": "0x0000000000000000000000000000000000000000", \ "dstTokenBlockchain": "POLYGON", \ "referrer": "rubic.exchange", \ "srcTokenAddress": "0x0000000000000000000000000000000000000000", \ "srcTokenAmount": "1.05", \ "srcTokenBlockchain": "ETH" \ }' ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/how-to-start-using-rubic Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Get Supported Providers API Endpoint Source: https://docs.rubic.finance/rubic-api/rubic-api/supported-providers This section details the API endpoint for retrieving supported providers and their blockchain networks. It includes examples of how to make the request using Node.js with Axios and cURL, as well as the structure of the expected JSON response. ```APIDOC Endpoint: /api/info/providers Description: Retrieves a list of supported providers available for swaps in the Rubic API. Each provider object contains a list of supported blockchains and the provider name used in the API. It provides separate information for cross-chain and on-chain providers. Query Parameters: - includeTestnets (boolean, optional): If true, includes testnets in the response. Defaults to false. Example Request (Node.js - Axios): ```javascript const axios = require('axios'); async function getSupportedProviders() { try { const response = await axios.get( 'https://api-v2.rubic.exchange/api/info/providers?includeTestnets=false' ); console.log(response.data); return response.data; } catch (error) { console.error('Error fetching supported providers:', error); throw error; } } getSupportedProviders(); ``` Example Request (cURL): ```shell curl -X 'GET' \ 'https://api-v2.rubic.exchange/api/info/providers?includeTestnets=false' \ -H 'accept: application/json' ``` Example Response (JSON): ```json { "crossChain": [ { "chains": [ { "name": "ETH", "proxyAvailable": true }, { "name": "BSC", "proxyAvailable": true }, { "name": "POLYGON", "proxyAvailable": true }, { "name": "AVALANCHE", "proxyAvailable": true }, { "name": "FANTOM", "proxyAvailable": true }, { "name": "MOONRIVER", "proxyAvailable": true }, { "name": "ARBITRUM", "proxyAvailable": true }, { "name": "OPTIMISM", "proxyAvailable": true }, { "name": "GNOSIS", "proxyAvailable": false }, { "name": "FUSE", "proxyAvailable": false }, { "name": "MOONBEAM", "proxyAvailable": false }, { "name": "CELO", "proxyAvailable": false }, { "name": "BASE", "proxyAvailable": true }, { "name": "POLYGON_ZKEVM", "proxyAvailable": true }, { "name": "ZK_SYNC", "proxyAvailable": true }, { "name": "LINEA", "proxyAvailable": true }, { "name": "MODE", "proxyAvailable": true }, { "name": "SCROLL", "proxyAvailable": true }, { "name": "MANTLE", "proxyAvailable": true }, { "name": "ROOTSTOCK", "proxyAvailable": true }, { "name": "BLAST", "proxyAvailable": true }, { "name": "AURORA", "proxyAvailable": true } ], "name": "lifi" }, { "chains": [ { "name": "ETH", "proxyAvailable": true }, { "name": "BSC", "proxyAvailable": true }, { "name": "POLYGON", "proxyAvailable": true }, { "name": "AVALANCHE", "proxyAvailable": true }, { "name": "BOBA", "proxyAvailable": false }, { "name": "BOBA_BSC", "proxyAvailable": false }, { "name": "TELOS", "proxyAvailable": true }, { "name": "ZK_SYNC", "proxyAvailable": true }, { "name": "ARBITRUM", "proxyAvailable": true }, { "name": "OPTIMISM", "proxyAvailable": true }, { "name": "POLYGON_ZKEVM", "proxyAvailable": true }, { "name": "LINEA", "proxyAvailable": true }, { "name": "BASE", "proxyAvailable": true }, { "name": "MANTLE", "proxyAvailable": true }, { "name": "TRON", "proxyAvailable": false }, { "name": "SCROLL", "proxyAvailable": true }, { "name": "METIS", "proxyAvailable": true }, { "name": "BITCOIN", "proxyAvailable": false }, { "name": "BLAST", "proxyAvailable": true }, { "name": "MERLIN", "proxyAvailable": true }, { "name": "ROOTSTOCK", "proxyAvailable": true }, { "name": "MODE", "proxyAvailable": true }, { "name": "ZK_LINK", "proxyAvailable": true }, { "name": "TAIKO", "proxyAvailable": false }, { "name": "SEI", "proxyAvailable": false }, { "name": "CORE", "proxyAvailable": false }, { "name": "BAHAMUT", "proxyAvailable": false }, { "name": "ZETACHAIN", "proxyAvailable": true }, { "name": "MANTA_PACIFIC", "proxyAvailable": true } ], "name": "rubic" } ] } ``` -------------------------------- ### SDK Initiation (CDN) Source: https://docs.rubic.finance/integrate-sdk/set-up-sdk Initializes the Rubic SDK after installation via CDN. Requires a configuration object specifying RPC providers for different blockchains. ```javascript const config = { rpcProviders: { BSC: { rpcList: ['https://bsc-dataseed.binance.org/', ...] }, POLYGON: { rpcList: ['https://polygon-rpc.com', ...] }, TRON: { rpcList: [ { fullHost: '', headers: { "TRON-PRO-API-KEY": 'your api key' } } ] } } }; const rubicSdk = await RubicSDK.SDK.createSDK(config); ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/integrate-sdk/set-up-sdk Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Call Rubic API to Get Token Quotes Source: https://docs.rubic.finance/rubic-api/rubic-api/integration-example/swaps-from-bitcoin Example JavaScript function to call the Rubic API's 'quoteBest' endpoint. It sends a POST request with specified token and blockchain details and processes the JSON response, logging the estimated amount and swap ID. ```javascript async function quoteBest() { const response = await fetch("https://api-v2.rubic.exchange/api/routes/quoteBest", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ "srcTokenAddress": "0x0000000000000000000000000000000000000000", "srcTokenAmount": "0.01", "srcTokenBlockchain": "BITCOIN", "dstTokenAddress": "0x0000000000000000000000000000000000000000", "dstTokenBlockchain": "ETH", "referrer": "rubic.exchange" }) }); const data = await response.json(); const { estimate, transaction, id } = data; console.log(estimate); console.log(id); return data; } ``` -------------------------------- ### Install Rubic SDK with NPM for Webpack Source: https://docs.rubic.finance/integrate-sdk/install-sdk Install the Rubic SDK using NPM. This section details the command for installation and the required modifications to your webpack configuration, including plugins and resolve fallbacks, especially if web3.js is not already present. ```shell npm install rubic-sdk ``` ```shell npm install --save-dev http-browserify https-browserify stream-browserify crypto-browserify ``` ```json new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], process: 'process/browser'}) ``` ```json "fallback": { "fs": false, "constants": false, "querystring": false, "url": false, "path": false, "os": false, "http": require.resolve("http-browserify"), "https": require.resolve("https-browserify"), "zlib": false, "stream": require.resolve("stream-browserify"), "crypto": require.resolve("crypto-browserify") } ``` -------------------------------- ### SDK Initialization and Configuration Update Source: https://docs.rubic.finance/integrate-sdk/set-up-sdk Provides details on the primary SDK methods for initialization and updating configuration. `createSDK` sets up the SDK with initial parameters like RPC providers. `updateConfiguration` allows dynamic changes, such as adding wallet information or modifying RPC endpoints, and should be called upon relevant user events. ```apidoc SDK.createSDK(config: object) - Initializes the Rubic SDK with the provided configuration object. - Parameters: - config: An object containing initial SDK settings, such as `rpcProviders`. - rpcProviders: An object mapping chain names (e.g., 'BSC', 'POLYGON', 'TRON') to their RPC configurations. - rpcList: An array of RPC endpoint URLs or objects with host and headers. - Returns: A Promise that resolves to the initialized SDK instance. rubicSDK.updateConfiguration(newConfig: object) - Updates the SDK's configuration with new settings. - This method is crucial for reflecting changes like user wallet connection or network switches. - Parameters: - newConfig: An object containing the updated configuration. This can include: - walletProvider: An object defining the connected wallet for different chain types. - rpcProviders: Updated RPC provider configurations. - Usage: - Call this method whenever a user connects a wallet or switches networks to ensure the SDK is aware of the current state. - Related Methods: - SDK.createSDK ``` -------------------------------- ### Provide Wallet Provider Instance Source: https://docs.rubic.finance/integrate-sdk/set-up-sdk An example demonstrating how to instantiate the `walletProvider` object for the EVM chain, including the core Ethereum provider and the user's wallet address. ```javascript const walletProvider = { [CHAIN_TYPE.EVM]: { core: window.ethereum, address: '0x0123....89' } }; ``` -------------------------------- ### Get Supported Chains (cURL) Source: https://docs.rubic.finance/rubic-api/rubic-api/supported-chains Makes a GET request to the Rubic API to retrieve a list of supported blockchains, excluding testnets. ```bash curl -X 'GET' \ 'https://api-v2.rubic.exchange/api/info/chains?includeTestnets=false' \ -H 'accept: application/json' ``` -------------------------------- ### Basic Configuration (V2) Source: https://docs.rubic.finance/integrate-sdk/migration-from-v2-to-v3 Demonstrates the basic configuration setup for the Rubic SDK in Version 2. It includes initializing the SDK with RPC providers for different blockchains, an optional provider address, and wallet provider details. ```javascript import SDK, { BLOCKCHAIN_NAME, Configuration, WalletProvider } from 'rubic-sdk'; // optional parameter const walletProvider: WalletProvider = { address: '0x123...', // user wallet address chainId, core: window.ethereum }; // optional parameter const providerAddress = '0xabc...'; const configuration: Configuration = { rpcProviders: { // optional blockchains [BLOCKCHAIN_NAME.ETHEREUM]: { mainRpc: '' }, [BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: { mainRpc: '' }, ... }, providerAddress, walletProvider }; const sdk = await SDK.createSDK(configuration); ... // Later, if user changed address, you can update configuration: await sdk.updateConfiguration(configuration); ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/how-do-we-get-listed-on-rubic Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/request-quote Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/how-to-create-a-swap Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/how-do-i-add-the-binance-smart-chain-and-polygon-networks-to-metamask Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/integrate-sdk/install-sdk Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/request-data Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Initialize Rubic SDK with Configuration (v3) Source: https://docs.rubic.finance/integrate-sdk/migration-from-v2-to-v3 Demonstrates how to initialize the Rubic SDK using a detailed configuration object. This includes setting up RPC providers for various blockchains, provider addresses, and wallet providers for EVM and TRON. It also shows how to update the SDK configuration after initialization. ```TypeScript /** Notice that now sdk is imported as `import { SDK } from 'rubic-sdk';` Moreover, now you can import any object as `import { ... } from 'rubic-sdk'; */ import { SDK, BLOCKCHAIN_NAME, Configuration, WalletProvider, CHAIN_TYPE } from 'rubic-sdk'; // optional parameter const walletProvider: WalletProvider = { // CHAIN_TYPE is new type to separate EVM and TRON data [CHAIN_TYPE.EVM]: { address: '0x123...', // user wallet address core: window.ethereum }, // optional [CHAIN_TYPE.TRON]: { address: 'T123...', // user wallet address core: window.tronLink.tronWeb // or window.tronWeb } }; // optional parameter const providerAddress = { [CHAIN_TYPE.EVM]: '0xabc...', // optional [CHAIN_TYPE.TRON]: 'TaBc...' } const configuration: Configuration = { rpcProviders: { // optional blockchains [BLOCKCHAIN_NAME.ETHEREUM]: { rpcList: ['', '', ...] }, [BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: { rpcList: [''] }, ... [BLOCKCHAIN_NAME.TRON]: { rpcList: [ { // use your tron rpc provider fullHost: 'https://api.trongrid.io', headers: { "TRON-PRO-API-KEY": 'your api key' } } ] } }, providerAddress, walletProvider }; const sdk = await SDK.createSDK(configuration); ... // Later, if user changed address, you can update configuration: await sdk.updateConfiguration(configuration); // Or, if you want to update only wallet configuration, you can use // one of next functions: sdk.updateWalletProvider(walletProvider: WalletProvider); sdk.updateWalletProviderCore(chainType: keyof WalletProvider, walletProviderCore: WalletProviderCore); sdk.updateWalletAddress(chainType: keyof WalletProvider, address: string); ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/how-to-complete-swaps-to-from-ton-network-using-rubic Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/swagger Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/should-i-list-my-token-before-using-your-service Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/faq-1/why-do-we-offer-a-choice-between-different-providers Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/models Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/models/transactiondto Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ``` -------------------------------- ### Rubic API Integration Examples Source: https://docs.rubic.finance/rubic-api/rubic-api/models/routingdto Illustrative examples demonstrating how to perform cross-chain swaps using the Rubic API for various blockchain ecosystems. ```APIDOC Integration Examples: Purpose: To provide practical code snippets and guidance for implementing cross-chain swaps via the Rubic API. Covers: - Swaps from EVM chains (e.g., Ethereum, Polygon, BSC) - Swaps from Solana - Swaps from TON (The Open Network) - Swaps from Tron - Swaps from Bitcoin - Swaps VIA deposit (handling deposits to facilitate swaps) Note: Specific code implementations would typically be found in the 'Swagger' documentation or dedicated SDK examples. ```