This project contains two Stellar smart contracts written in Rust: a token contract and an NFT contract. These contracts can be built, optimized, and deployed on the Stellar testnet.
.
├── contracts
│ ├── token
│ │ └── src
│ │ └── lib.rs
│ ├── nft
│ │ └── src
│ │ └── lib.rs
├── target
│ └── wasm32-unknown-unknown
│ └── release
│ ├── soroban_token_contract.wasm
│ ├── soroban_token_contract.optimized.wasm
│ ├── soroban_nft_contract.wasm
│ ├── soroban_nft_contract.optimized.wasm
└── README.md
Ensure you have the following installed:
- Rust: Install Rust
- Stellar CLI: Install Stellar CLI
To build the contracts, navigate to the project root directory and run:
stellar contract build
This command will generate the WebAssembly (WASM) files for both contracts:
target/wasm32-unknown-unknown/release/soroban_token_contract.wasm
target/wasm32-unknown-unknown/release/soroban_nft_contract.wasm
Optimize the generated WASM files to reduce their size and improve performance:
stellar contract optimize --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm
stellar contract optimize --wasm target/wasm32-unknown-unknown/release/soroban_nft_contract.wasm
This will create the optimized WASM files:
target/wasm32-unknown-unknown/release/soroban_token_contract.optimized.wasm
target/wasm32-unknown-unknown/release/soroban_nft_contract.optimized.wasm
Deploy the optimized WASM files to the Stellar testnet using the following command:
stellar contract deploy --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.optimized.wasm --source alice --network testnet
stellar contract deploy --wasm target/wasm32-unknown-unknown/release/soroban_nft_contract.optimized.wasm --source alice --network testnet
Replace alice
with the actual source account name.
Once deployed, you can interact with the contracts on the Stellar testnet. Refer to the Stellar documentation for details on how to call contract functions and handle transactions.
This README file provides a comprehensive guide on building, optimizing, and deploying your Stellar smart contracts.