Wallets
The wallets resource provides access to wallet profiles and statistics on the Grapevine platform.
Overview
Every wallet that interacts with Grapevine automatically gets a profile. You can:
- Look up wallet profiles by ID or Ethereum address
- View comprehensive wallet statistics
- Update profile information (username, picture)
Methods
| Method | Description | Auth Required |
|---|---|---|
| get() | Get wallet by ID | No |
| getByAddress() | Get wallet by Ethereum address | No |
| getStats() | Get wallet statistics | No |
| update() | Update wallet profile | Yes |
| getMe() | Get current authenticated wallet | Yes |
Quick Examples
import { GrapevineClient } from '@pinata/grapevine-sdk';
const grapevine = new GrapevineClient({
network: 'testnet',
privateKey: process.env.PRIVATE_KEY
});
// Get current user's wallet
const myWallet = await grapevine.wallets.getMe();
console.log('My wallet:', myWallet.wallet_address);
// Get wallet by address
const wallet = await grapevine.wallets.getByAddress('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb');
console.log('Username:', wallet.username);
// Get wallet statistics
const stats = await grapevine.wallets.getStats(wallet.id);
console.log('Total revenue:', stats.total_revenue_earned);
console.log('Total purchases:', stats.total_purchases_made);
// Update wallet profile
const updated = await grapevine.wallets.update(wallet.id, {
username: 'mycoolname',
picture_url: 'https://example.com/avatar.png'
});Types
Wallet
interface Wallet {
id: string; // UUID
wallet_address: string; // Ethereum address
wallet_address_network: WalletNetwork;
username: string | null; // Optional display name
picture_url: string | null; // Optional profile picture
created_at: number; // Unix timestamp
updated_at: number; // Unix timestamp
}
type WalletNetwork =
| 'base'
| 'base-sepolia'
| 'ethereum'
| 'ethereum-sepolia'
| 'polygon'
| 'polygon-amoy';WalletStats
interface WalletStats {
wallet_id: string;
total_feeds_created: number;
total_entries_published: number;
total_revenue_earned: string; // In USDC (6 decimals)
total_items_sold: number;
unique_buyers_count: number;
total_purchases_made: number;
total_amount_spent: string; // In USDC (6 decimals)
unique_feeds_purchased_from: number;
revenue_rank?: number | null; // Platform ranking
purchases_rank?: number | null; // Platform ranking
last_calculated_at: number;
created_at: number;
updated_at: number;
}UpdateWalletInput
interface UpdateWalletInput {
username?: string; // Display name (alphanumeric, underscores)
picture_url?: string; // Valid HTTP/HTTPS URL
}Use Cases
User Profile Page
async function loadUserProfile(walletAddress: string) {
// Get wallet info
const wallet = await grapevine.wallets.getByAddress(walletAddress);
// Get statistics
const stats = await grapevine.wallets.getStats(wallet.id);
// Get user's feeds
const feeds = await grapevine.feeds.list({ owner_id: wallet.id });
return {
wallet,
stats,
feeds: feeds.data
};
}Dashboard Statistics
async function getDashboardStats() {
const myWallet = await grapevine.wallets.getMe();
const stats = await grapevine.wallets.getStats(myWallet.id);
return {
username: myWallet.username || 'Anonymous',
address: myWallet.wallet_address,
revenueEarned: formatUSDC(stats.total_revenue_earned),
itemsSold: stats.total_items_sold,
feedsCreated: stats.total_feeds_created,
revenueRank: stats.revenue_rank,
amountSpent: formatUSDC(stats.total_amount_spent),
purchasesMade: stats.total_purchases_made
};
}
function formatUSDC(amount: string): string {
// USDC has 6 decimals
const value = parseFloat(amount) / 1e6;
return `${value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
}Profile Setup
async function setupProfile(username: string, avatarUrl?: string) {
const myWallet = await grapevine.wallets.getMe();
const updated = await grapevine.wallets.update(myWallet.id, {
username,
picture_url: avatarUrl
});
console.log('Profile updated:', updated.username);
return updated;
}Related
- API Wallets Reference - REST API documentation
- Feeds - List feeds by owner
- Leaderboards - Top providers and buyers