Destroys amount of tokens from from. Updates the total
supply accordingly.
e - Access to the Soroban environment.from - The account whose tokens are destroyed.amount - The amount of tokens to burn.crate::fungible::FungibleTokenError::InsufficientBalance] - When
attempting to burn more tokens than from current balance.crate::fungible::FungibleTokenError::LessThanZero] - When amount < 0.["burn", from: Address][amount: i128]fn burn(env: soroban_sdk::Env, from: soroban_sdk::Address, amount: i128)
Returns the name for this token.
e - Access to Soroban environment.fn name(env: soroban_sdk::Env) -> soroban_sdk::String
Bridges tokens to another chain
Burns tokens on the current chain and sends a cross-chain message to mint tokens on the destination chain.
env - The Soroban environmentfrom - The address sending the tokensdestination_chain - The chain ID of the destination chainamount - The amount of tokens to bridge (in base units)recipient - The recipient address on the destination chain (as bytes)text - Optional text message to include with the transferReturns the transaction ID (i128) for tracking the cross-chain transfer
fn bridge(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
destination_chain: u64,
amount: i128,
recipient: soroban_sdk::Bytes,
text: soroban_sdk::Bytes,
) -> u128
Returns the symbol for this token.
e - Access to Soroban environment.fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String
Sets the amount of tokens a spender is allowed to spend on behalf of
an owner. Overrides any existing allowance set between spender and
owner.
e - Access to Soroban environment.owner - The address holding the tokens.spender - The address authorized to spend the tokens.amount - The amount of tokens made available to spender.live_until_ledger - The ledger number at which the allowance
expires.FungibleTokenError::InvalidLiveUntilLedger] - Occurs when
attempting to set live_until_ledger that is less than the current
ledger number and greater than 0.FungibleTokenError::LessThanZero] - Occurs when amount < 0.["approve", from: Address, spender: Address][amount: i128, live_until_ledger: u32]fn approve(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
amount: i128,
live_until_ledger: u32,
)
Returns the amount of tokens held by account.
e - Access to the Soroban environment.account - The address for which the balance is being queried.fn balance(env: soroban_sdk::Env, account: soroban_sdk::Address) -> i128
Returns the number of decimals used to represent amounts of this token.
e - Access to Soroban environment.fn decimals(env: soroban_sdk::Env) -> u32
Transfers amount of tokens from from to to.
e - Access to Soroban environment.from - The address holding the tokens.to - The address receiving the transferred tokens.amount - The amount of tokens to be transferred.FungibleTokenError::InsufficientBalance] - When attempting to
transfer more tokens than from current balance.FungibleTokenError::LessThanZero] - When amount < 0.["transfer", from: Address, to: Address][to_muxed_id: Option<u64>, amount: i128]fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::MuxedAddress,
amount: i128,
)
Returns the amount of tokens a spender is allowed to spend on behalf
of an owner.
e - Access to Soroban environment.owner - The address holding the tokens.spender - The address authorized to spend the tokens.fn allowance(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
) -> i128
Destroys amount of tokens from from. Updates the total
supply accordingly.
e - Access to the Soroban environment.spender - The address authorized to burn the tokens.from - The account whose tokens are destroyed.amount - The amount of tokens to burn.crate::fungible::FungibleTokenError::InsufficientBalance] - When
attempting to burn more tokens than from current balance.crate::fungible::FungibleTokenError::InsufficientAllowance] - When
attempting to burn more tokens than from allowance.crate::fungible::FungibleTokenError::LessThanZero] - When amount < 0.["burn", from: Address][amount: i128]fn burn_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
amount: i128,
)
Sends a message to a destination chain through the message gateway
This is a default implementation that delegates to MessageClientBase.
fn message_send(
env: soroban_sdk::Env,
destination_chain: u64,
chain_data: soroban_sdk::Bytes,
confirmations: u32,
) -> u128
Returns the total amount of tokens in circulation.
e - Access to the Soroban environment.fn total_supply(env: soroban_sdk::Env) -> i128
fn __constructor(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
name: soroban_sdk::String,
symbol: soroban_sdk::String,
decimals: u32,
initial_supply: i128,
)
Approves spending of tokens from another token contract
env - The Soroban environmenttoken_address - The address of the token contract to approvespender - The address that will be approved to spend tokensamount - The amount of tokens to approve (in base units)expiration_ledger - The ledger number when the approval expiresfn approve_token(
env: soroban_sdk::Env,
token_address: soroban_sdk::Address,
spender: soroban_sdk::Address,
amount: i128,
expiration_ledger: u32,
)
Transfers amount of tokens from from to to using the
allowance mechanism. amount is then deducted from spender
allowance.
e - Access to Soroban environment.spender - The address authorizing the transfer, and having its
allowance consumed during the transfer.from - The address holding the tokens which will be transferred.to - The address receiving the transferred tokens.amount - The amount of tokens to be transferred.FungibleTokenError::InsufficientBalance] - When attempting to
transfer more tokens than from current balance.FungibleTokenError::LessThanZero] - When amount < 0.FungibleTokenError::InsufficientAllowance] - When attempting to
transfer more tokens than spender current allowance.["transfer", from: Address, to: Address][amount: i128]fn transfer_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
)
fn message_process(env: soroban_sdk::Env, request: ProcessFromGatewayRequest)
Transfers the message owner address.
Ownership is initialized atomically during __constructor by the
#[default_impl] macro, so this method is only reachable after an
owner has already been set. Only the current owner can authorize a
transfer.
This is a default implementation that delegates to MessageClientBase.
fn set_message_owner(env: soroban_sdk::Env, new_owner: soroban_sdk::Address)
Retrieves all text messages received from cross-chain transfers
env - The Soroban environmentA vector of Bytes containing all received text messages
fn get_received_texts(env: soroban_sdk::Env) -> soroban_sdk::Vec
Returns the active message gateway address, or None if not yet set.
fn get_message_gateway(env: soroban_sdk::Env) -> Option
Initiates a two-step gateway rotation (owner-only).
First call sets the gateway directly. Subsequent calls record a pending
transfer; the new gateway must call transfer_message_gateway to complete it.
fn set_message_gateway(env: soroban_sdk::Env, contract_address: soroban_sdk::Address)
Sets project signers on the gateway for this contract
This is a default implementation that delegates to MessageClientBase.
fn set_project_signers(
env: soroban_sdk::Env,
signers: soroban_sdk::Vec,
required: u32,
)
Decodes ABI-encoded bridge data using the generic ABI decoder
env - The Soroban environmentencoded - The ABI-encoded bytes to decodeA tuple containing (recipient, amount, text)
fn decode_abi_chain_data(
env: soroban_sdk::Env,
encoded: soroban_sdk::Bytes,
) -> (soroban_sdk::Bytes, i128, soroban_sdk::Bytes)
Encodes bridge data into ABI format using the generic ABI encoder
env - The Soroban environmentrecipient - The recipient address on the destination chainamount - The amount of tokens to bridgetext - Optional text message to includeABI-encoded bytes containing the bridge data
fn encode_abi_chain_data(
env: soroban_sdk::Env,
recipient: soroban_sdk::Bytes,
amount: i128,
text: soroban_sdk::Bytes,
) -> soroban_sdk::Bytes
Sets contract relayers on the gateway for this contract
This is a default implementation that delegates to MessageClientBase.
fn set_contract_relayers(
env: soroban_sdk::Env,
relayers: soroban_sdk::Vec,
)
Sets message endpoints for different chains
This is a default implementation that delegates to MessageClientBase.
fn set_message_endpoints(
env: soroban_sdk::Env,
chains: soroban_sdk::Vec,
endpoints: soroban_sdk::Vec,
)
Validates that a sender is authorized for a given source chain
This is a default implementation that delegates to MessageClientBase.
fn validate_chain_sender(
env: soroban_sdk::Env,
source_chain_id: u64,
sender: soroban_sdk::Bytes,
)
Retrieves the endpoint address for a specific chain ID
This is a default implementation that delegates to MessageClientBase.
fn get_endpoint_by_chain_id(env: soroban_sdk::Env, chain_id: u64) -> soroban_sdk::Bytes
Completes a pending gateway rotation.
contract_address (the pending gateway) must authorize this call.
Called by the gateway contract's accept_admin_transfer method.
fn transfer_message_gateway(
env: soroban_sdk::Env,
contract_address: soroban_sdk::Address,
)
Initializes the ClientTestV4 contract
This method is called automatically during contract registration. It sets up the contract owner, token metadata, and mints the initial supply.
env - The Soroban environmentowner - The address that will own the contractname - The name of the tokensymbol - The symbol of the tokendecimals - The number of decimals for the tokeninitial_supply - The initial number of tokens to mint to the ownerfn __message_client_constructor(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
name: soroban_sdk::String,
symbol: soroban_sdk::String,
decimals: u32,
initial_supply: i128,
)
fn message_process_from_gateway(
env: soroban_sdk::Env,
request: ProcessFromGatewayRequest,
)