A complete and opinionated template for developing smart contracts on Stellar using Soroban.
This boilerplate was created to accelerate the start of new projects and is specially crafted for vibe coding (AI-assisted development), providing:
- π¦ Rust workspace structure with multiple example contracts.
- π§ Ready-to-use scripts for deployment, interaction, and testing.
- π§ͺ Unit and integration tests configured.
- π€ Antigravity & Cursor Ready β Comes with pre-configured rules and skills in
.agents/and.cursor/to make your AI assistant a Soroban expert. - π Extensive documentation β Acting as the brain for your AI assistant so you can focus on the vibe.
- π³ Local network support via Docker (Stellar Quickstart).
- π Security best practices and advanced patterns.
Whether you are starting with Soroban or want a solid starting point for a real project using the latest AI-driven workflows (like Antigravity), this boilerplate is for you.
.
βββ .agents/ # Antigravity Agent Configuration (Skills & Workflows)
β βββ skills/stellar-dev/ # Soroban specialized knowledge
β βββ workflows/project-rules.md # Project-specific AI guidelines
βββ .cursor/ # Complete documentation of the Stellar ecosystem
β βββ ... (13 documentation files)
βββ .cursorrules # Legacy rules for the Cursor editor
βββ .env.example # Example environment variables
βββ Cargo.toml # Main workspace
βββ docker-compose.yml # Local Stellar network
βββ README.md # You are here!
βββ contracts/ # Example contracts
β βββ hello_world/ # Simple contract (greeting)
β βββ increment/ # Persistent counter (storage and TTL)
β βββ token/ # Basic fungible token implementation
βββ scripts/ # Utilities
β βββ deploy.sh
β βββ interact.sh
β βββ test_local.sh
βββ tests/ # Integration tests
βββ integration.rs
Before you start, make sure you have installed:
- Rust (version 1.84 or higher) β official installation
rustup target add wasm32-unknown-unknown
- Stellar CLI β installation guide
cargo install stellar-cli --locked
- Docker (optional, for local network) β install Docker
- Node.js (optional, if you plan to add a frontend later)
-
Clone the repository
git clone https://github.com/Dione-b/soroban-boilerplate.git cd soroban-boilerplate -
Configure environment variables
cp .env.example .env # Edit .env with your desired network (testnet is the default) -
Create and fund an identity (for testnet)
stellar keys generate alice --network testnet --fund
For local network:
docker-compose up -d stellar keys generate alice --network local --fund
To compile all contracts at once:
stellar contract build
# or
cargo build --target wasm32-unknown-unknown --releaseThe .wasm files will be generated in target/wasm32-unknown-unknown/release/.
Expected output example:
$ stellar contract build
Compiling hello_world v0.0.0
Compiling increment v0.0.0
Compiling token v0.0.0
Finished release [optimized] target(s) in 15.2s
cargo testExpected output:
running 3 tests
test test::test_hello ... ok
test test::test_increment ... ok
test test::test_token ... ok
cargo test --test integrationThese tests simulate interactions between multiple contracts, validating their compatibility.
./scripts/test_local.shThis script boots up the local network (via Docker), deploys the contracts, and runs an automated test suite.
π‘ Tip: Tests generate snapshots automatically in the
test_snapshots/folder. Compare them in Git to detect unexpected changes in contract behavior.
To deploy a contract to the configured network:
./scripts/deploy.sh <contract_name> [--source <identity>] [--network <network>]The script reads defaults from your .env file (STELLAR_NETWORK, STELLAR_IDENTITY). You can override them via CLI flags:
# Uses defaults from .env (identity: alice, network: testnet)
./scripts/deploy.sh hello_world
# Override identity and network
./scripts/deploy.sh hello_world --source bob --network localExpected output:
Deploying hello_world...
Network: testnet
Identity: alice
Contract ID: CABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
Use the interact.sh script to invoke contract functions:
./scripts/interact.sh <contract_id> <function_name> [--source <identity>] [--network <network>] [-- args...]Examples:
# Uses defaults from .env
./scripts/interact.sh CABCDEF...7890 hello -- --to World
# Override identity and network
./scripts/interact.sh CABCDEF...7890 hello --source bob --network local -- --to WorldExpected output:
["Hello", "World"]
For more complex commands, refer to the Stellar CLI documentation.
The .cursor/ folder contains detailed guides covering all aspects of development with Stellar/Soroban.
These documents are especially useful if you use the Cursor editor, as the AI can automatically browse them to answer your questions.
| File | Content |
|---|---|
contracts-soroban.md |
Contract development (storage, auth, events, errors) |
frontend-stellar-sdk.md |
Frontend integration (Next.js, React, wallets) |
security.md |
Security checklist and common vulnerabilities |
testing.md |
Testing strategies (unit, integration, fuzzing, mutation) |
stellar-assets.md |
Asset issuance and SAC usage |
api-rpc-horizon.md |
Data access via RPC and Horizon |
advanced-patterns.md |
Advanced patterns (upgrade, factory, governance, DeFi) |
common-pitfalls.md |
Frequent errors and how to solve them |
zk-proofs.md |
Zero-knowledge proofs (status-sensitive) |
ecosystem.md |
Mapping of tools, projects, and teams |
resources.md |
Useful links (official documentation, SDKs, examples) |
standards-reference.md |
Quick reference for SEPs and CAPs |
SKILL.md |
Main AI orchestrator (defines the assistant's scope) |
This project is optimized for the Antigravity agent. The configuration is stored in the .agents/ directory:
- Skills (
.agents/skills/): Contains thestellar-devskill, a comprehensive knowledge base about Stellar and Soroban. The agent automatically consults these files when you ask about contract development, security, or deployment. - Workflows (
.agents/workflows/):project-rules.md: Defines the global behavior of the agent (e.g., responding in Portuguese, following DRY/KISS principles).- Use
/project-rulesto explicitly invoke the project's guidelines.
The agent uses these rules to ensure high-quality code, proper error handling, and adherence to the Stellar ecosystem's best practices without manual intervention.
Want to include your own contract? Follow these steps:
-
Create a folder in
contracts/with the desired name:mkdir -p contracts/my_contract/src
-
Add the
Cargo.toml:[package] name = "my_contract" version = "0.0.0" edition = "2021" [lib] crate-type = ["cdylib"] [dependencies] soroban-sdk = { workspace = true } [dev-dependencies] soroban-sdk = { workspace = true, features = ["testutils"] }
-
Write your contract in
src/lib.rs:#![no_std] use soroban_sdk::{contract, contractimpl, vec, Env, String, Vec}; #[contract] pub struct MyContract; #[contractimpl] impl MyContract { pub fn hello(env: Env, to: String) -> Vec<String> { vec![&env, String::from_str(&env, "Hello, "), to] } } #[cfg(test)] mod test;
-
Add tests in
src/test.rs(view example contracts for inspiration). -
Done! The workspace is already configured to automatically include any folder inside
contracts/.
If something is not working as expected, refer to the common-pitfalls.md file in the .cursor/ folder. There you will find solutions for:
- Contract is too large (>64KB)
- Missing
#![no_std]error - TTL not extended (archived data)
- Authorization failing in tests
- Sequence errors (tx_bad_seq)
- And much more!
Still having issues? Open an issue.
Contributions are very welcome! If you have an idea, found a bug, or want to add a new example contract:
- Fork the project
- Create a branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Open a Pull Request
Please keep the code clean, well-tested, and following the best practices documented in the .cursor/ folder.
This project is licensed under the MIT License β see the LICENSE file for details.
- To the Stellar community and all developers contributing to the ecosystem.
- To the stellar-dev-skill repository that inspired the AI documentation structure.
Now it's up to you! Clone the repository, explore the examples, and start building the next big project on Stellar. If you have questions, the documentation is just a click (or an AI prompt) away. π