Create a new SDK instance.
Validates config.contractId immediately and throws if it is not a valid
Stellar C-address. No network call is made during construction.
SDK configuration: contract ID, RPC URL, network passphrase, and optional timeout / retry settings.
Accept a pending admin handover (must be signed by the proposed admin).
Completes the handover started by proposeNewAdmin. Fails if there
is no pending admin, or if pendingAdminKeypair does not match the
address that was proposed.
Keypair of the proposed (pending) admin.
Accept a pending fee-collector handover (must be signed by the proposed fee collector).
Completes the handover started by proposeNewFeeCollector. Fails
if there is no pending fee collector, or if pendingCollectorKeypair
does not match the address that was proposed.
Keypair of the proposed (pending) fee collector.
Register an Ed25519 relayer public key on the contract (admin only).
Registered relayers are authorised to submit attestation signatures for
cross-chain events via fundCrosschain. After adding, update the threshold
with setRelayerThreshold if needed.
Contains the pubkey and optional admin nonce.
Keypair of the admin account.
Fund multiple C-addresses from a single source account, automatically splitting large batches across multiple transactions.
When the number of options.targets exceeds BATCH_TX_LIMIT, the
list is split into chunks of at most BATCH_TX_LIMIT entries and one
on-chain batch_fund_c_address transaction is submitted per chunk. This
means a single call to batchFundCAddresses may submit multiple
transactions and returns an array of TransactionResult — one entry
per submitted transaction, in order.
Within each chunk the contract pulls the sum of that chunk's amounts from
source upfront. For targets that fail access control the corresponding
amount is refunded to source and a BatchTransferFailed event is emitted.
A BatchCompleted event is emitted at the end of each on-chain transaction.
options.targets and options.amounts must be the same length.
Batch transfer parameters: source, targets, amounts, asset.
Keypair of the source account used to sign every transaction.
OptionalonProgress: BatchProgressCallbackOptional callback invoked after each transaction is
submitted. Receives the cumulative count of recipients
processed, the total recipient count, and the tx hash
(or undefined if submission failed before a hash was
returned).
An array of TransactionResult, one per submitted transaction.
If the entire batch fits in a single transaction the array has one
element. On a per-chunk submission error the corresponding element
has status: 'failed'; processing continues with the remaining chunks.
// Small batch — fits in one tx
const [result] = await sdk.batchFundCAddresses(
{
source: keypair.publicKey(),
targets: ['CC...1', 'CC...2', 'CC...3'],
amounts: ['5000000', '3000000', '2000000'],
asset: 'CD...usdc',
},
keypair,
);
// Large batch — auto-split with progress reporting
const results = await sdk.batchFundCAddresses(
{ source: keypair.publicKey(), targets: largeTargetList, amounts: largeAmountList, asset: 'CD...' },
keypair,
(completed, total, txHash) => {
console.log(`Processed ${completed}/${total} recipients — tx: ${txHash}`);
},
);
Claim a matured timelocked funding entry.
Estimate the transaction cost for a fundCAddress call without submitting
it to the network.
Runs simulateTransaction under the hood and extracts the Soroban resource
fee, the base inclusion fee, and the minimum account balance required.
The fundCAddress call to price.
The estimated fees plus the source account's minimum balance.
const estimate = await sdk.estimateCost({
source: keypair.publicKey(),
target: 'CC...',
asset: 'CD...',
amount: '10000000',
});
console.log('Resource fee:', estimate.resourceFee, 'stroops');
console.log('Total fee: ', estimate.fee, 'stroops');
console.log('Min balance: ', estimate.minBalance, 'stroops');
Fund a single C-address from a source G-address.
Transfers options.amount of options.asset from source into the
bridge contract, deducts the protocol fee, and forwards the net amount to
target. The source account must authorise the token transfer — this is
handled automatically by Soroban's require_auth mechanism when the
transaction is signed with sourceKeypair.
Transfer parameters: source, target, asset, amount.
Keypair of the source account. Used to sign the
transaction. Must correspond to options.source.
A TransactionResult with status: 'pending' on successful
submission, or status: 'failed' with an error message.
Poll SorobanRpc.Server.getTransaction(result.hash) to confirm
finality before showing success to the user.
const result = await sdk.fundCAddress(
{
source: keypair.publicKey(),
target: 'CC...',
asset: 'CD...usdc',
amount: '10000000', // 1 USDC (7 decimal places)
},
keypair,
);
if (result.status === 'failed') {
console.error('Transfer failed:', result.error);
} else {
console.log('Submitted tx:', result.hash);
}
Create a timelocked funding entry for a C-address.
Transfers options.amount of options.asset from source into the bridge
contract immediately. The target can later call claimTimelocked
once releaseTime has passed.
Fund a C-address by swapping the source asset into a different target asset first.
Calls fund_c_address_with_swap on the bridge contract which:
sourceAmount of sourceAsset from source.swapRoute.targetAsset and forwards the net to target.Fund a C-address from a cross-chain event (called by the relayer service).
Requires at least threshold valid relayer signatures over the canonical payload hash.
Get the contract's token balances for multiple assets in a single RPC call.
Returns a plain object mapping each asset contract address to its balance string. Useful for dashboard or monitoring use-cases.
Array of token contract addresses to query.
A Record<assetAddress, balanceString>.
Assets with a zero balance are included with value '0'.
Query the token balance of any address (G-address or C-address) for a
given asset, using the bridge contract's query_balance view function.
The address to query (G-address or C-address).
Token contract address to check the balance for.
The balance in the token's smallest unit as a decimal string.
Get the accumulated (uncollected) fee balance for a specific asset.
Use this before calling withdrawFees to know the exact withdrawable amount.
Token contract address.
The accrued fee balance in the token's smallest unit as a string.
Return a paginated list of whitelisted asset contract addresses.
Only whitelisted assets can be used in fundCAddress and batch calls.
Pagination happens on-chain: the cursor encodes the offset, and the
contract only returns up to limit entries starting at that offset.
Optionalcursor: stringOpaque cursor from a previous call. Omit to start from page 1.
Maximum items per page. Defaults to 20.
A PaginatedResult containing asset C-addresses for this page.
Check whether an address is on the allowlist.
When the contract is in allowlist mode, only allowlisted addresses can receive funds. Non-allowlisted targets in batch calls are skipped and their amounts refunded to the source.
There is no contract call that lists the full allowlist — only a
per-address membership check (query_is_allowlisted) — so this replaces
the previous (non-functional) getAllowlistedAddresses listing method.
Build a full listing from indexer events instead, once allowlist events
exist.
The address to check.
true if address is allowlisted.
Check whether an address is on the blocklist.
Blocklisted addresses cannot receive funds via fundCAddress or batch calls.
Transfers to them are silently skipped (in batch) or rejected (single).
There is no contract call that lists the full blocklist — only a
per-address membership check (query_is_blocked) — so this replaces the
previous (non-functional) getBlocklistedAddresses listing method. Build
a full listing from indexer events instead, once blocklist events exist.
The address to check.
true if address is blocklisted.
Check whether the bridge contract has been initialized.
The contract must be initialized (via initialize) before any funding
operations are permitted. Use this after deployment to verify the contract
is ready for use.
true if the contract has been initialized, false otherwise.
Propose an admin handover to a new G-address (admin only).
This two-step path is preferred over setAdmin for normal operations
because it proves the proposed admin controls the key (via
acceptAdmin) before the role is moved — setAdmin transfers
control immediately and unrecoverably if the new key is unusable.
G-address of the proposed admin.
Keypair of the current admin account.
Optionalnonce: string | number | bigintPropose a fee-collector handover to a new G-address (admin only).
This two-step path is preferred over setFeeCollector for normal
operations because it proves the proposed collector controls the key
(via acceptFeeCollector) before the role is moved.
G-address of the proposed fee collector.
Keypair of the admin account.
Optionalnonce: string | number | bigintQuery a timelocked funding entry by ID.
Reclaim tokens accidentally sent directly to the bridge contract address.
Admin only. This is an emergency recovery tool — it moves the contract's
raw token balance (minus any accrued fees for that asset) to options.to.
Asset, amount, and destination address.
Keypair of the admin account.
Remove a previously registered Ed25519 relayer public key (admin only).
The removed key can no longer contribute valid signatures for cross-chain attestations. Ensure the remaining relayer set still meets the threshold or lower the threshold first.
Contains the 32-byte Ed25519 pubkey as a hex string.
Keypair of the admin account.
Transfer the admin role to a new G-address (admin only).
After this call the old admin loses all privileged access. Ensure the new admin keypair is accessible before calling this — there is no recovery path if the new admin key is lost.
G-address of the new admin.
Keypair of the current admin account.
Optionalnonce: string | number | bigintUpdate the protocol fee rate (admin only).
The new fee takes effect on the next fund_c_address call.
Maximum allowed value is 1000 bps (10%).
New fee in basis points (0–1000).
Keypair of the admin account.
Optionalnonce: string | number | bigintRotate the fee-collector address (admin only).
The new fee collector immediately gains the right to call withdrawFees.
The old fee collector loses it.
G-address of the new fee collector.
Keypair of the admin account.
Optionalnonce: string | number | bigintOptionalnonce: string | number | bigintSet the M-of-N relayer threshold (admin only).
Cross-chain attestations require at least threshold valid signatures from
registered relayers. Must not exceed the total number of registered relayers.
Minimum number of valid relayer signatures required.
Keypair of the admin account.
Upgrade the contract to a new wasm implementation (admin only). The new_wasm_hash must reference wasm already uploaded to the network. Preserves all instance storage (admin, fee settings, etc.).
Withdraw accumulated protocol fees from the bridge contract.
Only the configured fee-collector address may call this method. Fees
accumulate in the contract after every successful fund_c_address or
batch_fund_c_address call.
Asset and amount to withdraw.
Keypair of the fee-collector account.
TypeScript SDK for the C-Address Onboarding Bridge Soroban contract.
Provides typed wrappers around every contract function. Mutating methods return a TransactionResult and never throw — errors are surfaced through
result.status === 'failed'. Read-only query methods throw on RPC or contract error so you can use standardtry/catchpatterns.All RPC calls are automatically retried on transient network failures using exponential backoff with full jitter (see withRpcRetry). The retry policy is configurable via
BridgeConfig.retry.Example