smart-contracts
Skill17 starsChanged 2 months agoMITView on GitHub
Stellar smart contract development (Rust, soroban-sdk). Covers project setup, contract anatomy, storage/TTL, authorization, cross-contract calls, events, errors, upgrades, and comprehensive testing strategies.
- Reads credentials
3 other projects use a version of this.
Adopted by
Most recently taken up by
- DongDuong2001/pudo-code-systemtheir own version, first seen Oct 13, 2026
- poorvith-mp/skills-developertheir own version, first seen Aug 19, 2026
- piplabs/story-skillstheir own version, first seen Feb 25, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- DongDuong2001/pudo-code-system★ 5same name
- piplabs/story-skills★ 4same name
- poorvith-mp/skills-developer★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository32 other files it gives its agents.
- references/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- banner-designSkill
- brandkitSkill
- brandSkill
- designSkill
- design-systemSkill
- design-taste-frontendSkill
- design-taste-frontend-v1Skill
- full-output-enforcementSkill
- gpt-tasteSkill
- high-end-visual-designSkill
- imagegen-frontend-mobileSkill
- imagegen-frontend-webSkill
- image-to-codeSkill
- industrial-brutalist-uiSkill
- minimalist-uiSkill
- redesign-existing-projectsSkill
- slidesSkill
- stitch-design-tasteSkill
- ui-stylingSkill
- ui-ux-pro-maxSkill
- stellar-forgeSkill
- agentic-paymentsSkill
- assetsSkill
- dappSkill
- dataSkill
- frontend-designSkill
- graphifySkill
- standardsSkill
- stellar-mcpSkill
- zk-proofsSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 68
Test that only authorized callers can invoke privileged functions:
- Distinctive: line 241
If missing → first deploy → silent auto-deploy
- Distinctive: line 242
If exists → ask user before deploying
- Distinctive: line 246
Every deploy must record the contract ID in two places:
- Very specific: line 282
Always run cargo test before deploying
- Very specific: line 283
Test auth failures explicitly — do not rely on mock_all_auths() alone
- Distinctive: line 284
Test both happy path and error paths
- Distinctive: line 285
Verify events are emitted with correct topics and data
- Distinctive: line 286
Check TTL extension on persistent storage writes
- Very specific: line 287
Never deploy with failing tests — deploy is gated on cargo test passing 100%
- Very specific: line 288
Always record deployed contract IDs in data/deployments/<network>.json and .env
- Very specific: line 290
Run cargo test before cargo build --release to fail fast on test failures
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Smart Contracts (Soroban)
Source Files
| File | Contents |
contracts/hello-world/src/lib.rs | Minimal contract scaffold |
contracts/hello-world/src/test.rs | Unit + auth + event tests |
contracts/token/src/lib.rs | Full SEP-41 token |
contracts/token/src/test.rs | Token unit + integration tests |
Testing Guide
Setup
#![cfg(test)]
extern crate std;
use soroban_sdk::{
testutils::{Address as _, Events},
Address, Env, String, Symbol,
};Pattern 1: Unit Test with Setup Helper
Extract shared setup into a helper function:
fn setup() -> (Env, Address, Address, MyContractClient<'static>) {
let env = Env::default();
env.mock_all_auths();
let admin = Address::generate(&env);
let user = Address::generate(&env);
let contract_id = env.register(MyContract, (&admin, 1000u32));
let client = MyContractClient::new(&env, &contract_id);
(env, admin, user, client)
}
#[test]
fn test_initial_state() {
let (_, _, _, client) = setup();
assert_eq!(client.get_count(), 0);
}Pattern 2: Auth Testing (without mock_all_auths)
Test that only authorized callers can invoke privileged functions:
#[test]
fn test_auth_required() {
let env = Env::default();
// Do NOT call mock_all_auths() — test auth failures
let admin = Address::generate(&env);
let attacker = Address::generate(&env);
let contract_id = env.register(MyContract, (&admin,));
let client = MyContractClient::new(&env, &contract_id);
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
client.admin_only(&attacker); // attacker has no auth
}));
assert!(result.is_err());
}
#[test]
fn test_auth_passes() {
let env = Env::default();
env.mock_all_auths();
let admin = Address::generate(&env);
let contract_id = env.register(MyContract, (&admin,));
let client = MyContractClient::new(&env, &contract_id);
client.admin_only(&admin); // should not panic
}Pattern 3: Event Assertions
#[test]
fn test_events_emitted() {
let env = Env::default();
env.mock_all_auths();
let admin = Address::generate(&env);
let contract_id = env.register(MyContract, (&admin,));
let client = MyContractClient::new(&env, &contract_id);
client.do_thing();
let events = env.events().all();
assert!(!events.is_empty());
let (event_contract, topics, data) = &events[0];
assert_eq!(*event_contract, contract_id);
// topics[0] is the event type symbol
assert_eq!(topics.get(0).unwrap(), Symbol::new(&env, "DONE"));
}Pattern 4: Error / Panic Testing
#[test]
#[should_panic(expected = "HostError")]
fn test_rejects_invalid_input() {
let env = Env::default();
env.mock_all_auths();
let (_, _, client) = setup();
client.try_v1(); // intentionally bad input
}Pattern 5: Contract Storage / TTL Testing
#[test]
fn test_storage_ttl() {
let env = Env::default();
env.mock_all_auths();
let (_, _, client) = setup();
let key = DataKey::Counter;
let ttl = env.storage().instance().get_ttl(&key);
assert!(ttl > 0);
// Extend TTL
client.touch();
let new_ttl = env.storage().instance().get_ttl(&key);
assert!(new_ttl >= ttl);
}Pattern 6: Cross-Contract Call Testing
#[test]
fn test_cross_contract() {
let env = Env::default();
env.mock_all_auths();
let admin = Address::generate(&env);
let token_id = env.register(Token, (&admin, String::from_str(&env, "TKN"), Symbol::new(&env, "TKN"), 7u32));
let aggregator_id = env.register(Aggregator, (&admin,));
let token = TokenClient::new(&env, &token_id);
let aggregator = AggregatorClient::new(&env, &aggregator_id);
token.mint(&admin, &1000);
aggregator.deposit(&admin, &token_id, &500);
assert_eq!(token.balance(&admin), 500);
assert_eq!(token.balance(&aggregator_id), 500);
}Pattern 7: Snapshot / Rollback Testing
#[test]
fn test_rollback_on_failure() {
let env = Env::default();
env.mock_all_auths();
let (_, admin, client) = setup();
let snapshot = env.clone();
// Try an operation that should fail
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
client.fail_operation(&admin);
}));
// Restore snapshot and verify state unchanged
let env = snapshot;
// env.restore() is not a direct API, use the snapshot approach
}Build & Test Commands
# Build
cd contracts/my-contract
cargo build --release --target wasm32v1-none
# Run all tests
cargo test
# Run a specific test
cargo test test_transfer
# Run tests with output
cargo test -- --nocapture
# Check WASM size
wasm-strip target/wasm32v1-none/release/my_contract.wasm -o my_contract.optimized.wasm
ls -lh my_contract.optimized.wasm
# Manual deploy
stellar contract deploy \
--wasm target/wasm32v1-none/release/my_contract.wasm \
--source-account deployer \
--network testnetTests Must Pass First — The Gate
Deployment is gated on all tests passing. If any test fails, the agent aborts and reports which tests failed. Only green tests → deploy.
cargo test → FAIL → fix & retry
→ PASS → deployAuto-Deploy (First Time)
If no prior contract has been deployed on the target network, the contracts agent auto-deploys without prompting. This is the first-deploy rule:
- Agent checks
data/deployments/testnet.json - If missing → first deploy → silent auto-deploy
- If exists → ask user before deploying
Record & Env Update
Every deploy must record the contract ID in two places:
# data/deployments/<network>.json — deployment tracker
{
"network": "testnet",
"deployer": "deployer",
"contracts": [
{
"name": "my_contract",
"contract_id": "CA...",
"wasm_hash": "<sha256>",
"deployed_at": "2026-07-29T12:00:00Z"
}
]
}
# .env — for frontend/backend reference
NEXT_PUBLIC_MY_CONTRACT_CONTRACT_ID=CA...Helper Script
./scripts/deploy-contract.sh \
target/wasm32v1-none/release/my_contract.wasm \
my_contract \
testnetThis script handles build check, deploy, tracker update, and .env update in one step.
Strict Rules
- Always run
cargo testbefore deploying - Test auth failures explicitly — do not rely on
mock_all_auths()alone - Test both happy path and error paths
- Verify events are emitted with correct topics and data
- Check TTL extension on persistent storage writes
- Never deploy with failing tests — deploy is gated on
cargo testpassing 100% - Always record deployed contract IDs in
data/deployments/<network>.jsonand.env - First deployment on a network auto-deploys (no prior deploy file found)
- Run
cargo testbeforecargo build --releaseto fail fast on test failures
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

