Skip to main content

bridge/interfaces/BridgeStrategy.md

Strategy interface for chain-specific bridge operations.

The Bridge SDK uses the Strategy pattern to abstract chain-specific logic:

  • EthereumBridgeStrategy: Handles ERC-20 approvals, ethers.js signing
  • SolanaBridgeStrategy: Handles SPL token accounts, @solana/web3.js signing

Each strategy encapsulates:

  • Fee estimation for the target chain
  • Outbound transfers (GalaChain → External)
  • Inbound transfers (External → GalaChain)
  • Status polling and transaction tracking

Properties​

PropertyModifierTypeDescription
networkreadonlyExternalNetworkThe external network this strategy handles.

Methods​

bridgeIn()​

bridgeIn(params): Promise<BridgeTransaction>

Bridge tokens IN from external chain to GalaChain.

Flow:

  1. Approve bridge contract (if needed)
  2. Deposit tokens to bridge contract
  3. Register the deposit with GalaConnect
  4. Receive native tokens on GalaChain

Parameters​

ParameterTypeDescription
paramsBridgeInParamsBridge in parameters

Returns​

Promise<BridgeTransaction>

Transaction details with tracking info


bridgeOut()​

bridgeOut(params): Promise<BridgeTransaction>

Bridge tokens OUT from GalaChain to external chain.

Flow:

  1. Lock tokens on GalaChain (via GalaConnect)
  2. Wait for bridge confirmation
  3. Receive wrapped tokens on external chain

Parameters​

ParameterTypeDescription
paramsBridgeOutParamsBridge out parameters

Returns​

Promise<BridgeTransaction>

Transaction details with tracking info


estimateFee()​

estimateFee(tokenSymbol): Promise<BridgeFeeEstimate>

Estimate bridge fees for a transfer (a per-transfer cost: it does not depend on the amount).

Parameters​

ParameterTypeDescription
tokenSymbolstringToken symbol (e.g., 'GALA', 'GUSDC')

Returns​

Promise<BridgeFeeEstimate>

Fee estimate with breakdown


getStatus()​

getStatus(transactionHash): Promise<BridgeStatus>

Get the current status of a bridge transaction.

Parameters​

ParameterTypeDescription
transactionHashstringThe bridge transaction hash

Returns​

Promise<BridgeStatus>

Current status with details


getSupportedTokens()​

getSupportedTokens(): string[]

Get the list of supported tokens for this chain.

Returns​

string[]

Array of token symbols supported by this bridge


isTokenSupported()​

isTokenSupported(tokenSymbol): boolean

Check if a specific token is supported for bridging.

Parameters​

ParameterTypeDescription
tokenSymbolstringToken symbol to check

Returns​

boolean

True if token can be bridged


isValidAddress()​

isValidAddress(address): boolean

Validate a recipient address for the external chain.

Parameters​

ParameterTypeDescription
addressstringAddress to validate

Returns​

boolean

True if address is valid for this chain


waitForCompletion()​

waitForCompletion(transactionHash, options?): Promise<BridgeStatus>

Wait for a bridge transaction to complete.

Polls the transaction status until it reaches a terminal state (completed or failed) or the timeout is reached.

Parameters​

ParameterTypeDescription
transactionHashstringThe bridge transaction hash
options?WaitOptionsPolling options

Returns​

Promise<BridgeStatus>

Final status when complete

Throws​

GalaSDKError BRIDGE_STATUS_TIMEOUT if the timeout is reached first; INVALID_BRIDGE_OPTION for a poll interval or timeout that is not a finite number, 0 or more