

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Solidity Development Guidelines for Asset Tokenization Kit23## General Principles45- **Think first, code second**: Minimize the number of lines changed and consider ripple effects across the codebase.6- **Prefer simplicity**: Fewer moving parts → fewer bugs and lower audit overhead.78## Assembly Usage910| Rule | Rationale |11|------|-----------|12| Use assembly only when essential. | Keeps code readable and auditable. |13| Assembly is mandatory for low-level external calls. | Gives full control over call parameters & return data, and saves gas. |14| Precede every assembly block with: • A brief justification (1-2 lines). • Equivalent Solidity pseudocode. | Documents intent for reviewers. |15| Mark assembly blocks memory-safe when the Solidity docs' criteria are met. | Enables compiler optimizations. |1617## Gas Optimization1819- Keep a dedicated **Gas Optimization** section in the PR description; justify any measurable gas deltas.20- Prefer `calldata` over `memory`.21- Limit storage (`sstore`, `sload`) operations; cache in memory wherever possible.22- Use forge snapshot and benchmarks:23```bash24 forge snapshot # Create gas snapshot25 forge test --gas-report # Gas report for tests26 forge test --match-test bench # Run benchmarks27```28- Large regressions must be explained.2930## Handling "Stack Too Deep"3132- **Struct hack (tests only)**: Bundle local variables into a temporary struct declared above the test.33- **Scoped blocks**: Wrap code in `{ ... }` to drop unused vars from the stack.34- **Internal helper functions**: Encapsulate logic to shorten call frames.35- **Refactor / delete unnecessary variables before other tricks**.3637## Security Checklist3839- Review every change with an adversarial mindset.40- Favor the simplest design that meets requirements.41- After coding, ask: "What new attack surface did I introduce?"42- Reject any change that raises security risk without strong justification.43- Follow SMART protocol security patterns for ERC-3643 compliance.4445## Error Handling Style4647Always use custom errors with the revert pattern instead of require statements:4849```solidity50// ❌ Don't use require with string messages51require(amount > 0, "Amount must be positive");52require(to != address(0), "Cannot transfer to zero address");5354// ✅ Do use custom errors with if/revert pattern55error AmountMustBePositive();56error CannotTransferToZeroAddress();5758if (amount == 0) revert AmountMustBePositive();59if (to == address(0)) revert CannotTransferToZeroAddress();60```6162**Benefits of custom errors**:63- More gas efficient than require strings64- Better error identification in tests and debugging65- Cleaner, more professional code66- Consistent with modern Solidity best practices6768## Testing Guidelines6970### Core Testing Principles7172**Every feature or change MUST have comprehensive tests before creating a PR**. This is non-negotiable for maintaining code quality and preventing regressions.7374### When to Write Tests7576- **New Features**: Write tests that demonstrate the complete flow and all edge cases77- **Bug Fixes**: Add tests that reproduce the bug and verify the fix78- **Refactoring**: Ensure existing tests still pass; add new ones if behavior changes79- **Gas Optimizations**: Include benchmark tests showing before/after comparisons8081### Types of Required Tests8283**Unit Tests**:84- Write clear unit tests that demonstrate the general flow of your feature/change85- Test both happy paths and failure cases86- Include edge cases and boundary conditions87- Test revert conditions with specific error messages8889**Fuzz Tests**:90- **Fuzz tests are highly encouraged** for all new functionality91- Use Foundry's built-in fuzzing capabilities92- Apply random arguments to thoroughly test your implementation9394Example fuzz test pattern:95```solidity96function testFuzz_myFeature(uint256 amount, address user) public {97 // Bound inputs to reasonable ranges98 amount = bound(amount, 1, type(uint128).max);99 vm.assume(user != address(0));100101 // Test your feature with random inputs102 myContract.myFeature(amount, user);103104 // Assert expected outcomes105 assertEq(myContract.balanceOf(user), amount);106}107```108109### Testing Checklist Before PR110111Before opening any PR, ensure:112- [ ] All new functions have unit tests113- [ ] Critical paths have fuzz tests with random inputs114- [ ] Edge cases and revert scenarios are tested115- [ ] Gas benchmarks are included for optimizations116- [ ] All tests pass: `forge test`117- [ ] No test coverage regression: `forge coverage`118119## Verification Workflow120121```bash122forge build # compile123forge test # full test suite124forge snapshot # gas snapshot125forge test --match-test bench # run benchmarks126forge test --gas-report # gas usage report127forge coverage # code coverage128```129130## Asset Tokenization Kit Specific Guidelines131132### Contract Structure133- Follow the SMART protocol patterns for all asset implementations134- Use the established factory pattern (`ATKBondFactory`, `ATKEquityFactory`, etc.)135- Implement proper ERC-3643 compliance for all tokenized assets136- Utilize the extension system (`SMARTBurnable`, `SMARTCapped`, etc.) for modularity137138### Testing Assets139When testing tokenized assets:140- Test compliance features (identity registry, claim topics)141- Test factory deployment patterns142- Test proxy upgradeability143- Test all extensions used by the asset144- Include integration tests with the compliance system145146### Common Patterns147- Use `AccessControl` for role-based permissions148- Implement `Pausable` for emergency stops149- Follow ERC-3643 for identity and compliance150- Use proxy patterns for upgradeability151152### Available Tools153154The Asset Tokenization Kit includes:155- Foundry for contract compilation and testing156- OpenZeppelin contracts for base implementations157- SMART protocol contracts for compliance158- Hardhat for additional tooling support159160### Project Structure161162- `contracts/`: Smart contract source files163 - `assets/`: Asset factories and implementations164 - `smart/`: SMART protocol base contracts and extensions165 - `system/`: Compliance and registry contracts166 - `test/`: Test contracts and utilities167- `test/`: Foundry tests168- `scripts/`: Deployment and utility scripts169170## Critical Reminders171172### DO NOT173174- Use require() statements - always use custom errors175- Create contracts without comprehensive tests176- Make gas-intensive changes without benchmarks177- Skip security considerations for any change178- Use inline strings for errors179180### ALWAYS181182- Follow SMART protocol patterns183- Test all compliance features184- Measure gas impact of changes185- Consider upgradeability implications186- Use established factory patterns187- Document assembly blocks188- Run full test suite before PR189190## Continuous Learning191192- Consult SMART protocol documentation193- Review OpenZeppelin best practices194- Study ERC-3643 compliance requirements195- Learn from audited tokenization projects196197Apply these rules rigorously when working with Solidity files in the Asset Tokenization Kit.
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| settlemint/sdk.cursor/rules/commands.mdc · 15 | Cursor rules | setup | 31/100 | 14 days ago | |
| settlemint/sdk.cursor/rules/bun.mdc · 15 | Cursor rules | setupbuildtest | 73/100 | 14 days ago | |
| settlemint/sdk.cursor/rules/commits.mdc · 15 | Cursor rules | lint-formattypesgitdependencies | 48/100 | 14 days ago | |
| settlemint/sdk.cursor/rules/git-workflow.mdc · 15 | Cursor rules | gitdo-notagent-behaviour | 65/100 | 14 days ago | |
| settlemint/sdk.cursor/rules/mcp.mdc · 15 | Cursor rules | no sections | 4/100 | 14 days ago | |
| settlemint/sdk.cursor/rules/shadcn.mdc · 15 | Cursor rules | ui | 55/100 | 14 days ago | |
| settlemint/sdk.cursor/rules/typescript.mdc · 15 | Cursor rules | setuplint-formatstylearch+3 | 66/100 | 14 days ago | |
| settlemint/sdkCLAUDE.md · 15 | CLAUDE.md | setupbuildtestlint-format+10 | 96/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 14 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/settlemint-sdk-cursor-rules-solidity)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.