Skip to main content

Class: BridgeService

GalaChain core SDK 1.0.0-rc.8


GalaChain core SDK 1.0.0-rc.8 / bridge / BridgeService

Class: BridgeService

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1855

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

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1868

Parameters​

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

Methods​

bridgeIn()​

bridgeIn(params): Promise<BridgeTransaction>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1902

Bridge tokens in from an external chain to GalaChain.

Parameters​

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


bridgeOut()​

bridgeOut(params): Promise<BridgeTransaction>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1893

Bridge tokens out from GalaChain to an external chain.

Parameters​

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


estimateBridgeFee()​

estimateBridgeFee(params): Promise<BridgeFeeEstimate>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1883

Estimate the fee of a bridge-out (a per-transfer cost: it does not depend on the amount).

Parameters​

params​

EstimateBridgeFeeParams

Token and destination chain

Returns​

Promise<BridgeFeeEstimate>

Fee estimate


fetchEthereumWalletAllBalances()​

fetchEthereumWalletAllBalances(address?): Promise<EthereumWalletBalanceResult>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1961

Every bridge-token balance and the ETH balance of the Ethereum wallet or address.

Parameters​

address?​

string

Returns​

Promise<EthereumWalletBalanceResult>


fetchEthereumWalletNativeBalance()​

fetchEthereumWalletNativeBalance(address?): Promise<ExternalChainBalance>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1949

The ETH balance of the Ethereum wallet or address.

Parameters​

address?​

string

Returns​

Promise<ExternalChainBalance>


fetchEthereumWalletTokenBalance()​

fetchEthereumWalletTokenBalance(symbol, address?): Promise<ExternalChainBalance>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1947

One ERC-20 balance of the Ethereum wallet or address, with its token's details.

Parameters​

symbol​

string

address?​

string

Returns​

Promise<ExternalChainBalance>


fetchSolanaWalletAllBalances()​

fetchSolanaWalletAllBalances(address?): Promise<SolanaWalletBalanceResult>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1963

Every bridge-token balance and the SOL balance of the Solana wallet or address.

Parameters​

address?​

string

Returns​

Promise<SolanaWalletBalanceResult>


fetchSolanaWalletNativeBalance()​

fetchSolanaWalletNativeBalance(address?): Promise<ExternalChainBalance>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1953

The SOL balance of the Solana wallet or address.

Parameters​

address?​

string

Returns​

Promise<ExternalChainBalance>


fetchSolanaWalletTokenBalance()​

fetchSolanaWalletTokenBalance(symbol, address?): Promise<ExternalChainBalance>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1951

One SPL balance of the Solana wallet or address, with its token's details.

Parameters​

symbol​

string

address?​

string

Returns​

Promise<ExternalChainBalance>


getBridgeStatus()​

getBridgeStatus(transactionHash): Promise<BridgeStatus>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1909

Get the status of a bridge transaction (GalaConnect tracks both chains: one read).

Parameters​

transactionHash​

string

Transaction hash

Returns​

Promise<BridgeStatus>

Current status


getEthereumNativeBalance()​

getEthereumNativeBalance(address?): Promise<string>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1941

The ETH balance (decimal string) of the Ethereum wallet or address.

Parameters​

address?​

string

Returns​

Promise<string>


getEthereumTokenBalance()​

getEthereumTokenBalance(tokenSymbol, address?): Promise<string>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1939

An ERC-20 balance (decimal string) of the Ethereum wallet or address.

Parameters​

tokenSymbol​

string

address?​

string

Returns​

Promise<string>


getEthereumTransactionStatus()​

getEthereumTransactionStatus(transactionHash): Promise<EthereumTransactionStatus>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1959

The status of an Ethereum transaction, from the Ethereum RPC.

Parameters​

transactionHash​

string

Returns​

Promise<EthereumTransactionStatus>


getSolanaNativeBalance()​

getSolanaNativeBalance(address?): Promise<string>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1945

The SOL balance (decimal string) of the Solana wallet or address.

Parameters​

address?​

string

Returns​

Promise<string>


getSolanaTokenBalance()​

getSolanaTokenBalance(tokenSymbol, address?): Promise<string>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1943

An SPL balance (decimal string) of the Solana wallet or address.

Parameters​

tokenSymbol​

string

address?​

string

Returns​

Promise<string>


getSolanaTransactionStatus()​

getSolanaTransactionStatus(signature): Promise<SolanaTransactionStatus>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1957

The status of a Solana transaction, from the Solana RPC.

Parameters​

signature​

string

Returns​

Promise<SolanaTransactionStatus>


getSupportedBridgeChains()​

getSupportedBridgeChains(): ExternalNetwork[]

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1929

Get the chains this service can bridge with (Solana only with a Solana key).

Returns​

ExternalNetwork[]


getSupportedBridgeTokens()​

getSupportedBridgeTokens(chain?): BridgeToken[]

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1925

Get the bridge tokens (for one chain, or all).

Parameters​

chain?​

ExternalNetwork

Optional chain filter

Returns​

BridgeToken[]

Supported tokens with their chains and addresses


isTokenSupported()​

isTokenSupported(tokenSymbol, chain?): boolean

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1933

Whether a token symbol is bridgeable (with chain, or with any configured chain).

Parameters​

tokenSymbol​

string

chain?​

ExternalNetwork

Returns​

boolean


isValidAddress()​

isValidAddress(address, chain): boolean

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1937

Whether an address is valid for a chain (false for a chain that is not configured).

Parameters​

address​

string

chain​

ExternalNetwork

Returns​

boolean


requestSolanaDevnetAirdrop()​

requestSolanaDevnetAirdrop(amount?, address?): Promise<string>

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1955

Request a devnet SOL airdrop (devnet only).

Parameters​

amount?​

number

address?​

string

Returns​

Promise<string>


waitForBridgeCompletion()​

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

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:1918

Wait for a bridge transaction to reach a final status (completed, failed, delivery failed).

Parameters​

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