Utilities
You can use the utilities to work with networks that the SDK supports:
import { Network } from '@holyheld/sdk';
holyheldSDK.getAvailableNetworks(); // ['ethereum', 'polygon', ...]
holyheldSDK.getNetworkChainId(Network.ethereum); // 1
holyheldSDK.getNetwork(Network.ethereum); // NetworkInfo
holyheldSDK.getNetworkByChainId(1); // NetworkInfo
(async () => {
// estimate transaction price
const value = await holyheldSDK.offRamp.getTopUpEstimation(Network.ethereum); // '287499997500000' (in WEI)
})();
Types:
type Token = {
// smart contract address of the token
address: string;
// token decimal digits (as in ERC20 implementation)
decimals: number;
// token symbol
symbol: string;
// network (blockchain), on which this token resides
network: Network;
// name of the token
name: string;
// logo (picture) for the token
iconURL: string;
};
type NetworkInfo = {
network: Network;
// name of the blockchain network
name: string; // example: 'Polygon Mainnet'
// chainId of the corresponding network
chainId: number; // example: 137
// block explorer URL of corresponding network
explorerURL: string; // example: 'https://polygonscan.com'
// block explorer name (e.g. to display user friendly link 'view on X')
explorerName: string; // example: 'Polygonscan'
// base asset (native/gas token) of the network
baseAsset: Token;
// RPC URLs array (array supported for redundancy purposes)
rpcUrls: string[]; // example: ['https://polygon-rpc.com/'']
// logo (picture) for the network, displayed near token logo to identify on which network the token is on
iconURL: string; // example: 'data:image/png;base64,...'
// name of the network to display
displayedName: string; // example: 'Polygon'
// id for sorting
orderIdx: number; // example: 1
};