Skip to main content

Import


createBridge

Factory function to create a Bridge instance for validating transfers and accessing the API.

Signature

Parameters

config
BridgeConfig
required
Configuration object for the bridge.

Returns

Bridge
Bridge
A Bridge instance with properties and methods for transfer validation.

Example


Bridge.validateTransfer

Validates transfer parameters and prepares a ValidatedTransfer object for building transactions.

Signature

Parameters

params
TransferParams
required
The transfer parameters to validate.

Returns

ValidatedTransfer
ValidatedTransfer
A validated transfer object ready for building.

Validation Checks

The method performs these validations:
  1. Amount validation: Amount must be positive, fee cannot be negative
  2. Address format: Sender and recipient must be valid OmniAddresses
  3. EVM address validation: EVM addresses must be valid hex format
  4. Token registration: Token must be registered on the bridge
  5. Decimal normalization: Amount must survive conversion between chains
  6. Minimum amount: Amount minus fee must be greater than zero after normalization

Errors

Throws ValidationError with one of these codes:

Example


Bridge.getTokenDecimals

Gets decimal information for a token from the NEAR bridge contract.

Signature

Parameters

token
OmniAddress
required
The token address in OmniAddress format.

Returns

TokenDecimals | null
TokenDecimals | null
Token decimal information, or null if the token is not registered.

Example


Bridge.getBridgedToken

Gets the bridged token address on a destination chain.

Signature

Parameters

token
OmniAddress
required
The source token address in OmniAddress format.
destChain
ChainKind
required
The destination chain to look up the bridged token on.

Returns

OmniAddress | null
OmniAddress | null
The bridged token address on the destination chain, or null if not found.

Example


Bridge.getUtxoDepositAddress

Gets a deposit address for Bitcoin or Zcash. Funds sent to this address will be bridged to NEAR.

Signature

Parameters

chain
UtxoChain
required
The UTXO chain (ChainKind.Btc or ChainKind.Zcash).
recipient
string
required
NEAR account ID to receive the bridged tokens.
options
UtxoDepositOptions
Optional configuration for the deposit.

Returns

UtxoDepositResult
UtxoDepositResult
The deposit address and related information.

Example


BridgeAPI

REST API client for interacting with the Omni Bridge backend services.

Constructor

network
'mainnet' | 'testnet'
required
The network to connect to.
config
BridgeAPIConfig
Optional configuration.

Example


BridgeAPI.getTransferStatus

Gets the status of a transfer.

Signature

Parameters

options
object
required
Lookup options. Provide either transactionHash OR originChain + originNonce.

Returns

TransferStatus[]
TransferStatus[]
Array of status values representing the transfer’s progression.Possible values:
  • "Initialized" - Transfer initiated on source chain
  • "Signed" - MPC signature obtained
  • "FastFinalisedOnNear" - Fast finalized on NEAR
  • "FinalisedOnNear" - Finalized on NEAR
  • "FastFinalised" - Fast finalized on destination
  • "Finalised" - Fully finalized
  • "Claimed" - Tokens claimed

Example


BridgeAPI.getFee

Gets a fee quote for a transfer.

Signature

Parameters

sender
OmniAddress
required
Sender address in OmniAddress format.
recipient
OmniAddress
required
Recipient address in OmniAddress format.
tokenAddress
OmniAddress
required
Token address in OmniAddress format.
amount
string | bigint
required
Transfer amount in the token’s smallest unit.

Returns

ApiFeeResponse
ApiFeeResponse
Fee quote information.

Example


BridgeAPI.getTransfer

Gets full details of a transfer.

Signature

Parameters

Same as getTransferStatus.

Returns

Transfer[]
Transfer[]
Array of transfer objects with full details.

Example


BridgeAPI.findTransfers

Searches for transfers by sender or transaction ID.

Signature

Parameters

params
object
required
Search parameters. At least one of sender or transactionId must be provided.

Returns

Transfer[]
Transfer[]
Array of matching transfers.

Example


BridgeAPI.getAllowlistedTokens

Gets all tokens supported by the bridge.

Signature

Returns

Record<string, OmniAddress>
Record<string, OmniAddress>
Map of token symbols to their OmniAddress.

Example


BridgeAPI.getUtxoDepositAddress

Gets a deposit address for Bitcoin or Zcash.

Signature

Parameters

chain
'btc' | 'zcash'
required
The UTXO chain.
recipient
string
required
NEAR recipient account ID.
postActions
PostAction[] | null
Optional post-actions to execute after deposit finalization.
extraMsg
string | null
Optional extra message.

Returns

UtxoDepositAddressResponse
UtxoDepositAddressResponse

Example


Types

OmniAddress

Cross-chain address format with chain prefix.
Examples:
  • "eth:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" - USDC on Ethereum
  • "near:alice.near" - NEAR account
  • "sol:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" - Token on Solana
  • "btc:bc1q..." - Bitcoin address

ChainKind

Enum representing supported chains, matching on-chain values.

ChainPrefix

Chain prefix strings used in OmniAddress format.

Network

Network type for mainnet or testnet.

Chain

API chain name strings.

TransferParams

Parameters for initiating a transfer.
token
OmniAddress
The token to transfer in OmniAddress format.
amount
bigint
Amount in the token’s smallest unit.
fee
bigint
Relayer fee in the transfer token.
nativeFee
bigint
Relayer fee in the source chain’s native token.
sender
OmniAddress
Sender address in OmniAddress format.
recipient
OmniAddress
Recipient address in OmniAddress format.
message
string
Optional message or memo.

ValidatedTransfer

Result of transfer validation, ready for building transactions.
params
TransferParams
The original transfer parameters.
sourceChain
ChainKind
Source chain extracted from sender address.
destChain
ChainKind
Destination chain extracted from recipient address.
normalizedAmount
bigint
Amount normalized for decimal differences.
normalizedFee
bigint
Fee normalized for decimal differences.
contractAddress
string
Bridge contract address on source chain.
bridgedToken
OmniAddress | undefined
Token address on destination chain if different.

TokenDecimals

Token decimal information from the bridge contract.
decimals
number
Decimals on the foreign chain.
origin_decimals
number
Decimals on NEAR.

UTXO

Unspent Transaction Output for Bitcoin/Zcash operations.
txid
string
Transaction ID.
vout
number
Output index in the transaction.
balance
bigint | number | string
Balance in satoshis/zatoshis.
tx_bytes
Uint8Array | number[] | undefined
Raw transaction bytes for signing.
path
string | undefined
HD derivation path for hardware wallets.

UtxoChain

UTXO chain subset type.

EvmUnsignedTransaction

Unsigned transaction for EVM chains. Compatible with both viem and ethers v6.
to
`0x${string}`
Target contract address.
data
`0x${string}`
Encoded call data.
value
bigint
Native token value to send.
chainId
number
EVM chain ID.

NearUnsignedTransaction

Unsigned transaction for NEAR.
type
"near"
Transaction type identifier.
signerId
string
NEAR account ID of the signer.
receiverId
string
NEAR account ID of the receiver.
actions
NearAction[]
Array of actions to execute.

NearAction

A single action in a NEAR transaction.
type
"FunctionCall"
Action type.
methodName
string
Contract method to call.
args
Uint8Array
Encoded method arguments.
gas
bigint
Gas to attach.
deposit
bigint
NEAR tokens to deposit.

SolanaUnsignedTransaction

Unsigned transaction for Solana.
type
"solana"
Transaction type identifier.
feePayer
string
Public key of the fee payer.
instructions
SolanaInstruction[]
Array of instructions to execute.

SolanaInstruction

A single instruction in a Solana transaction.
programId
string
Program ID to invoke.
keys
Array
Account keys with signer and writable flags.
data
Uint8Array
Instruction data.

BtcUnsignedTransaction

Unsigned transaction for Bitcoin/Zcash.
type
"btc"
Transaction type identifier.
inputs
Array
UTXO inputs to spend.
outputs
Array
Outputs to create.

Common Type Aliases


ChainAddresses

Contract addresses for all chains.

EvmAddresses

EVM chain contract addresses.

NearAddresses

NEAR chain configuration.

SolanaAddresses

Solana chain configuration.

BtcAddresses

Bitcoin chain configuration.

ZcashAddresses

Zcash chain configuration.

WormholeNetwork

Wormhole network type.

EvmChainKind

Type representing EVM-compatible chains.

Utility Functions

getChain

Extracts the chain from an OmniAddress.
Parameters:
  • address - An OmniAddress string
Returns: The ChainKind enum value Throws: ValidationError with code INVALID_ADDRESS or INVALID_CHAIN

getAddress

Extracts the raw address (without chain prefix) from an OmniAddress.
Parameters:
  • address - An OmniAddress string
Returns: The raw address without the chain prefix Throws: ValidationError with code INVALID_ADDRESS

omniAddress

Constructs an OmniAddress from chain kind and raw address.
Parameters:
  • chain - The ChainKind enum value
  • address - The raw address string
Returns: A properly formatted OmniAddress

getChainPrefix

Returns the chain prefix for a given chain kind.
Parameters:
  • chain - The ChainKind enum value
Returns: The chain prefix string

isEvmChain

Checks if a chain is an EVM-compatible chain.
Parameters:
  • chain - The ChainKind enum value
Returns: true if the chain is EVM-compatible (Eth, Base, Arb, Bnb, Pol)

normalizeAmount

Normalizes an amount from one decimal precision to another.
Parameters:
  • amount - The amount to normalize as a bigint
  • fromDecimals - The source decimal precision
  • toDecimals - The target decimal precision
Returns: The normalized amount as a bigint

validateTransferAmount

Validates that a transfer amount will survive decimal normalization. Throws if invalid.
Parameters:
  • amount - The amount to transfer
  • fee - The fee to be deducted
  • originDecimals - Decimals on the source chain
  • destinationDecimals - Decimals on the destination chain
Throws:
  • ValidationError with code INVALID_AMOUNT if amount is less than or equal to fee
  • ValidationError with code AMOUNT_TOO_SMALL if normalized amount would be zero

verifyTransferAmount

Checks if a transfer amount will be valid after normalization. Returns boolean instead of throwing.
Parameters:
  • amount - The amount to transfer
  • fee - The fee to be deducted
  • originDecimals - Decimals on the source chain
  • destinationDecimals - Decimals on the destination chain
Returns: true if the normalized amount (minus fee) will be greater than 0

getMinimumTransferableAmount

Gets the minimum transferable amount for a token pair accounting for decimal normalization.
Parameters:
  • originDecimals - Decimals on the source chain
  • destinationDecimals - Decimals on the destination chain
Returns: The minimum transferable amount as a bigint

getAddresses

Gets contract addresses for a network.
Parameters:
  • network - The network ("mainnet" or "testnet")
Returns: ChainAddresses object with all chain configurations

getWormholeVaa

Fetches a Wormhole VAA for a Solana transaction. Waits up to 2 minutes for guardians to sign.
Parameters:
  • txSignature - Solana transaction signature
  • network - Wormhole network ("Mainnet", "Testnet", or "Devnet")
Returns: Hex-encoded VAA string Throws: Error if no VAA is found within the timeout

Configuration Constants

EVM_CHAIN_IDS

EVM chain IDs per network.

API_BASE_URLS

API base URLs per network.

Error Types

OmniBridgeError

Base error class for all SDK errors.
code
string
Error code identifying the type of error.
details
Record<string, unknown>
Optional additional details about the error.

ValidationError

Thrown when transfer validation fails.
Error Codes (ValidationErrorCode):

RpcError

Thrown when RPC calls fail.
retryCount
number
Number of retries attempted before failing.

ProofError

Thrown when proof generation or verification fails.
Error Codes:

Error Handling

Basic error handling

Handling specific validation codes

RPC error retry pattern

Proof error handling