bridge/classes/BridgeService.md
Bridge Service - Main entry point for cross-chain operations.
Supports bridging between:
- GalaChain ↔ Ethereum (6 tokens: GALA, GWETH, GUSDC, GUSDT, GWTRX, GWBTC)
- GalaChain ↔ Solana (2 tokens: GALA, GSOL)
Example
const bridgeService = new BridgeService({
galaChainWalletAddress: 'eth|1234...',
ethereumPrivateKey: '0xabcd...',
solanaPrivateKey: 'base58EncodedKey...',
bridgeableTokenService,
});
const fee = await bridgeService.estimateBridgeFee({
tokenId: 'GALA|Unit|none|none',
destinationChain: 'Ethereum',
});
Constructors
Constructor
new BridgeService(
config):BridgeService
Parameters
| Parameter | Type | Description |
|---|---|---|
config | BridgeServiceConfig | Bridge service configuration |
Returns
BridgeService
Throws
GalaSDKError INVALID_BRIDGE_OPTION (bridgeableTokenService) without a token lookup;
INVALID_WALLET_ADDRESS (galaChainWalletAddress) for a wallet address that is not a
GalaChain one; the strategies' refusals of a bad key
bridge service config invalid option bridgeable token wallet address gala chain
Methods
bridgeIn()
bridgeIn(
params):Promise<BridgeTransaction>
Bridge tokens in from an external chain to GalaChain.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | BridgeInParams | Bridge in parameters |
Returns
Promise<BridgeTransaction>
Transaction details
Throws
GalaSDKError UNSUPPORTED_BRIDGE_TOKEN for a token the chain's strategy does not
bridge; the strategy's failures
bridge in transaction params unsupported token
bridgeOut()
bridgeOut(
params):Promise<BridgeTransaction>
Bridge tokens out from GalaChain to an external chain.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | BridgeOutParams | Bridge out parameters |
Returns
Promise<BridgeTransaction>
Transaction details
Throws
GalaSDKError INVALID_WALLET_ADDRESS (recipientAddress) for a recipient that is not
an address of the destination chain; UNSUPPORTED_BRIDGE_TOKEN for a token the chain's
strategy does not bridge; the strategy's failures
bridge out transaction params invalid wallet address recipient unsupported token
estimateBridgeFee()
estimateBridgeFee(
params):Promise<BridgeFeeEstimate>
Estimate the fee of a bridge-out (a per-transfer cost: it does not depend on the amount).
Parameters
| Parameter | Type | Description |
|---|---|---|
params | EstimateBridgeFeeParams | Token and destination chain |
Returns
Promise<BridgeFeeEstimate>
Fee estimate
estimate bridge fee params
fetchEthereumWalletAllBalances()
fetchEthereumWalletAllBalances(
address?):Promise<EthereumWalletBalanceResult>
Every bridge-token balance and the ETH balance of the Ethereum wallet or address.
Parameters
| Parameter | Type |
|---|---|
address? | string |
Returns
Promise<EthereumWalletBalanceResult>
fetch ethereum wallet all balances balance result
fetchEthereumWalletNativeBalance()
fetchEthereumWalletNativeBalance(
address?):Promise<ExternalChainBalance>
The ETH balance of the Ethereum wallet or address.
Parameters
| Parameter | Type |
|---|---|
address? | string |
Returns
Promise<ExternalChainBalance>
fetch ethereum wallet native balance external chain
fetchEthereumWalletTokenBalance()
fetchEthereumWalletTokenBalance(
symbol,address?):Promise<ExternalChainBalance>
One ERC-20 balance of the Ethereum wallet or address, with its token's details.
Parameters
| Parameter | Type |
|---|---|
symbol | string |
address? | string |
Returns
Promise<ExternalChainBalance>
fetch ethereum wallet token balance external chain
fetchSolanaWalletAllBalances()
fetchSolanaWalletAllBalances(
address?):Promise<SolanaWalletBalanceResult>
Every bridge-token balance and the SOL balance of the Solana wallet or address.
Parameters
| Parameter | Type |
|---|---|
address? | string |
Returns
Promise<SolanaWalletBalanceResult>
fetch solana wallet all balances balance result
fetchSolanaWalletNativeBalance()
fetchSolanaWalletNativeBalance(
address?):Promise<ExternalChainBalance>
The SOL balance of the Solana wallet or address.
Parameters
| Parameter | Type |
|---|---|
address? | string |
Returns
Promise<ExternalChainBalance>
fetch solana wallet native balance external chain
fetchSolanaWalletTokenBalance()
fetchSolanaWalletTokenBalance(
symbol,address?):Promise<ExternalChainBalance>
One SPL balance of the Solana wallet or address, with its token's details.
Parameters
| Parameter | Type |
|---|---|
symbol | string |
address? | string |
Returns
Promise<ExternalChainBalance>
fetch solana wallet token balance external chain
getBridgeStatus()
getBridgeStatus(
transactionHash):Promise<BridgeStatus>
Get the status of a bridge transaction (GalaConnect tracks both chains: one read).
Parameters
| Parameter | Type | Description |
|---|---|---|
transactionHash | string | Transaction hash |
Returns
Promise<BridgeStatus>
Current status
get bridge status transaction hash
getEthereumNativeBalance()
getEthereumNativeBalance(
address?):Promise<string>
The ETH balance (decimal string) of the Ethereum wallet or address.
Parameters
| Parameter | Type |
|---|---|
address? | string |
Returns
Promise<string>
get ethereum native balance
getEthereumTokenBalance()
getEthereumTokenBalance(
tokenSymbol,address?):Promise<string>
An ERC-20 balance (decimal string) of the Ethereum wallet or address.
Parameters
| Parameter | Type |
|---|---|
tokenSymbol | string |
address? | string |
Returns
Promise<string>
get ethereum token balance symbol
getEthereumTransactionStatus()
getEthereumTransactionStatus(
transactionHash):Promise<EthereumTransactionStatus>
The status of an Ethereum transaction, from the Ethereum RPC.
Parameters
| Parameter | Type |
|---|---|
transactionHash | string |
Returns
Promise<EthereumTransactionStatus>
get ethereum transaction status hash
getSolanaNativeBalance()
getSolanaNativeBalance(
address?):Promise<string>
The SOL balance (decimal string) of the Solana wallet or address.
Parameters
| Parameter | Type |
|---|---|
address? | string |
Returns
Promise<string>
get solana native balance
getSolanaTokenBalance()
getSolanaTokenBalance(
tokenSymbol,address?):Promise<string>
An SPL balance (decimal string) of the Solana wallet or address.
Parameters
| Parameter | Type |
|---|---|
tokenSymbol | string |
address? | string |
Returns
Promise<string>
get solana token balance symbol
getSolanaTransactionStatus()
getSolanaTransactionStatus(
signature):Promise<SolanaTransactionStatus>
The status of a Solana transaction, from the Solana RPC.
Parameters
| Parameter | Type |
|---|---|
signature | string |
Returns
Promise<SolanaTransactionStatus>
get solana transaction status
getSupportedBridgeChains()
getSupportedBridgeChains():
ExternalNetwork[]
Get the chains this service can bridge with (Solana only with a Solana key).
Returns
get supported bridge chains external network
getSupportedBridgeTokens()
getSupportedBridgeTokens(
chain?):BridgeToken[]
Get the bridge tokens (for one chain, or all).
Parameters
| Parameter | Type | Description |
|---|---|---|
chain? | ExternalNetwork | Optional chain filter |
Returns
Supported tokens with their chains and addresses
get supported bridge tokens token external network
isTokenSupported()
isTokenSupported(
tokenSymbol,chain?):boolean
Whether a token symbol is bridgeable (with chain, or with any configured chain).
Parameters
| Parameter | Type |
|---|---|
tokenSymbol | string |
chain? | ExternalNetwork |
Returns
boolean
is token supported symbol external network
isValidAddress()
isValidAddress(
address,chain):boolean
Whether an address is valid for a chain (false for a chain that is not configured).
Parameters
| Parameter | Type |
|---|---|
address | string |
chain | ExternalNetwork |
Returns
boolean
is valid address external network
requestSolanaDevnetAirdrop()
requestSolanaDevnetAirdrop(
amount?,address?):Promise<string>
Request a devnet SOL airdrop (devnet only).
Parameters
| Parameter | Type |
|---|---|
amount? | number |
address? | string |
Returns
Promise<string>
request solana devnet airdrop
waitForBridgeCompletion()
waitForBridgeCompletion(
transactionHash,options?):Promise<BridgeStatus>
Wait for a bridge transaction to reach a final status (completed, failed, delivery failed).
Parameters
| Parameter | Type | Description |
|---|---|---|
transactionHash | string | Transaction hash |
options? | WaitForBridgeOptions | Polling options (defaults: the service's pollInterval and pollTimeout) |
Returns
Promise<BridgeStatus>
Final status
Throws
GalaSDKError BRIDGE_STATUS_TIMEOUT when the timeout comes first
wait for bridge completion transaction hash status options timeout