SDK
Configure SDK
Initialize and configure the OpenOcean SDK in your project.
Initialize the SDK
Import and instantiate the SDK to access all available modules:
Terminal
JS
1 import { OpenoceanSdk } from '@openocean.finance/openocean-sdk' 2
3 const openoceanSdk = new OpenoceanSdk() 4 const { api, swapSdk, config } = openoceanSdk
You can then use all the functions exposed by the SDK (api and swapSdk).
Available Modules
api
Use for fetching quotes, token lists, gas prices, and balances. Example: api.quote(), api.getTokenList()
swapSdk
Use for wallet connection, token approvals, and executing swaps. Example: swapSdk.connectWallet(), swapSdk.swap()
config
Access chain and wallet configurations. Example: config.chains.chainNames, config.wallets.walletList
Supported Chains and Wallets
Access the list of supported chains and wallets from the config module:
Terminal
JS
1 // Get all supported chain names 2 let AllChainNames = config.chains.chainNames 3 // ["eth", "ropsten", "rinkeby", "bsc", "solana", "flow", "polygon", "avax", ...] 4
5 // Get all supported wallet names 6 let AllWalletNames = config.wallets.walletList.map(item => item.key) 7 // ["MetaMask", "CryptoCom", "TrustWallet", ...]