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
| Property | Modifier | Type | Description |
|---|---|---|---|
network | readonly | ExternalNetwork | The external network this strategy handles. |
external network
Methods
bridgeIn()
bridgeIn(
params):Promise<BridgeTransaction>
Bridge tokens IN from external chain to GalaChain.
Flow:
- Approve bridge contract (if needed)
- Deposit tokens to bridge contract
- Register the deposit with GalaConnect
- Receive native tokens on GalaChain
Parameters
| Parameter | Type | Description |
|---|---|---|
params | BridgeInParams | Bridge in parameters |
Returns
Promise<BridgeTransaction>
Transaction details with tracking info
bridge in transaction params
bridgeOut()
bridgeOut(
params):Promise<BridgeTransaction>
Bridge tokens OUT from GalaChain to external chain.
Flow:
- Lock tokens on GalaChain (via GalaConnect)
- Wait for bridge confirmation
- Receive wrapped tokens on external chain
Parameters
| Parameter | Type | Description |
|---|---|---|
params | BridgeOutParams | Bridge out parameters |
Returns
Promise<BridgeTransaction>
Transaction details with tracking info
bridge out transaction params
estimateFee()
estimateFee(
tokenSymbol):Promise<BridgeFeeEstimate>
Estimate bridge fees for a transfer (a per-transfer cost: it does not depend on the amount).
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenSymbol | string | Token symbol (e.g., 'GALA', 'GUSDC') |
Returns
Promise<BridgeFeeEstimate>
Fee estimate with breakdown
estimate fee token symbol bridge
getStatus()
getStatus(
transactionHash):Promise<BridgeStatus>
Get the current status of a bridge transaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
transactionHash | string | The bridge transaction hash |
Returns
Promise<BridgeStatus>
Current status with details
get status transaction hash bridge
getSupportedTokens()
getSupportedTokens():
string[]
Get the list of supported tokens for this chain.
Returns
string[]
Array of token symbols supported by this bridge
get supported tokens
isTokenSupported()
isTokenSupported(
tokenSymbol):boolean
Check if a specific token is supported for bridging.
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenSymbol | string | Token symbol to check |
Returns
boolean
True if token can be bridged
is token supported symbol
isValidAddress()
isValidAddress(
address):boolean
Validate a recipient address for the external chain.
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | Address to validate |
Returns
boolean
True if address is valid for this chain
is valid address
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
| Parameter | Type | Description |
|---|---|---|
transactionHash | string | The bridge transaction hash |
options? | WaitOptions | Polling 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
wait for completion transaction hash bridge status options timeout invalid option