Prime SDK
Prime SDK examples
- Run Prime SDK examples
- Get Address
- Transfer Funds
- Transfer ERC20
- Transfer NFT
- Social Logins
- Get Account Balances
- Get Transaction
- Get Token List
- Get NFT List
- Show gas fee in fiat
- Get Exchange Rates
- Get Exchange Supported assets
- Use Paymaster
- Paymaster valid until after specified time
- Swap
- Get bridging quotes (LiFi)
- Get bridging quotes (other)
- Get Zerodev Address
- Get SimpleAccount Address
- User Specific callGasLimit
- Concurrent UserOps
- Add Guardians
Integrations
Chain Specific Tutorials
Prime SDK examples
Swap
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';
import { BigNumber, constants } from 'ethers';
dotenv.config();
async function main(): Promise<void> {
// initializating Data service...
const dataService = new DataUtils();
const exchangeSupportedAssets = await dataService.getExchangeSupportedAssets({ page: 1, limit: 100, account: '', chainId: Number(process.env.CHAIN_ID) });
console.log('\x1b[33m%s\x1b[0m', `Found exchange supported assets:`, exchangeSupportedAssets.items.length);
const fromTokenAddress = '0xe3818504c1b32bf1557b16c238b2e01fd3149c17';
const toTokenAddress = constants.AddressZero;
const fromAmount = '1000000000000000000';
const fromChainId = 1;
const offers = await dataService.getExchangeOffers({
fromAddress: '',
fromChainId,
fromTokenAddress,
toTokenAddress,
fromAmount: BigNumber.from(fromAmount),
});
console.log('\x1b[33m%s\x1b[0m', `Exchange offers:`, offers);
}
main()
.catch(console.error)
.finally(() => process.exit());