Import
createBridge
Factory function to create a Bridge instance for validating transfers and accessing the API.Signature
Parameters
Configuration object for the bridge.
Returns
A Bridge instance with properties and methods for transfer validation.
Example
Bridge.validateTransfer
Validates transfer parameters and prepares aValidatedTransfer object for building transactions.
Signature
Parameters
The transfer parameters to validate.
Returns
A validated transfer object ready for building.
Validation Checks
The method performs these validations:- Amount validation: Amount must be positive, fee cannot be negative
- Address format: Sender and recipient must be valid OmniAddresses
- EVM address validation: EVM addresses must be valid hex format
- Token registration: Token must be registered on the bridge
- Decimal normalization: Amount must survive conversion between chains
- Minimum amount: Amount minus fee must be greater than zero after normalization
Errors
ThrowsValidationError with one of these codes:
Example
Bridge.getTokenDecimals
Gets decimal information for a token from the NEAR bridge contract.Signature
Parameters
The token address in OmniAddress format.
Returns
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
The source token address in OmniAddress format.
The destination chain to look up the bridged token on.
Returns
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
The UTXO chain (
ChainKind.Btc or ChainKind.Zcash).NEAR account ID to receive the bridged tokens.
Optional configuration for the deposit.
Returns
The deposit address and related information.
Example
BridgeAPI
REST API client for interacting with the Omni Bridge backend services.Constructor
The network to connect to.
Optional configuration.
Example
BridgeAPI.getTransferStatus
Gets the status of a transfer.Signature
Parameters
Lookup options. Provide either
transactionHash OR originChain + originNonce.Returns
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 address in OmniAddress format.
Recipient address in OmniAddress format.
Token address in OmniAddress format.
Transfer amount in the token’s smallest unit.
Returns
Fee quote information.
Example
BridgeAPI.getTransfer
Gets full details of a transfer.Signature
Parameters
Same asgetTransferStatus.
Returns
Array of transfer objects with full details.
Example
BridgeAPI.findTransfers
Searches for transfers by sender or transaction ID.Signature
Parameters
Search parameters. At least one of
sender or transactionId must be provided.Returns
Array of matching transfers.
Example
BridgeAPI.getAllowlistedTokens
Gets all tokens supported by the bridge.Signature
Returns
Map of token symbols to their OmniAddress.
Example
BridgeAPI.getUtxoDepositAddress
Gets a deposit address for Bitcoin or Zcash.Signature
Parameters
The UTXO chain.
NEAR recipient account ID.
Optional post-actions to execute after deposit finalization.
Optional extra message.
Returns
Example
Types
OmniAddress
Cross-chain address format with chain prefix."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.The token to transfer in OmniAddress format.
Amount in the token’s smallest unit.
Relayer fee in the transfer token.
Relayer fee in the source chain’s native token.
Sender address in OmniAddress format.
Recipient address in OmniAddress format.
Optional message or memo.
ValidatedTransfer
Result of transfer validation, ready for building transactions.The original transfer parameters.
Source chain extracted from sender address.
Destination chain extracted from recipient address.
Amount normalized for decimal differences.
Fee normalized for decimal differences.
Bridge contract address on source chain.
Token address on destination chain if different.
TokenDecimals
Token decimal information from the bridge contract.Decimals on the foreign chain.
Decimals on NEAR.
UTXO
Unspent Transaction Output for Bitcoin/Zcash operations.Transaction ID.
Output index in the transaction.
Balance in satoshis/zatoshis.
Raw transaction bytes for signing.
HD derivation path for hardware wallets.
UtxoChain
UTXO chain subset type.EvmUnsignedTransaction
Unsigned transaction for EVM chains. Compatible with both viem and ethers v6.Target contract address.
Encoded call data.
Native token value to send.
EVM chain ID.
NearUnsignedTransaction
Unsigned transaction for NEAR.Transaction type identifier.
NEAR account ID of the signer.
NEAR account ID of the receiver.
Array of actions to execute.
NearAction
A single action in a NEAR transaction.Action type.
Contract method to call.
Encoded method arguments.
Gas to attach.
NEAR tokens to deposit.
SolanaUnsignedTransaction
Unsigned transaction for Solana.Transaction type identifier.
Public key of the fee payer.
Array of instructions to execute.
SolanaInstruction
A single instruction in a Solana transaction.Program ID to invoke.
Account keys with signer and writable flags.
Instruction data.
BtcUnsignedTransaction
Unsigned transaction for Bitcoin/Zcash.Transaction type identifier.
UTXO inputs to spend.
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.address- An OmniAddress string
ChainKind enum value
Throws: ValidationError with code INVALID_ADDRESS or INVALID_CHAIN
getAddress
Extracts the raw address (without chain prefix) from an OmniAddress.address- An OmniAddress string
ValidationError with code INVALID_ADDRESS
omniAddress
Constructs an OmniAddress from chain kind and raw address.chain- TheChainKindenum valueaddress- The raw address string
OmniAddress
getChainPrefix
Returns the chain prefix for a given chain kind.chain- TheChainKindenum value
isEvmChain
Checks if a chain is an EVM-compatible chain.chain- TheChainKindenum value
true if the chain is EVM-compatible (Eth, Base, Arb, Bnb, Pol)
normalizeAmount
Normalizes an amount from one decimal precision to another.amount- The amount to normalize as a bigintfromDecimals- The source decimal precisiontoDecimals- The target decimal precision
validateTransferAmount
Validates that a transfer amount will survive decimal normalization. Throws if invalid.amount- The amount to transferfee- The fee to be deductedoriginDecimals- Decimals on the source chaindestinationDecimals- Decimals on the destination chain
ValidationErrorwith codeINVALID_AMOUNTif amount is less than or equal to feeValidationErrorwith codeAMOUNT_TOO_SMALLif normalized amount would be zero
verifyTransferAmount
Checks if a transfer amount will be valid after normalization. Returns boolean instead of throwing.amount- The amount to transferfee- The fee to be deductedoriginDecimals- Decimals on the source chaindestinationDecimals- Decimals on the destination chain
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.originDecimals- Decimals on the source chaindestinationDecimals- Decimals on the destination chain
getAddresses
Gets contract addresses for a network.network- The network ("mainnet"or"testnet")
ChainAddresses object with all chain configurations
getWormholeVaa
Fetches a Wormhole VAA for a Solana transaction. Waits up to 2 minutes for guardians to sign.txSignature- Solana transaction signaturenetwork- Wormhole network ("Mainnet","Testnet", or"Devnet")
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.Error code identifying the type of error.
Optional additional details about the error.
ValidationError
Thrown when transfer validation fails.ValidationErrorCode):
RpcError
Thrown when RPC calls fail.Number of retries attempted before failing.