macOS:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Stellar CLI
# Follow instructions at https://soroban.stellar.org/docs/getting-started/setupLinux:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Stellar CLI
# Follow instructions at https://soroban.stellar.org/docs/getting-started/setupWindows:
# Install Rust
# Download from https://rustup.rs/
# Install Stellar CLI
# Follow instructions at https://soroban.stellar.org/docs/getting-started/setuprustc --version
cargo --version
stellar --version-
Clone and navigate:
git clone https://github.com/Samuel1-ona/Hunty-contract.git cd Hunty-contract -
Build all contracts:
# Build hunty-core cd contracts/hunty-core make build # Build reward-manager cd ../reward-manager make build # Build nft-reward cd ../nft-reward make build
-
Run tests:
# From each contract directory make test
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make changes:
- Edit source files
- Add tests
- Update documentation
-
Test your changes:
make test make build -
Format code:
make fmt
-
Commit and push:
git add . git commit -m "feat: description of changes" git push origin feature/your-feature-name
Individual contract tests:
cd contracts/hunty-core
cargo testAll tests:
cargo test --workspaceWith output:
cargo test -- --nocaptureBuild a single contract:
cd contracts/hunty-core
make buildBuild all contracts:
# From project root
for dir in contracts/*/; do
cd "$dir" && make build && cd ../..
doneCheck build output:
ls -lh target/wasm32-unknown-unknown/release/*.wasmFile Structure:
lib.rs- Main contract implementationtypes.rs- Data structures (Hunt, Clue, PlayerProgress)storage.rs- Storage access patternserrors.rs- Custom error typestest.rs- Test suite
Key Functions to Implement:
create_hunt()- Create new huntadd_clue()- Add clue to huntregister_player()- Register player for huntsubmit_answer()- Submit and verify answercomplete_hunt()- Mark hunt complete
File Structure:
lib.rs- Main reward distribution logicxlm_handler.rs- XLM token handlingnft_handler.rs- NFT coordinationtest.rs- Test suite
Key Functions to Implement:
distribute_rewards()- Main distribution entryhandle_xlm_rewards()- XLM transfer logichandle_nft_rewards()- NFT minting coordination
File Structure:
lib.rs- NFT contract implementationtest.rs- Test suite
Key Functions to Implement:
mint_reward_nft()- Mint NFT for rewardtransfer_nft()- Transfer NFT to playerget_nft_metadata()- Retrieve NFT info
Test individual functions:
#[test]
fn test_create_hunt() {
let env = Env::default();
// Test implementation
}Test cross-contract interactions:
#[test]
fn test_reward_distribution() {
// Test HuntyCore -> RewardManager -> NftReward flow
}Aim for >80% code coverage. Run:
cargo test --workspace -- --nocapture-
Build errors:
- Check Rust version:
rustc --version - Clean and rebuild:
make clean && make build
- Check Rust version:
-
Test failures:
- Run with output:
cargo test -- --nocapture - Check error messages carefully
- Run with output:
-
Storage issues:
- Verify storage keys are unique
- Check data serialization
Print debugging:
env.logs().add("Debug message", &value);Check storage:
// In tests
let stored_value = env.storage().get(&key);Always format before committing:
make fmt
# or
cargo fmt --all- Functions:
snake_case - Types:
PascalCase - Constants:
UPPER_SNAKE_CASE - Storage keys:
snake_case
Add doc comments:
/// Creates a new hunt with the given parameters.
///
/// # Arguments
/// * `env` - The environment
/// * `creator` - Address of the hunt creator
///
/// # Returns
/// Hunt ID
pub fn create_hunt(env: Env, creator: Address) -> u64 {
// Implementation
}# Deploy to local network
stellar contract deploy --wasm target/wasm32-unknown-unknown/release/hunty_core.wasm# Deploy to testnet
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/hunty_core.wasm \
--network testnet- Check ARCHITECTURE.md for system design
- Review CONTRIBUTING.md for contribution guidelines
- Open an issue on GitHub for questions