{"id":30727640,"url":"https://github.com/topsecretagent007/token-presale-smart-contract","last_synced_at":"2025-09-03T14:09:08.500Z","repository":{"id":310959675,"uuid":"1026404074","full_name":"topsecretagent007/token-presale-smart-contract","owner":"topsecretagent007","description":"A fully working Solana token presale smart contract and website, inspired by Pump.fun. The project is complete and ready for testing or deployment.","archived":false,"fork":false,"pushed_at":"2025-08-21T07:42:36.000Z","size":46,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-21T09:41:29.250Z","etag":null,"topics":["presale","presale-smart-contract","pumpdotfun","solana","token"],"latest_commit_sha":null,"homepage":"https://wild-go-presale-pumpfun-frontend.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/topsecretagent007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-25T20:36:55.000Z","updated_at":"2025-08-21T07:42:39.000Z","dependencies_parsed_at":"2025-08-21T09:42:57.795Z","dependency_job_id":"710402d1-4b89-4ec6-85af-aba70a819379","html_url":"https://github.com/topsecretagent007/token-presale-smart-contract","commit_stats":null,"previous_names":["topsecretagent007/token-presale-smart-contract"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/topsecretagent007/token-presale-smart-contract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topsecretagent007%2Ftoken-presale-smart-contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topsecretagent007%2Ftoken-presale-smart-contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topsecretagent007%2Ftoken-presale-smart-contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topsecretagent007%2Ftoken-presale-smart-contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/topsecretagent007","download_url":"https://codeload.github.com/topsecretagent007/token-presale-smart-contract/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topsecretagent007%2Ftoken-presale-smart-contract/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273453710,"owners_count":25108473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["presale","presale-smart-contract","pumpdotfun","solana","token"],"created_at":"2025-09-03T14:09:06.564Z","updated_at":"2025-09-03T14:09:08.495Z","avatar_url":"https://github.com/topsecretagent007.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solana Token Presale Smart Contract\n\nA complete Solana token presale smart contract built with Anchor framework. This is a full-working project that provides a robust foundation for token presales on Solana blockchain.\n\n## Features\n\n- **Multi-stage presale** with configurable pricing\n- **Dual payment support** - SOL and stable coins (USDC/USDT)\n- **Admin controls** for managing presale stages and settings\n- **User state tracking** for individual purchase history\n- **Pyth price feed integration** for real-time SOL/USD pricing\n- **Comprehensive testing suite**\n- **CLI tools** for easy deployment and management\n- **Enhanced security** with proper error handling and validation\n- **Robust stage management** with bounds checking and validation\n\n## Recent Improvements\n\n### Security Enhancements\n- **Removed unsafe `unwrap()` calls** that could cause panics\n- **Added proper error handling** for price feed operations\n- **Improved stage indexing logic** with bounds checking\n- **Enhanced validation** for stage transitions and configuration\n\n### Code Quality Improvements\n- **Better error messages** for debugging and user experience\n- **Consistent stage management** across all purchase functions\n- **Added validation functions** for stage configuration\n- **Improved state management** with helper methods\n\n### Error Handling\n- Added `StalePriceFeed` error for outdated price data\n- Added `PresaleAlreadyEnded` error for better state management\n- Improved validation in initialization and purchase functions\n\n## Contact Information\n\n- **Telegram**: [@topsecretagent_007](https://t.me/topsecretagent_007)\n- **GitHub**: [https://github.com/topsecretagent007/token-presale-smart-contract](https://github.com/topsecretagent007/token-presale-smart-contract)\n- **Test Project**: [https://wild-go-presale-pumpfun-frontend.vercel.app/](https://wild-go-presale-pumpfun-frontend.vercel.app/)\n\n## Prerequisites\n\n### Install Dependencies\n\n- Install `node` and `yarn`\n- Install `rust`, `solana` and `anchor`\n\n    https://www.anchor-lang.com/docs/installation\n\n## How to Deploy\n\n### 1. Clone and Setup\n\n```bash\ngit clone https://github.com/topsecretagent007/token-presale-smart-contract\ncd token-presale-smart-contract\nyarn install\n```\n\n### 2. Build the Program\n\n```bash\nanchor build\n```\n\n### 3. Get Program Address\n\n```bash\nsolana-keygen pubkey ./target/deploy/presale-keypair.json\n```\n\nThis will give you the program pubkey (e.g., `BE4G...5qhv`)\n\n### 4. Update Program Address\n\nUpdate the program address in these files:\n\n**In `programs/presale/src/lib.rs`:**\n```rust\ndeclare_id!(\"YOUR_PROGRAM_ID_HERE\");\n```\n\n**In `Anchor.toml`:**\n```toml\n[programs.localnet]\npresale = \"YOUR_PROGRAM_ID_HERE\"\n```\n\n### 5. Configure Provider Settings\n\nUpdate `Anchor.toml`:\n```toml\n[provider]\ncluster = \"localnet\"  # or \"devnet\", \"testnet\", \"mainnet-beta\"\nwallet = \"./admin.json\"\n```\n\n### 6. Deploy\n\n```bash\nanchor build\nanchor deploy\n```\n\n## Testing\n\n### Run Tests\n\n```bash\nanchor test\n```\n\n### Test on Devnet\n\n1. **Initialize project:**\n   ```bash\n   yarn script init -t \u003cTOKEN_ADDRESS\u003e\n   ```\n\n2. **Set DAO wallet address:**\n   ```bash\n   yarn script set-vault -v \u003cDAO_WALLET_ADDRESS\u003e\n   ```\n\n3. **Deposit tokens to the program:**\n   ```bash\n   yarn script deposit-token -t \u003cTOKEN_ADDRESS\u003e -a \u003cDEPOSIT_AMOUNT\u003e\n   ```\n\n4. **Start presale:**\n   ```bash\n   yarn script start-presale -t \u003cTOKEN_ADDRESS\u003e\n   ```\n\n5. **Set stage:**\n   ```bash\n   yarn script set-stage -s \u003cSTAGE_NUMBER\u003e\n   ```\n\n## Smart Contract Features\n\n### Presale Stages\n- 10 configurable stages with different pricing\n- Automatic stage progression based on token sales\n- Admin-controlled stage management\n\n### Payment Methods\n- **SOL payments** with real-time price feeds\n- **USDC/USDT payments** for stable coin purchases\n- Automatic price conversion and token allocation\n\n### Admin Functions\n- Initialize global state\n- Set vault addresses\n- Start/pause presale\n- Manage presale stages\n- Transfer admin rights\n\n### User Functions\n- Initialize user state\n- Purchase tokens with SOL\n- Purchase tokens with stable coins\n- Track purchase history\n\n## Security Features\n\n- Admin-only functions with proper access control\n- Input validation and error handling\n- Pyth price feed integration for accurate pricing\n- Comprehensive state management\n- Secure token transfer mechanisms\n\n## Project Structure\n\n```\n├── programs/presale/src/\n│   ├── lib.rs              # Main program entry point\n│   ├── state.rs            # Account state definitions\n│   ├── error.rs            # Custom error types\n│   ├── constant.rs         # Program constants and stages\n│   ├── util.rs             # Utility functions\n│   └── instructions/       # Instruction implementations\n├── tests/                  # Test files\n├── cli/                    # Command line tools\n└── migrations/             # Deployment scripts\n```\n\n## License\n\nThis project is open source and available under the MIT License.\n\n## Support\n\nFor questions, custom requirements, or support:\n- **Telegram**: [@topsecretagent_007](https://t.me/topsecretagent_007)\n- **GitHub Issues**: [Create an issue](https://github.com/topsecretagent007/token-presale-smart-contract/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopsecretagent007%2Ftoken-presale-smart-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftopsecretagent007%2Ftoken-presale-smart-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopsecretagent007%2Ftoken-presale-smart-contract/lists"}