resources/bondToken.BondTokenClient

The BondTokenClient provides an interface for interacting with the platform’s utility token, the Bond Token. This token is used for payments, staking, and other economic activities within the Spaceport and Cultura ecosystem. This client simplifies operations like checking balances, approving transfers, and minting new tokens.

Table of contents

Methods

constructor

new BondTokenClient(client): BondTokenClient

Parameters

NameType
clientSpaceportSDK

Returns

BondTokenClient

Methods

balanceOf

balanceOf(address): Promise<bigint>

Retrieves the balance of bond tokens for an address.

Parameters

NameTypeDescription
address`0x${string}`The address to check balance for

Returns

Promise<bigint>

The balance as a bigint

approve

approve(spender, amount): Promise<`0x${string}`>

Approves a specific address to spend a certain amount of bond tokens.

Parameters

NameTypeDescription
spender`0x${string}`The address being approved to spend tokens
amountbigintThe amount of tokens to approve

Returns

Promise<`0x${string}`>

Transaction hash

allowance

allowance(owner, spender): Promise<bigint>

Checks the current allowance granted to a spender.

Parameters

NameTypeDescription
owner`0x${string}`The owner of the tokens
spender`0x${string}`The address with spending approval

Returns

Promise<bigint>

The current allowance as a bigint

checkFundsAndAllowance

checkFundsAndAllowance(walletAddress, spenderAddress, requiredAmount): Promise<void>

Checks if a wallet has sufficient balance and allowance for a specific amount.

Parameters

NameTypeDescription
walletAddress`0x${string}`The wallet address to check
spenderAddress`0x${string}`The address that needs allowance to spend tokens
requiredAmountbigintThe amount of tokens required

Returns

Promise<void>

Promise that resolves if checks pass, throws error if insufficient funds/allowance

mint

mint(to, amount): Promise<`0x${string}`>

Mints new bond tokens to a specified address (admin function).

Parameters

NameTypeDescription
to`0x${string}`The recipient of the minted tokens
amountbigintThe amount of tokens to mint

Returns

Promise<`0x${string}`>

Transaction hash

approveAllForAmount

approveAllForAmount(amount): Promise<Record<string, { hash: `0x${string}` ; status: "success" | "reverted" }>>

Approves all Cultura and Spaceport contracts to spend a specific amount of tokens and waits for confirmations

Parameters

NameTypeDescription
amountbigintAmount of tokens to approve for each contract

Returns

Promise<Record<string, { hash: `0x${string}` ; status: "success" | "reverted" }>>

Object containing transaction receipts for each approval

Example

// Approve all Cultura and Spaceport contracts to spend tokens
import { parseEther } from 'viem'
await sdk.bondToken.approveAllForAmount(parseEther('1'));