Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cultura.xyz/llms.txt

Use this file to discover all available pages before exploring further.

Client for interacting with the Bond Token (ERC20) contract Provides an interface for interacting with ERC20 tokens used for bonding in self-attestations and other platform functions. This client handles token operations like approvals and balance checks, with a test-only minting function.

Remarks

Token approvals are required before any operation that needs to transfer tokens (self-attestation, endorsements, etc.)

new BondTokenClient()

new BondTokenClient(publicClient, walletClient, contractAddress): BondTokenClient

Parameters

publicClient
walletClient
contractAddress
`0x${string}`

Returns

BondTokenClient

Methods

mint()

mint(account, amount): Promise<`0x${string}`>
Mints new bond tokens to a specified account (only for testing)

Parameters

account
`0x${string}` Address that will receive the minted tokens
amount
bigint Amount of tokens to mint

Returns

Promise<`0x${string}`> Transaction hash

Remarks

This function is only available on test networks. In production/mainnet, tokens must be acquired through proper channels (exchanges, transfers, etc).

approve()

approve(spender, amount): Promise<`0x${string}`>
Approves an address to spend tokens on behalf of the caller

Parameters

spender
`0x${string}` Address that will be approved to spend tokens
amount
bigint Amount of tokens to approve

Returns

Promise<`0x${string}`> Transaction hash

Example

// Approve tokens for self-attestation
const bondAmount = parseEther('0.0001');
await sdk.bondToken.approve(attestationServiceAddress, bondAmount);

balanceOf()

balanceOf(account): Promise<bigint>
Gets the balance of an account

Parameters

account
`0x${string}` Address to check balance of

Returns

Promise<bigint> Balance of the account

Example

// Check account balance
const balance = await sdk.bondToken.balanceOf(userAddress);

allowance()

allowance(owner, spender): Promise<bigint>
Gets the allowance of an account to spend another account’s tokens

Parameters

owner
`0x${string}` Address of the token owner
spender
`0x${string}` Address of the token spender

Returns

Promise<bigint> Amount of tokens the spender is allowed to spend

Example

// Check if contract has enough allowance
const currentAllowance = await sdk.bondToken.allowance(userAddress, contractAddress);
if (currentAllowance < requiredAmount) {
  await sdk.bondToken.approve(contractAddress, requiredAmount);
}