Skip to content

Namespaces

business

The business namespace provides methods to interact with the Otmoic business service. It allows you to sign, send, confirm and refund assets, and submit complaints.

signQuote
typescript
signQuote(
    network: NetworkType,
    quote: Quote,
    amount: string,
    swapToNative: number,
    receivingAddress: string,
    expectedSingleStepTime?: number,
    tolerantSingleStepTime?: number,
    earliestRefundTime?: number,
    rpcSrc?: string,
    rpcDst?: string,
    option: SignSwapOption
): Promise<SwapSignData | SwapSignedData>

Signs a quote for a swap operation, supporting both EVM and Solana networks.

  • Parameters:
    • network (NetworkType): The network type
    • quote (Quote): The quote data to be signed
    • amount (string): The amount to be swapped
    • swapToNative (number): Percentage to swap to native token
    • receivingAddress (string): The address to receive the swapped tokens
    • expectedSingleStepTime (number, optional): Expected time for a single step
    • tolerantSingleStepTime (number, optional): Tolerant time for a single step
    • earliestRefundTime (number, optional): Earliest refund time
    • rpcSrc (string, optional): Source RPC endpoint
    • rpcDst (string, optional): Destination RPC endpoint
    • option (SignSwapOption): Options for signing the quote
  • Returns:
transferOut
typescript
transferOut(
    preBusiness: PreBusiness,
    network: NetworkType,
    rpc?: string,
    option: SwapTransactionOption
): Promise<ContractTransaction | ResponseTransferOut | Transaction | ResponseSolana>

Initiates a transfer out operation, supporting both EVM and Solana networks.

transferOutConfirm
typescript
transferOutConfirm(
    preBusiness: PreBusiness,
    network: NetworkType,
    rpc?: string,
    option: SwapTransactionOption
): Promise<ContractTransaction | ContractTransactionResponse | Transaction | ResponseSolana>

Confirms a transfer out operation, supporting both EVM and Solana networks.

transferInConfirm
typescript
transferInConfirm(
    preBusiness: PreBusiness,
    network: NetworkType,
    rpc?: string,
    sender: string,
    option: SwapTransactionOption
): Promise<ContractTransaction | ContractTransactionResponse | Transaction | ResponseSolana>

Confirms a transfer in operation, supporting both EVM and Solana networks.

transferOutRefund
typescript
transferOutRefund(
    preBusiness: PreBusiness,
    network: NetworkType,
    rpc?: string,
    option: SwapTransactionOption
): Promise<ContractTransaction | ContractTransactionResponse | Transaction | ResponseSolana>

Refunds a transfer out operation, supporting both EVM and Solana networks.

complain
typescript
complain(
    preBusiness: PreBusiness,
    privateKey: string,
    network: NetworkType
): Promise<string | boolean>

Submits a complaint using a private key, supporting EVM networks.

  • Parameters:
    • preBusiness (PreBusiness): Pre-business data
    • privateKey (string): The private key for signing
    • network (NetworkType): The network type
  • Returns:
    • Promise<string | boolean>: Result of the complaint submission
signComplainEIP712
typescript
signComplainEIP712(
    preBusiness: PreBusiness,
    network: NetworkType,
    option: SignComplainEIP712Option
): Promise<ComplainSignedData | ComplainSignData>

Signs a complaint using EIP-712, supporting EVM networks.

utils

Collection of utility functions for chain operations and calculations.

GetChainName
typescript
GetChainName(systemChainId: ChainId): string

Converts a system chain ID to its human-readable name.

  • Parameters:
    • systemChainId (ChainId): The system chain ID
  • Returns:
    • string: Human-readable chain name (e.g., "ETH", "Solana")
GetNativeTokenName
typescript
GetNativeTokenName(systemChainId: ChainId): string

Retrieves the native token name for a given blockchain.

  • Parameters:
    • systemChainId (ChainId): The system chain ID
  • Returns:
    • string: Native token name (e.g., "ETH", "SOL")
GetChainId
typescript
GetChainId(systemChainId: ChainId, network: NetworkType): number | undefined

Converts a system chain ID to the network-specific chain ID.

  • Parameters:
    • systemChainId (ChainId): The system chain ID
    • network (NetworkType): Network type ('mainnet' or 'testnet')
  • Returns:
    • number | undefined: Network-specific chain ID
GetNativeTokenDecimals
typescript
GetNativeTokenDecimals(systemChainId: ChainId): number

Retrieves the number of decimals for the native token of a chain.

  • Parameters:
    • systemChainId (ChainId): The system chain ID
  • Returns:
    • number: Number of decimals for the native token
GetTokenDecimals
typescript
GetTokenDecimals(systemChainId: ChainId, tokenAddress: string, network: NetworkType, rpc: string | undefined): Promise<number>

Retrieves the number of decimals for a token on any chain.

  • Parameters:
    • systemChainId (ChainId): The system chain ID
    • tokenAddress (string): The token address
    • network (NetworkType): Network type ('mainnet' or 'testnet')
    • rpc (string | undefined): The RPC endpoint, if omitted, the default will be provided
  • Returns:
    • Promise<number>: Number of decimals for the token
GetChainType
typescript
GetChainType(systemChainId: ChainId): string

Determines the type of blockchain (e.g., 'evm', 'solana') based on the system chain ID.

  • Parameters:
    • systemChainId (ChainId): The system chain ID
  • Returns:
    • string: Type of blockchain
MathReceived
typescript
MathReceived(quote: Quote, amount: string, swapToNative: number): DstAmountSet

Calculates the received token amounts and native token amounts, considering fees and percentage swapping to native token.

  • Parameters:
    • quote (Quote): The quote data
    • amount (string): Amount to be swapped
    • swapToNative (number): Percentage to swap to native token
  • Returns:
    • DstAmountSet (DstAmountSet): Object containing destination amounts
GetTokenAddress
typescript
GetTokenAddress(contractAddress: string, systemChainId: ChainId): string

Retrieves the standardized token address (Hex string) for a given chain.

  • Parameters:
    • contractAddress (string): The contract address
    • systemChainId (ChainId): The system chain ID
  • Returns:
    • string: Standardized token address (Hex string)
Sleep
typescript
Sleep(ms: number): Promise<void>

Pauses execution for a specified duration.

  • Parameters:
    • ms (number): Duration in milliseconds
  • Returns:
    • Promise<void>: Resolves after the specified duration
IsNeedApprove
typescript
IsNeedApprove(preBusiness: PreBusiness, userWallet: string, rpc?: string, network: NetworkType): Promise<boolean>

Checks if an approval is needed for a evm token transfer.

  • Parameters:
    • preBusiness (PreBusiness): Pre-business data
    • userWallet (string): The user's wallet address
    • rpc (string, optional): The RPC endpoint
    • network (NetworkType): The network type
  • Returns:
    • Promise<boolean>: True if approval is needed, false otherwise
GetApproveTransfer
typescript
GetApproveTransfer(preBusiness: PreBusiness, network: NetworkType): Promise<ContractTransaction>

Constructs a raw transaction for approving a token transfer on the evm blockchain.

GetGasPrice
typescript
GetGasPrice(provider: JsonRpcProvider, systemChainId: ChainId, network: NetworkType): Promise<GasPrice>

Retrieves the current gas price for a network used in Otmoic.

GetOnChainGasPrice
typescript
GetOnChainGasPrice(systemChainId: ChainId, network: NetworkType): Promise<bigint>

Retrieves the on-chain gas price for an evm network.

  • Parameters:
  • Returns:
    • Promise<bigint>: On-chain gas price
GetBalance
typescript
GetBalance(bridge: Bridge, address: string, network: NetworkType, rpc?: string): Promise<string>

Retrieves the balance of the src token on a bridge for a given address.

  • Parameters:
    • bridge (Bridge): The bridge configuration
    • address (string): The address to check the balance for
    • network (NetworkType): The network type
    • rpc (string, optional): The RPC endpoint
  • Returns:
    • Promise<string>: The balance of the token