Import
createBridge
Factory function to create a Bridge instance for validating transfers and accessing the API.Signature
Parameters
BridgeConfig
required
Configuration object for the bridge.
Returns
Bridge
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
TransferParams
required
The transfer parameters to validate.
Returns
ValidatedTransfer
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
OmniAddress
required
The token address in OmniAddress format.
Returns
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
OmniAddress
required
The source token address in OmniAddress format.
ChainKind
required
The destination chain to look up the bridged token on.
Returns
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
UtxoChain
required
The UTXO chain (
ChainKind.Btc or ChainKind.Zcash).string
required
NEAR account ID to receive the bridged tokens.
UtxoDepositOptions
Optional configuration for the deposit.
Returns
UtxoDepositResult
The deposit address and related information.
Example
BridgeAPI
REST API client for interacting with the Omni Bridge backend services.Constructor
'mainnet' | 'testnet'
required
The network to connect to.
BridgeAPIConfig
Optional configuration.
Example
BridgeAPI.getTransferStatus
Gets the status of a transfer.Signature
Parameters
object
required
Lookup options. Provide either
transactionHash OR originChain + originNonce.Returns
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
OmniAddress
required
Sender address in OmniAddress format.
OmniAddress
required
Recipient address in OmniAddress format.
OmniAddress
required
Token address in OmniAddress format.
string | bigint
required
Transfer amount in the token’s smallest unit.
Returns
ApiFeeResponse
Fee quote information.
Example
BridgeAPI.getTransfer
Gets full details of a transfer.Signature
Parameters
Same asgetTransferStatus.
Returns
Transfer[]
Array of transfer objects with full details.
Example
BridgeAPI.findTransfers
Searches for transfers by sender or transaction ID.Signature
Parameters
object
required
Search parameters. At least one of
sender or transactionId must be provided.Returns
Transfer[]
Array of matching transfers.
Example
BridgeAPI.getAllowlistedTokens
Gets all tokens supported by the bridge.Signature
Returns
Record<string, OmniAddress>
Map of token symbols to their OmniAddress.
Example
BridgeAPI.getUtxoDepositAddress
Gets a deposit address for Bitcoin or Zcash.Signature
Parameters
'btc' | 'zcash'
required
The UTXO chain.
string
required
NEAR recipient account ID.
PostAction[] | null
Optional post-actions to execute after deposit finalization.
string | null
Optional extra message.
Returns
UtxoDepositAddressResponse
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.OmniAddress
The token to transfer in OmniAddress format.
bigint
Amount in the token’s smallest unit.
bigint
Relayer fee in the transfer token.
bigint
Relayer fee in the source chain’s native token.
OmniAddress
Sender address in OmniAddress format.
OmniAddress
Recipient address in OmniAddress format.
string
Optional message or memo.
ValidatedTransfer
Result of transfer validation, ready for building transactions.TransferParams
The original transfer parameters.
ChainKind
Source chain extracted from sender address.
ChainKind
Destination chain extracted from recipient address.
bigint
Amount normalized for decimal differences.
bigint
Fee normalized for decimal differences.
string
Bridge contract address on source chain.
OmniAddress | undefined
Token address on destination chain if different.
TokenDecimals
Token decimal information from the bridge contract.number
Decimals on the foreign chain.
number
Decimals on NEAR.
UTXO
Unspent Transaction Output for Bitcoin/Zcash operations.string
Transaction ID.
number
Output index in the transaction.
bigint | number | string
Balance in satoshis/zatoshis.
Uint8Array | number[] | undefined
Raw transaction bytes for signing.
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.`0x${string}`
Target contract address.
`0x${string}`
Encoded call data.
bigint
Native token value to send.
number
EVM chain ID.
NearUnsignedTransaction
Unsigned transaction for NEAR."near"
Transaction type identifier.
string
NEAR account ID of the signer.
string
NEAR account ID of the receiver.
NearAction[]
Array of actions to execute.
NearAction
A single action in a NEAR transaction."FunctionCall"
Action type.
string
Contract method to call.
Uint8Array
Encoded method arguments.
bigint
Gas to attach.
bigint
NEAR tokens to deposit.
SolanaUnsignedTransaction
Unsigned transaction for Solana."solana"
Transaction type identifier.
string
Public key of the fee payer.
SolanaInstruction[]
Array of instructions to execute.
SolanaInstruction
A single instruction in a Solana transaction.string
Program ID to invoke.
Array
Account keys with signer and writable flags.
Uint8Array
Instruction data.
BtcUnsignedTransaction
Unsigned transaction for Bitcoin/Zcash."btc"
Transaction type identifier.
Array
UTXO inputs to spend.
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.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.string
Error code identifying the type of error.
Record<string, unknown>
Optional additional details about the error.
ValidationError
Thrown when transfer validation fails.ValidationErrorCode):
RpcError
Thrown when RPC calls fail.number
Number of retries attempted before failing.