The Balanced contracts within the Stellar blockchain ecosystem is designed to manage various aspects of the decentralized application (dApp) including asset management, cross-chain communication, and stable coin operations. This structure ensures efficient handling of these operations through well-defined smart contracts and unique contract addresses. The smart contracts are written using Soroban framework of Rust programming language
The Balanced Stellar Spoke have three main smart contracts, each responsible for specific functionalities:
- Purpose: Manages assets within the Balanced ecosystem.
- Purpose: Facilitates cross-chain administration from the icon side.
- Purpose: Includes the bnUSD token contract and Manages the crosschain bnUSD operations within the Balanced ecosystem.
- Definition: Addresses of each each smart contract on the stellar blockchain
- Usage: Used while called using RPC and cross contract calls, also used in cross-chain configuration
soroban contract invoke --id $contract_address \
--source-account $ACCOUNT --rpc-url $ENDPOINT \
--network-passphrase "$PASSPHRASE" -- \
#method_name --arg1 $arg1 --arg2 $arg2
This guide provides an overview of the key functions for interacting with the Stellar blockchain within your frontend application. These functions are part of the Asset Manager, Balanced Dollar, and XCall smart contracts, which allow for token deposits, cross-chain transfers, and cross-chain calls.
Stellar has unique renting mechanism implemented on its smart contracts..
The Asset Manager Contract handles depositing Stellar tokens in balanced.
Deposits a specified amount of a token into the Sui blockchain.
deposit(
from: Address, //Address from which the transaction is initiated
token: Address, // Address of the token being deposited
amount: u128, // Amount of the token being deposited
to: Option<String>,// (Optional) The recipient's address if needed.
data: Option<Bytes>, // (Optional) Any additional data you want to attach to the deposit.
);
The above method can be RPC called using the shell script with the following code:
soroban contract invoke --id $assetManagerContractAddress \
--source-account $ACCOUNT --rpc-url $ENDPOINT \
--network-passphrase "$PASSPHRASE" -- \
deposit --from $fromAddress --token $tokenAddress \
--amount $amount --to $toNetworkAddress
Both native token and Other fungible tokens can be deposited using the deposit
method
The Balanced Dollar Contract facilitates the transfer of BALANCED_DOLLAR
tokens across chains.
Transfers BALANCED_DOLLAR
tokens across chains.
function cross_transfer(
from: Address, //Address from which the transaction is initiated
amount: u128, // Amount of the balanced dollar being deposited
to: String, // The recipient's address on the destination chain.
data: Option<Bytes> // (Optional) Any additional data to attach to the transfer.
)
The above method can be called using following shell script:
soroban contract invoke --id $bnUSDContractAddress \
--rpc-url $ENDPOINT --network-passphrase "$PASSPHRASE" \
--source-account $ACCOUNT -- cross_transfer --from $fromAddress -- amount $amount --to $toNetworkAddress
The get_protocols
function retrieves the sources and destinations associated with a given configuration.
function get_protocols(
) -> Result<( // Returns a tuple containing two arrays: sources and destinations or error if occurred
Vec<String>,
Vec<String>
), ContractError>