Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ A peer-to-peer cryptocurrency exchange platform for trading across Solana Virtua
3. Run the development server: `npm run dev`
4. Connect your wallet to start trading

## 📚 Documentation

### API Documentation
Comprehensive API and smart contract documentation is available:

- **[Complete API Reference](docs/api/README.md)** - Main API documentation hub
- **[Smart Contract API](docs/api/smart-contracts.md)** - Detailed smart contract instructions
- **[Wallet Operations](docs/api/wallet-operations.md)** - Wallet integration patterns
- **[Account Structures](docs/api/account-structures.md)** - Data structure specifications
- **[Error Codes](docs/api/error-codes.md)** - Error handling reference
- **[Transaction Flows](docs/api/transaction-flows.md)** - Implementation examples
- **[API Changelog](docs/api/CHANGELOG.md)** - Version history and updates

### Quick Start Guides
- **[Examples Directory](docs/api/examples/)** - Ready-to-use code examples
- **[Installation Guide](docs/installation-guide.md)** - Detailed setup instructions
- **[Contributing Guide](docs/contributing.md)** - Development workflow

### Developer Resources
- **Program ID**: `FKkTQLgBE9vDZqgXKWrXZfAv5HgCQdsjDZDzPfJosPt9`
- **Documentation Version**: 1.0.0
- **API Support**: Full smart contract and wallet integration coverage

## Requirements

- Node.js >= 18.17.0 (required by Next.js 14)
Expand Down
134 changes: 52 additions & 82 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,95 +224,65 @@ The Solana program consists of several key components:

## API Reference

### Frontend Components API

#### NotificationContext
```javascript
// Import
import { useNotifications } from './components/notifications/NotificationContext';

// Usage
const {
notifications,
notifySuccess,
notifyError,
markAsRead,
removeNotification
} = useNotifications();

// Methods
notifySuccess(title, message, options);
notifyError(title, message, options);
markAsRead(notificationId);
removeNotification(notificationId);
```

#### OfferCreation
```javascript
// Import
import OfferCreation from './components/OfferCreation';

// Props
<OfferCreation
onSubmit={handleSubmit}
initialValues={initialValues}
isLoading={isLoading}
/>
```

#### UserProfile
```javascript
// Import
import UserProfile from './components/UserProfile';

// Props
<UserProfile
userId={userId}
isCurrentUser={isCurrentUser}
/>
```

### Smart Contract API

#### Creating an Offer
```javascript
// Import
import { createOffer } from './api/solana';

// Usage
const result = await createOffer({
assetType: 'SOL',
amount: 1.5,
price: 100,
paymentMethods: ['USDC', 'Bank Transfer'],
terms: 'Payment must be completed within 30 minutes'
### 📚 Comprehensive API Documentation

We provide extensive API documentation for developers integrating with SVMP2P:

#### **[Complete API Documentation Hub](api/README.md)**
Central hub for all API documentation with version information and navigation.

#### Core API References
- **[Smart Contract API](api/smart-contracts.md)** - Complete instruction reference with parameters, behaviors, and examples
- **[Account Structures](api/account-structures.md)** - Detailed account specifications and TypeScript interfaces
- **[Wallet Operations](api/wallet-operations.md)** - Wallet connection, transaction signing, and security patterns
- **[Error Codes](api/error-codes.md)** - Complete error reference with recovery strategies
- **[Events](api/events.md)** - Smart contract event monitoring and handling
- **[Transaction Flows](api/transaction-flows.md)** - End-to-end implementation examples

#### Developer Resources
- **[Code Examples](api/examples/)** - Ready-to-use TypeScript examples
- **[API Changelog](api/CHANGELOG.md)** - Version history and migration guides
- **Program ID**: `FKkTQLgBE9vDZqgXKWrXZfAv5HgCQdsjDZDzPfJosPt9`
- **Current API Version**: 1.0.0

### Legacy Documentation
- **[Basic Smart Contract API](smart-contract-api.md)** - Basic API overview (see comprehensive docs above)
- **[Frontend Components](frontend-components.md)** - UI component documentation
- **[Enhanced Reward System](enhanced-reward-system.md)** - Reward system details

### Quick Start Examples

#### Creating an Offer (TypeScript)
```typescript
import { Program, BN } from '@coral-xyz/anchor';
import { createAndListOffer } from './api/examples/basic-trading/create-offer';

const result = await createAndListOffer(program, seller, {
amount: new BN(1 * LAMPORTS_PER_SOL), // 1 SOL
fiatAmount: new BN(50000), // $500.00 in cents
currency: 'USD',
paymentMethod: 'Bank transfer - Chase Bank'
});
```

#### Accepting an Offer
```javascript
// Import
import { acceptOffer } from './api/solana';
#### Wallet Connection
```typescript
import { useWallet } from '@solana/wallet-adapter-react';

// Usage
const result = await acceptOffer({
offerId: 'offer123',
buyerWallet: 'buyer_wallet_address'
});
```
const { connect, connected, publicKey } = useWallet();

#### Completing a Trade
```javascript
// Import
import { completeTrade } from './api/solana';

// Usage
const result = await completeTrade({
tradeId: 'trade123',
feedback: 'Smooth transaction, great trader!'
});
const handleConnect = async () => {
try {
await connect();
console.log('Connected:', publicKey?.toString());
} catch (error) {
console.error('Connection failed:', error);
}
};
```

For complete examples and advanced patterns, see the [examples directory](api/examples/).

## Troubleshooting

### Common Issues
Expand Down
Loading
Loading