This project demonstrates a simple token creation system built on the Soroban smart contract platform for the Stellar blockchain. The contract allows you to deploy tokens with specified metadata, manage balances, set allowances, and perform transfers. This modular contract leverages Soroban SDK to interact with accounts and maintain token data efficiently.
- Token Initialization: Create tokens with custom metadata like name, symbol, and decimal places.
- Minting: Admin can mint new tokens to specified accounts.
- Transfer Mechanism: Token holders can transfer tokens between accounts.
- Allowance Management: Set allowances for other accounts to spend tokens on behalf of the owner.
- Balance Management: Track account balances securely.
- Admin Functions: Admin control for minting and transferring tokens.
- admin.rs: Handles administrator roles for managing token operations.
- allowance.rs: Manages allowances between accounts for token spending.
- balance.rs: Provides utilities for reading and updating account balances.
- contract.rs: Main entry point with functions like initialization, transfer, and minting.
- metadata.rs: Stores and retrieves metadata such as token name, symbol, and decimals.
- storage_types.rs: Defines custom data structures used throughout the contract.
- test.rs: Contains unit tests for validating the contract’s behavior.
- Rust and Cargo installed.
- Soroban CLI installed: Installation Guide.
- Stellar Wallet or Test Account for deploying contracts on the testnet.
-
Navigate to the contract folder:
cd contracts/lumifi_token_laucher
-
Build the contract using Soroban CLI:
soroban contract build
-
Deploy the contract:
soroban contract deploy --wasm target/wasm32-unknown-unknown/release/lumifi_token_laucher.wasm --network testnet
-
Note the contract ID from the deployment output, as it will be used for further interactions.
Initialize a token with metadata such as name, symbol, and decimal points.
soroban contract invoke --id <CONTRACT_ID> --fn create_token --arg <ADMIN_ADDRESS> --arg 18 --arg "MyToken" --arg "MTK"
The admin can mint tokens for a specific account.
soroban contract invoke --id <CONTRACT_ID> --fn mint --arg <ACCOUNT_ADDRESS> --arg 1000
A user can transfer tokens to another account.
soroban contract invoke --id <CONTRACT_ID> --fn transfer --arg <FROM_ADDRESS> --arg <TO_ADDRESS> --arg 50
Set allowance for another account to spend on behalf of the owner.
soroban contract invoke --id <CONTRACT_ID> --fn approve --arg <OWNER_ADDRESS> --arg <SPENDER_ADDRESS> --arg 100
View the balance of a specific account.
soroban contract invoke --id <CONTRACT_ID> --fn balance --arg <ACCOUNT_ADDRESS>
- Create a Token: Admin initializes a token named "MyToken" with the symbol "MTK".
- Mint Tokens: Admin mints 1,000 tokens to User A.
- Transfer Tokens: User A transfers 50 tokens to User B.
- Set Allowance: User A approves User B to spend 100 tokens on their behalf.
- Check Balances: Check the balances of User A and User B to confirm transactions.
Use the included test.rs
file to validate the contract’s behavior.
cargo test
If you encounter issues during the build or deployment, ensure:
- Rust and Soroban CLI are correctly installed.
- The Stellar testnet is accessible.
- You have the correct contract ID and function names.
This project is licensed under the MIT License.
This project offers a simple but powerful token management system using Soroban on Stellar. It serves as a foundation for building more complex decentralized applications, such as liquidity pools, swaps, or DeFi solutions.