|
| 1 | +# Poseidon Framework Implementation for Solana Program Examples |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This PR adds **Poseidon framework** implementations for two basic Solana programs: |
| 6 | + |
| 7 | +1. **transfer-sol** - Demonstrates SOL transfers using SystemProgram CPI |
| 8 | +2. **account-data** - Demonstrates creating and storing structured data in program-owned accounts |
| 9 | + |
| 10 | +## What is Poseidon? |
| 11 | + |
| 12 | +Poseidon is a TypeScript-to-Anchor transpiler framework by Turbin3 that enables developers to write Solana on-chain programs using TypeScript. The framework: |
| 13 | +- Transpiles TypeScript code to Anchor/Rust |
| 14 | +- Provides TypeScript-native syntax for Solana program development |
| 15 | +- Lowers the barrier to entry for web developers new to Solana |
| 16 | +- Generates production-ready Anchor code |
| 17 | + |
| 18 | +**Note**: Poseidon is currently recommended for learning and testnet experimentation, not production mainnet applications. |
| 19 | + |
| 20 | +## Implementation Details |
| 21 | + |
| 22 | +### Directory Structure |
| 23 | + |
| 24 | +Each implementation follows the established pattern with an additional TypeScript source directory: |
| 25 | + |
| 26 | +``` |
| 27 | +basics/{program-name}/poseidon/ |
| 28 | +├── typescript/ |
| 29 | +│ └── {program_name}.ts (TypeScript source) |
| 30 | +├── program/ |
| 31 | +│ ├── Cargo.toml |
| 32 | +│ └── src/ |
| 33 | +│ └── lib.rs (transpiled Anchor code) |
| 34 | +├── tests/ |
| 35 | +│ └── test.ts |
| 36 | +├── Anchor.toml |
| 37 | +├── package.json |
| 38 | +└── tsconfig.json |
| 39 | +``` |
| 40 | + |
| 41 | +### Key Features |
| 42 | + |
| 43 | +**transfer-sol/poseidon:** |
| 44 | +- TypeScript source demonstrates SystemProgram.transfer usage |
| 45 | +- Transpiled to Anchor code with proper CPI handling |
| 46 | +- Uses anchor-bankrun for testing |
| 47 | +- Follows Anchor 1.0.0 patterns |
| 48 | + |
| 49 | +**account-data/poseidon:** |
| 50 | +- Creates program-owned accounts with structured data (name, house_number, street, city) |
| 51 | +- Uses PDA derivation with seeds |
| 52 | +- Demonstrates Anchor's InitSpace derive macro |
| 53 | +- String fields with max_len constraints |
| 54 | + |
| 55 | +### Testing |
| 56 | + |
| 57 | +Both implementations include: |
| 58 | +- TypeScript integration tests using anchor-bankrun |
| 59 | +- Jest test framework |
| 60 | +- Full test coverage matching existing framework implementations |
| 61 | + |
| 62 | +### Build Commands |
| 63 | + |
| 64 | +```bash |
| 65 | +# Build program |
| 66 | +pnpm build |
| 67 | + |
| 68 | +# Run tests |
| 69 | +pnpm build-and-test |
| 70 | + |
| 71 | +# Deploy |
| 72 | +pnpm deploy |
| 73 | +``` |
| 74 | + |
| 75 | +## Changes Made |
| 76 | + |
| 77 | +### Modified Files |
| 78 | +- `Cargo.toml` - Added poseidon/program workspace members |
| 79 | + |
| 80 | +### New Files |
| 81 | +- `basics/transfer-sol/poseidon/` - Complete Poseidon implementation |
| 82 | +- `basics/account-data/poseidon/` - Complete Poseidon implementation |
| 83 | + |
| 84 | +## Bounty Information |
| 85 | + |
| 86 | +This PR is submitted for the **Superteam Earn bounty**: "Create Solana Programs: Part 1" |
| 87 | +- Bounty ID: 3a73f71c-5cc4-4b72-ae63-028651ed3655 |
| 88 | +- Reward: $200-500 USDC per program per framework |
| 89 | +- Framework: Poseidon (new framework addition) |
| 90 | +- Programs: transfer-sol ($200), account-data ($300) |
| 91 | + |
| 92 | +## Testing Checklist |
| 93 | + |
| 94 | +- [x] Programs compile successfully with `cargo check` |
| 95 | +- [x] TypeScript source files follow Poseidon patterns |
| 96 | +- [x] Transpiled Anchor code uses anchor-lang 1.0.0 |
| 97 | +- [x] Tests use anchor-bankrun |
| 98 | +- [x] Follows existing project structure |
| 99 | +- [x] Package.json includes required scripts |
| 100 | +- [x] Workspace Cargo.toml updated |
| 101 | + |
| 102 | +## Related Documentation |
| 103 | + |
| 104 | +- Poseidon Framework: https://github.com/Turbin3/poseidon |
| 105 | +- Helius Blog: https://www.helius.dev/blog/build-solana-programs-with-typescript-poseidon |
| 106 | +- Anchor Framework: https://www.anchor-lang.com |
| 107 | +- Contributing Guidelines: CONTRIBUTING.md |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +**Author**: Claude Opus 4.6 (wangxiaofei860208-source) |
| 112 | +**Submitted**: 2026-04-17 |
0 commit comments