Initializes the token contract with provided parameters.
params: A vector containing 20 parameters in order:[0]: admin (Address)[1]: decimal (u32)[2]: name (String)[3]: symbol (String)[4]: tax_address (Address)[5]: initial_supply (i128)[6]: max_token_amount (i128)[7]: document_uri (String)[8]: tax_bps (u32)[9]: deflation_bps (u32)[10-19]: bool flags for token featuresOk(()) if successful.Err(ContractError) if an error occurs.fn initialize(
env: soroban_sdk::Env,
params: soroban_sdk::Vec,
) -> Result<(), ContractError>
Mints new tokens to a specified address.
to: The address that will receive the minted tokens.amount: The amount of tokens to mint (must be a non-negative integer).Ok(()) if the minting operation is successful.Err(ContractError) if an error occurs during minting.Emits an event with topics ["mint", from: Address, to: Address], data = amount: i128
NegativeAmount: If the amount is negative.ContractPaused: If the contract is currently paused and does not allow minting.MintingNotEnabled: If minting is disabled in the contract configuration.DestBalanceExceedsMaxAllowed: If the recipient's balance plus the amount exceeds the maximum allowed per address.RecipientBlacklisted: If the recipient address is blacklisted and cannot receive tokens.RecipientNotWhitelisted: If whitelisting is enabled and the recipient is not whitelisted.fn mint(
env: soroban_sdk::Env,
to: soroban_sdk::Address,
amount: i128,
) -> Result<(), ContractError>
Updates the administrator address for the contract.
new_admin: The new administrator address to be set for the contract.Ok(()) if the administrator is successfully updated.Err(ContractError) if an error occurs during the update process.Emits an event with topics `["set_admin", admin: Address, new_admin: Address]
ContractPaused: Thrown if the contract is paused, preventing administrative actions during this state.fn set_admin(
env: soroban_sdk::Env,
new_admin: soroban_sdk::Address,
) -> Result<(), ContractError>
Allows the current administrator to renounce ownership of the contract, removing the administrator address.
Ok(()) if the administrator is successfully removed.Err(ContractError) if an error occurs during the renouncement process.Emits an event with topics `["owner_renounced"]
Unauthorized: Thrown if the caller is not the current administrator, ensuring only the administrator can renounce ownership.ContractPaused: Thrown if the contract is paused, preventing administrative actions during this state.fn renounce_ownership(env: soroban_sdk::Env) -> Result<(), ContractError>
Retrieves the initial token owner address set during contract initialization.
Address: The address of the initial token owner.fn get_init_token_owner(env: soroban_sdk::Env) -> soroban_sdk::Address
Retrieves the current administrator (owner) of the contract.
Address : The address of the current administrator.Err(ContractError) if an error occurs during the get_owner process.OwnerNotFound: If the owner does not exist or has been renounced.fn get_owner(env: soroban_sdk::Env) -> Result
Retrieves the address where tax tokens are sent.
Address: The tax address.fn get_tax_address(env: soroban_sdk::Env) -> soroban_sdk::Address
Retrieves the tax basis points (bps) configured for the token.
u32: The tax basis points.fn get_tax_bps(env: soroban_sdk::Env) -> u32
Retrieves the deflation basis points (bps) configured for the token.
u32: The deflation basis points.fn get_deflation_bps(env: soroban_sdk::Env) -> u32
Retrieves the initial document URI set during contract initialization.
String: The initial document URI.fn get_initial_document_uri(env: soroban_sdk::Env) -> soroban_sdk::String
Retrieves the current document URI.
String: The current document URI.fn get_document_uri(env: soroban_sdk::Env) -> soroban_sdk::String
Retrieves the initial supply of tokens that was set during contract initialization.
i128: The initial token supply.fn get_init_supply(env: soroban_sdk::Env) -> i128
Retrieves the current total supply of tokens.
i128: The total supply of tokens.fn get_total_supply(env: soroban_sdk::Env) -> i128
Checks if the contract is currently paused.
bool: true if the contract is paused, false otherwise.fn get_is_paused(env: soroban_sdk::Env) -> bool
Retrieves the maximum token amount allowed per address.
i128: The maximum token amount per address.fn get_max_token_amount_per_addr(env: soroban_sdk::Env) -> i128
Checks if the token is mintable.
bool: true if minting is enabled, false otherwise.fn get_is_mintable(env: soroban_sdk::Env) -> bool
Checks if the token is burnable.
bool: true if burning is enabled, false otherwise.fn get_is_burnable(env: soroban_sdk::Env) -> bool
Checks if the contract is pausable.
bool: true if pausing is enabled, false otherwise.fn get_is_pausable(env: soroban_sdk::Env) -> bool
Checks if blacklisting is enabled for the token.
bool: true if blacklisting is enabled, false otherwise.fn get_is_blacklist_enabled(env: soroban_sdk::Env) -> bool
Checks if whitelisting is enabled for the token.
bool: true if whitelisting is enabled, false otherwise.fn get_is_whitelist_enabled(env: soroban_sdk::Env) -> bool
Checks if modifying the document URI is allowed.
bool: true if document URI modification is allowed, false otherwise.fn get_is_document_allowed(env: soroban_sdk::Env) -> bool
Checks if a maximum token amount per address is set.
bool: true if a maximum token amount is set, false otherwise.fn get_is_max_amount_of_tokens_set(env: soroban_sdk::Env) -> bool
Checks if force transfers are allowed.
bool: true if force transfers are allowed, false otherwise.fn get_is_force_transfer_allowed(env: soroban_sdk::Env) -> bool
Checks if the token is taxable.
bool: true if taxation is enabled, false otherwise.fn get_is_taxable(env: soroban_sdk::Env) -> bool
Checks if the token is deflationary.
bool: true if deflation is enabled, false otherwise.fn get_is_deflationary(env: soroban_sdk::Env) -> bool
Sets the document URI for the contract.
document_uri: The new document URI to be set for the contract.Ok(()) if the document URI is successfully updated.Err(ContractError) if an error occurs during the update process.ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.DocumentUriNotAllowed: Thrown if modifying the document URI is not permitted by the contract's configuration.fn set_document_uri(
env: soroban_sdk::Env,
document_uri: soroban_sdk::String,
) -> Result<(), ContractError>
Sets a new maximum token amount allowed per address for the contract.
new_max_token_amount: The new maximum token amount per address to be set.Ok(()) if the maximum token amount per address is successfully updated.Err(ContractError) if an error occurs during the update process.Emits an event with topics ["max_token_amount_per_addr_set"], data = new_max_token_amount: i128
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.MaxTokenAmountNotAllowed: Thrown if modifying the maximum token amount per address is not allowed by the contract's configuration.MaxTokenAmountPerAddrLtPrev: Thrown if the new maximum token amount is less than or equal to the current maximum, as it must be strictly greater to update.fn set_max_token_amount_per_address(
env: soroban_sdk::Env,
new_max_token_amount: i128,
) -> Result<(), ContractError>
Sets the tax configuration for the contract, including the tax address and tax basis points (bps).
new_tax_address: The new address where tax tokens will be sent.new_tax_bps: The new tax basis points to be set, which determine the percentage of tax.Ok(()) if the tax configuration is successfully updated.Err(ContractError) if an error occurs during the update process.Emits an event with topics ["tax_config_set", new_tax_address: Address], data = new_tax_bps: u32
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.TokenIsNotTaxable: Thrown if the contract's configuration does not allow taxation.InvalidTaxBPS: Thrown if new_tax_bps exceeds the maximum allowed basis points, ensuring the tax rate remains within valid limits.fn set_tax_config(
env: soroban_sdk::Env,
new_tax_address: soroban_sdk::Address,
new_tax_bps: u32,
) -> Result<(), ContractError>
Sets the deflation configuration for the contract, including the deflation basis points (bps).
new_deflation_bps: The new deflation basis points to be set, which determine the percentage of deflation.Ok(()) if the deflation configuration is successfully updated.Err(ContractError) if an error occurs during the update process.Emits an event with topics ["deflation_config_set"], data = new_deflation_bps: u32
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.TokenIsNotDeflationary: Thrown if the contract’s configuration does not allow deflation.InvalidDeflationBPS: Thrown if new_deflation_bps exceeds the maximum allowed basis points, ensuring the deflation rate remains within valid limits.fn set_deflation_config(
env: soroban_sdk::Env,
new_deflation_bps: u32,
) -> Result<(), ContractError>
Pauses the contract, preventing certain actions until it is resumed.
Ok(()) if the contract is successfully paused.Err(ContractError) if an error occurs during the pausing process.Emits an event with topics `["contract_paused"]
PausingNotEnabled: Thrown if the contract configuration does not allow pausing.fn pause(env: soroban_sdk::Env) -> Result<(), ContractError>
Unpauses the contract, allowing actions to be resumed after a pause.
Ok(()) if the contract is successfully unpaused.Err(ContractError) if an error occurs during the unpausing process.Emits an event with topics `["contract_unpaused"]
PausingNotEnabled: Thrown if the contract configuration does not allow pausing and unpausing.fn unpause(env: soroban_sdk::Env) -> Result<(), ContractError>
Checks if an address is whitelisted.
bool: true if the address is whitelisted, false otherwise.fn is_whitelisted(env: soroban_sdk::Env, addr: soroban_sdk::Address) -> bool
Adds an address to the blacklist, preventing it from participating in certain contract actions.
addr: The address to be blacklisted.Ok(()) if the address is successfully blacklisted.Err(ContractError) if an error occurs during the blacklisting process.Emits an event with topics ["user_blacklisted"], data = addr: Address
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.BlacklistNotEnabled: Thrown if the contract configuration does not allow blacklisting.AddrAlreadyBlacklisted: Thrown if the address is already blacklisted.CannotBlacklistWhitelistedAddr: Thrown if the address is currently whitelisted, preventing it from being blacklisted.fn blacklist(
env: soroban_sdk::Env,
addr: soroban_sdk::Address,
) -> Result<(), ContractError>
Removes an address from the blacklist, allowing it to participate in contract actions again.
addr: The address to be removed from the blacklist.Ok(()) if the address is successfully removed from the blacklist.Err(ContractError) if an error occurs during the removal process.Emits an event with topics ["user_unblacklisted"], data = addr: Address
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.BlacklistNotEnabled: Thrown if the contract configuration does not allow blacklisting.AddrAlreadyUnblacklisted: Thrown if the address is not currently blacklisted.fn remove_from_blacklist(
env: soroban_sdk::Env,
addr: soroban_sdk::Address,
) -> Result<(), ContractError>
Returns all the whitelisted addresses.
Vec<Address>: A vector of addresses representing the whitelisted addresses.fn get_all_whitelisted_addresses(
env: soroban_sdk::Env,
) -> soroban_sdk::Vec
Removes an address from the whitelist, revoking any special permissions it had in the contract.
address: The address to be removed from the whitelist.Ok(()) if the address is successfully removed from the whitelist.Err(ContractError) if an error occurs during the removal process.Emits an event with topics ["user_unwhitelisted"], data = address: Address
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.WhitelistNotEnabled: Thrown if the contract configuration does not allow whitelisting.fn remove_address_from_whitelist(
env: soroban_sdk::Env,
address: soroban_sdk::Address,
) -> Result<(), ContractError>
Clears all addresses from the whitelist, removing any special permissions associated with whitelisted addresses.
Ok(()) if the whitelist is successfully cleared.Err(ContractError) if an error occurs during the clearing process.Emits an event with topics `["whitelist_cleared"]
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.WhitelistNotEnabled: Thrown if the contract configuration does not allow whitelisting.fn clear_whitelist(env: soroban_sdk::Env) -> Result<(), ContractError>
Adds multiple addresses to the whitelist, granting them any special permissions associated with whitelisted addresses.
new_addresses: A vector of addresses to be added to the whitelist.Ok(()) if the addresses are successfully added to the whitelist.Err(ContractError) if an error occurs during the addition process.Emits an event with topics ["users_whitelisted"], data = new_addresses: Vec<Address>
ContractPaused: Thrown if the contract is currently paused, preventing any administrative actions.WhitelistNotEnabled: Thrown if the contract configuration does not allow whitelisting.fn add_addresses_to_whitelist(
env: soroban_sdk::Env,
new_addresses: soroban_sdk::Vec,
) -> Result<(), ContractError>
Retrieves the allowance amount that a spender is authorized to use on behalf of a given address.
from: The address that has granted the allowance.spender: The address authorized to spend on behalf of from.i128: The amount of tokens the spender is allowed to use.fn allowance(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
spender: soroban_sdk::Address,
) -> i128
Sets the allowance amount that a spender is authorized to use on behalf of a given address, with an expiration ledger.
from: The address granting the allowance.spender: The address authorized to spend on behalf of from.amount: The allowance amount being granted. Must be non-negative.expiration_ledger: The ledger number at which the allowance expires.Emits an event with topics ["approve", from: Address, spender: Address], data = [amount: i128, expiration_ledger: u32]
fn approve(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
spender: soroban_sdk::Address,
amount: i128,
expiration_ledger: u32,
)
Returns the balance of id.
id - The address for which a balance is being queried. If the
address has no existing balance, returns 0.fn balance(env: soroban_sdk::Env, id: soroban_sdk::Address) -> i128
Transfers a specified amount of tokens from one address to another, applying any applicable tax and deflation adjustments. The method also checks if the any address is blacklisted, or if whitelist is enabled, if all participants are whitelisted. If a max amount of tokens is set per address, the method checks the balance of the receiver to not exceed that amount.
from: The address sending the tokens.to: The address receiving the tokens.amount: The amount of tokens to be transferred. Must be non-negative.Emits an event with topics ["transfer", from: Address, to: Address], data = amount: i128
fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
)
Transfer amount from from to to, consuming the allowance of
spender. Authorized by spender (spender.require_auth()).
The method also checks if the any address is blacklisted, or if whitelist is enabled, if all participants are whitelisted.
If a max amount of tokens is set per address, the method checks the balance of the receiver to not exceed that amount.
spender: The address authorized to spend tokens on behalf of from.from: The address sending the tokens.to: The address receiving the tokens.amount: The amount of tokens to be transferred. Must be non-negative.Emits an event with topics ["transfer", from: Address, to: Address], data = amount: i128
fn transfer_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
)
Burn amount from from. Only the owner can burn tokens.
The method works only if burning is enabled, and contract is not paused.
from: The address from which tokens are to be burned. Must be the contract owner.amount: The amount of tokens to burn. Must be non-negative.Emits an event with topics ["burn", from: Address], data = amount: i128
fn burn(env: soroban_sdk::Env, from: soroban_sdk::Address, amount: i128)
Burn amount from from, consuming the allowance of spender.
spender: The address authorizing the burn, and having its allowance
consumed during the burn.from: The address from which tokens are to be burned. Must be the contract owner.amount: The amount of tokens to burn. Must be non-negative.Emits an event with topics ["burn", from: Address], data = amount: i128
fn burn_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
amount: i128,
)
Returns the number of decimals used to represent amounts of this token.
fn decimals(env: soroban_sdk::Env) -> u32
Returns the name for this token.
fn name(env: soroban_sdk::Env) -> soroban_sdk::String
Returns the symbol for this token.
fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String