This directory contains practical examples for integrating with the SVMP2P platform.
examples/
├── basic-trading/
│ ├── create-offer.ts
│ ├── accept-offer.ts
│ └── complete-trade.ts
├── dispute-resolution/
│ ├── open-dispute.ts
│ ├── submit-evidence.ts
│ └── juror-voting.ts
├── reward-system/
│ ├── setup-rewards.ts
│ ├── claim-rewards.ts
│ └── reward-tracking.ts
├── wallet-integration/
│ ├── wallet-connection.ts
│ ├── transaction-signing.ts
│ └── error-handling.ts
├── advanced/
│ ├── batch-operations.ts
│ ├── multi-network.ts
│ └── cross-program-invocation.ts
└── utils/
├── program-setup.ts
├── account-helpers.ts
└── error-recovery.ts
-
Install Dependencies:
npm install @coral-xyz/anchor @solana/web3.js @solana/wallet-adapter-react
-
Environment Setup:
// Set up your environment variables export const PROGRAM_ID = "FKkTQLgBE9vDZqgXKWrXZfAv5HgCQdsjDZDzPfJosPt9"; export const RPC_ENDPOINT = "https://api.devnet.solana.com";
-
Basic Program Setup:
import { Program, AnchorProvider } from '@coral-xyz/anchor'; import { Connection } from '@solana/web3.js'; const connection = new Connection(RPC_ENDPOINT); const provider = new AnchorProvider(connection, wallet, {}); const program = new Program(IDL, PROGRAM_ID, provider);
- Complete trade lifecycle from offer creation to completion
- Error handling and validation
- Account management and PDA derivation
- Opening disputes with proper evidence
- Juror assignment and voting processes
- Verdict execution and fund distribution
- Setting up reward tokens and user accounts
- Earning rewards through trading and governance
- Claiming and managing reward balances
- Secure wallet connection patterns
- Transaction building and signing
- Multi-wallet support and fallbacks
- Batch transaction processing
- Cross-program invocations
- Multi-network deployment strategies
- Testing: All examples include test scenarios for devnet
- Error Handling: Comprehensive error handling patterns
- Security: Best practices for secure operations
- Performance: Optimized transaction patterns
When adding new examples:
- Follow the existing directory structure
- Include comprehensive error handling
- Add JSDoc comments for all functions
- Provide test cases with sample data
- Update this README with new examples
For more detailed documentation, see the API reference and wallet operations guide.