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.
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 32-byte Ed25519 pubkey as a hex string.
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}`);
},
);
Create a new Soroban smart-contract account (C-address).
Calls the bridge contract's create_contract helper which deploys a new
account contract and derives its C-address from the deployer's address and
an optional salt. If options.initialFunds is provided, a fund_c_address
call is made immediately after creation so the new account has a starting
balance.
Deployer keypair, optional deterministic salt, and optional initial funding parameters.
A CreateCAddressResult with the new C-address and creation tx hash.
InternalConvert an array of JavaScript values to Soroban ScVal XDR values.
Handles strings (G-/C-addresses, numeric strings, plain strings), numbers,
bigints, Address instances, arrays (→ scvVec), and null/undefined
(→ scvVoid).
Array of xdr.ScVal suitable for passing to Contract.call.
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.
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);
}
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'.
Return a paginated list of addresses 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.
Optionalcursor: stringOpaque cursor from a previous call. Omit to start from page 1.
Maximum items per page. Defaults to 20.
A PaginatedResult of address strings.
Return a paginated list of addresses on the blocklist.
Blocklisted addresses cannot receive funds via fundCAddress or batch calls.
Transfers to them are silently skipped (in batch) or rejected (single).
Optionalcursor: stringOpaque cursor from a previous call. Omit to start from page 1.
Maximum items per page. Defaults to 20.
A PaginatedResult of address strings.
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 held by the contract 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 fee-exempt addresses.
Fee-exempt addresses pay zero protocol fee on every transfer regardless of
the configured fee_bps. The full list is fetched from the contract and
paginated client-side.
Optionalcursor: stringOpaque cursor from a previous call. Omit to start from page 1.
Maximum items per page. Defaults to 20.
A PaginatedResult of address strings.
Return a paginated list of whitelisted asset contract addresses.
Only whitelisted assets can be used in fundCAddress and batch calls.
The full list is fetched from the contract and paginated client-side.
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 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.
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.
Update 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.
Rotate 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.
Set 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