Utilities

You can use the utilities to work with networks that the SDK supports.

EVM Networks

import { Network } from '@holyheld/sdk';

holyheldSDK.evm.offRamp.getAvailableNetworks(); // ['ethereum', 'polygon', ...]
holyheldSDK.evm.onRamp.getAvailableNetworks(); // ['ethereum', 'polygon', ...]
holyheldSDK.evm.isEVMNetwork(Network.ethereum); // true
holyheldSDK.evm.getNetwork(Network.ethereum); // NetworkInfoEVM
holyheldSDK.evm.getNetworkChainId(Network.ethereum); // 1
holyheldSDK.evm.getNetworkByChainId(1); // NetworkInfoEVM | undefined

(async () => {
  const value = await holyheldSDK.evm.offRamp.getTopUpEstimation({ // estimate transaction cost (only supports estimation for native tokens used for gas fees)
    publicClient: publicClient, // create public client, see https://viem.sh/docs/clients/public.html
    network: Network.ethereum,
    amount: '5.25', // token amount
    walletAddress: '0x...', // wallet address
    supportsSignTypedDataV4: true, // true if connected wallet supports 'eth_signTypedData_v4' (default: false)
    supportsRawTransactionsSigning: true, // true if connected wallet supports raw transactions signing via 'eth_sign' or 'eth_signTransaction' (default: false)
  });

  console.log(value); // '287499997500000' (in WEI)
})();

Types:

type TokenEVM = {
  address: string; // smart contract address of the token
  decimals: number; // token decimal digits (as in ERC20 implementation)
  symbol: string; // token symbol
  network: Network; // network (blockchain), on which this token resides
  name: string; // name of the token
  iconURL: string; // logo (icon) for the token
  networkKind: NetworkKind.EVM // blockchain type
};

type NetworkInfoEVM = {
  network: Network;
  name: string; // name of the blockchain network, for example: 'Polygon Mainnet'
  chainId: number; // chainId of the corresponding network, for example: 137
  explorerURL: string; // block explorer URL of corresponding network, for example: 'https://polygonscan.com'
  explorerName: string; // block explorer name (e.g. to display user friendly link 'view on X'), for example: 'Polygonscan'
  baseAsset: TokenEVM; // base asset (native/gas token) of the network
  rpcUrls: string[]; // RPC URLs array (array supported for redundancy purposes), for example: ['https://polygon-rpc.com/'']
  iconURL: string; // logo (icon) for the network, displayed near token logo to identify on which network the token is on
  displayedName: string; // name of the network to display, for example: 'Polygon'
  orderIdx: number; // id for sorting, example: 1
  networkKind: NetworkKind.EVM // blockchain type
};

Solana Network

import { SolanaNetwork } from '@holyheld/sdk';

holyheldSDK.solana.offRamp.getAvailableNetworks(); // ['solana-mainnet']
holyheldSDK.solana.isSolanaNetwork(SolanaNetwork.Mainnet); // true
holyheldSDK.solana.getNetwork(SolanaNetwork.Mainnet); // NetworkInfoSolana

(async () => {
  // estimate transaction price
  const value = await holyheldSDK.solana.offRamp.getTopUpEstimation({
    connection: connection, // create connection, see https://solana-foundation.github.io/solana-web3.js/classes/Connection.html#constructor
    walletAddress: '...', // wallet address
    tokenAddress: '...', // token address
    tokenNetwork: SolanaNetwork.Mainnet,
    tokenAmount: '5.25', // token amount
    holytag: 'SDKTEST', // funds recipient tag
    transferData: transferData, // if was provided by 'convertTokenToEUR' and/or 'convertEURToToken'
  });

  console.log(value); // '229309' (in lamports)
})();

Types:

type TokenSolana = {
  address: string; // smart contract address of the token
  decimals: number; // token decimal digits
  symbol: string; // token symbol
  network: SolanaNetwork; // network (blockchain), on which this token resides
  name: string; // name of the token
  iconURL: string; // logo (icon) for the token
  networkKind: NetworkKind.Solana // blockchain type
};

type NetworkInfoSolana = {
  network: SolanaNetwork;
  name: string; // name of the blockchain network, for example: 'Solana Mainnet'
  explorerURL: string; // block explorer URL of corresponding network, for example: 'https://solscan.io'
  explorerName: string; // block explorer name (e.g. to display user friendly link 'view on X'), for example: 'Solscan'
  baseAsset: TokenSolana; // base asset (native/gas token) of the network
  httpRpcURL: string; // HTTP RPC endpoint, for example: 'https://solana-rpc.publicnode.com'
  wsRpcURL: string; // WebSocket RPC endpoint, for example: 'wss://solana-rpc.publicnode.com'
  iconURL: string; // logo (icon) for the network, displayed near token logo to identify on which network the token is on
  displayedName: string; // name of the network to display, for example: 'Solana'
  orderIdx: number; // id for sorting, for example: 1
  networkKind: NetworkKind.Solana // blockchain type
};