The Template Marketplace feature enables community-contributed Soroban smart contract templates with versioning, discovery, and easy scaffolding. This allows developers to quickly bootstrap projects using battle-tested templates from the community.
Search and browse available templates by name, description, or tags:
# Search for DeFi templates
starforge template search defi
# Search with tag filtering
starforge new contract --search defi --tags dex,amm
# List all available templates
starforge template list
# View detailed information about a template
starforge template show uniswap-v2Scaffold new projects using marketplace templates:
# Use a marketplace template
starforge new contract my-dex --template uniswap-v2 --from marketplace
# Search and use in one workflow
starforge new contract --search lending
# Then use the found template
starforge new contract my-lending --template lending-pool --from marketplaceShare your templates with the community:
# Publish a template
starforge template publish ./my-template \
--name my-awesome-template \
--description "An awesome Soroban contract" \
--author "Your Name" \
--tags "defi,custom" \
--version "1.0.0"
# Interactive publishing (prompts for missing info)
starforge template publish ./my-templateManage your local template registry:
# Initialize registry with example templates
starforge template init
# Remove a template
starforge template remove my-templateEvery template must contain:
Cargo.toml- Rust package manifestsrc/directory - Source codesrc/lib.rs- Main contract file
README.md- Documentation.cargo/config.toml- Cargo configurationtests/- Test files
Templates support automatic variable substitution:
| Placeholder | Example Input | Example Output |
|---|---|---|
{{PROJECT_NAME}} |
my-project | my-project |
{{PROJECT_NAME_SNAKE}} |
my-project | my_project |
{{PROJECT_NAME_PASCAL}} |
my-project | MyProject |
Example usage in Cargo.toml:
[package]
name = "{{PROJECT_NAME}}"
version = "0.1.0"Example usage in src/lib.rs:
#[contract]
pub struct {{PROJECT_NAME_PASCAL}};Templates can be sourced from three locations:
{
"source": {
"type": "git",
"url": "https://github.com/user/repo",
"branch": "main"
}
}{
"source": {
"type": "local",
"path": "/path/to/template"
}
}{
"source": {
"type": "builtin",
"id": "hello-world"
}
}The template registry is stored in ~/.starforge/templates/registry.json:
{
"version": "1",
"templates": [
{
"name": "uniswap-v2",
"version": "1.0.0",
"description": "Uniswap V2 style AMM DEX",
"author": "Stellar Community",
"tags": ["defi", "dex", "amm"],
"source": {
"type": "git",
"url": "https://github.com/stellar/soroban-examples",
"branch": "main"
},
"created_at": "2025-01-01T00:00:00Z",
"updated_at": "2025-01-01T00:00:00Z",
"downloads": 42,
"verified": true
}
]
}Templates can be marked as verified: true by maintainers. Verified templates:
- Have been reviewed for security and quality
- Follow Soroban best practices
- Include proper documentation
- Have working tests
Verified templates appear first in search results with a ✓ badge.
-
Discover templates:
starforge template search defi
-
View template details:
starforge template show uniswap-v2
-
Create project from template:
starforge new contract my-dex --template uniswap-v2 --from marketplace
-
Build and deploy:
cd my-dex stellar contract build starforge deploy --wasm target/wasm32-unknown-unknown/release/my_dex.wasm
-
Create your template:
# Create a new contract as usual starforge new contract my-template cd my-template # Add your custom logic # Replace hardcoded names with placeholders
-
Add placeholders:
// In src/lib.rs #[contract] pub struct {{PROJECT_NAME_PASCAL}};
-
Test the template:
cargo test stellar contract build -
Publish to marketplace:
cd .. starforge template publish ./my-template \ --name my-awesome-template \ --description "Does something awesome" \ --author "Your Name" \ --tags "defi,awesome" \ --version "1.0.0"
-
Share with others:
# Others can now use it starforge new contract test-project --template my-awesome-template --from marketplace
The marketplace includes several example templates:
- uniswap-v2 - AMM DEX implementation
- lending-pool - Lending and borrowing protocol
- governance - DAO governance with voting
- multisig-wallet - Multi-signature wallet
Initialize these with:
starforge template initsrc/
├── commands/
│ ├── new.rs # Extended with marketplace support
│ └── template.rs # New template management commands
├── utils/
│ └── templates.rs # Template registry and operations
templates/
├── registry.json # Default template registry
├── README.md # Template documentation
└── examples/
└── simple-counter/ # Example template
Template Discovery:
search_templates(query, tags)- Search with filteringget_template(name)- Get specific templateload_registry()- Load template registry
Template Operations:
fetch_template(entry, dest)- Download/copy templatevalidate_template_structure(path)- Validate templatepublish_template(...)- Publish new template
Registry Management:
add_template(entry)- Add to registryremove_template(name)- Remove from registrysave_registry(registry)- Persist changes
Potential improvements for future versions:
- Remote Registry - Central registry server for global template sharing
- Template Versioning - Support multiple versions of the same template
- Template Updates - Update existing templates to newer versions
- Template Dependencies - Templates that depend on other templates
- Template Categories - Organize templates into categories
- Template Ratings - Community ratings and reviews
- Template Analytics - Usage statistics and popularity metrics
- Template CI/CD - Automated testing and verification
- Template Marketplace UI - Web interface for browsing templates
When using templates from the marketplace:
- Review Code - Always review template code before using
- Verify Source - Check the template source (Git URL, author)
- Use Verified - Prefer verified templates when available
- Test Thoroughly - Test templates in a safe environment first
- Update Dependencies - Keep template dependencies up to date
To contribute templates to the official registry:
- Create a high-quality template following best practices
- Test thoroughly with multiple project names
- Add comprehensive documentation
- Submit a PR adding your template to
templates/registry.json - Include examples and usage instructions
For issues or questions:
- GitHub Issues: https://github.com/YOUR_USERNAME/starforge/issues
- Documentation: https://github.com/YOUR_USERNAME/starforge/blob/main/README.md