wallets.getMe()
Get the wallet profile for the currently authenticated user. This is a convenience method that looks up the wallet by the configured wallet address.
Signature
wallets.getMe(): Promise<Wallet>Parameters
None - uses the wallet address from the authenticated client.
Returns
- Type:
Promise<Wallet>
interface Wallet {
id: string;
wallet_address: string;
wallet_address_network: WalletNetwork;
username: string | null;
picture_url: string | null;
created_at: number;
updated_at: number;
}Usage
Basic Example
const grapevine = new GrapevineClient({
network: 'testnet',
privateKey: process.env.PRIVATE_KEY
});
const myWallet = await grapevine.wallets.getMe();
console.log('My wallet ID:', myWallet.id);
console.log('My address:', myWallet.wallet_address);
console.log('My username:', myWallet.username || 'Not set');Get Full Profile with Stats
async function getMyFullProfile() {
const wallet = await grapevine.wallets.getMe();
const stats = await grapevine.wallets.getStats(wallet.id);
return {
id: wallet.id,
address: wallet.wallet_address,
username: wallet.username,
picture: wallet.picture_url,
memberSince: new Date(wallet.created_at * 1000),
stats: {
feedsCreated: stats.total_feeds_created,
entriesPublished: stats.total_entries_published,
revenue: stats.total_revenue_earned,
purchases: stats.total_purchases_made
}
};
}With Wagmi
import { useGrapevine } from '@pinata/grapevine-sdk/react';
import { useWalletClient } from 'wagmi';
function MyProfile() {
const { data: walletClient } = useWalletClient();
const grapevine = useGrapevine({ walletClient, network: 'testnet' });
const [profile, setProfile] = useState(null);
useEffect(() => {
if (grapevine?.hasWallet()) {
grapevine.wallets.getMe()
.then(setProfile)
.catch(console.error);
}
}, [grapevine]);
if (!profile) return <div>Loading profile...</div>;
return (
<div>
<h2>{profile.username || 'Anonymous'}</h2>
<p>Address: {profile.wallet_address}</p>
{profile.picture_url && (
<img src={profile.picture_url} alt="Profile" />
)}
</div>
);
}Check if Profile Exists
async function ensureProfileExists() {
try {
const wallet = await grapevine.wallets.getMe();
console.log('Profile exists:', wallet.id);
return wallet;
} catch (error) {
if (error.message.includes('404')) {
console.log('Profile will be created on first action');
return null;
}
throw error;
}
}Initialize and Update Profile
async function initializeProfile(username: string) {
// Get current wallet
const wallet = await grapevine.wallets.getMe();
// Check if username is set
if (!wallet.username) {
console.log('Setting up profile...');
const updated = await grapevine.wallets.update(wallet.id, {
username
});
console.log('Profile created:', updated.username);
return updated;
}
console.log('Profile already set up:', wallet.username);
return wallet;
}Error Handling
try {
const wallet = await grapevine.wallets.getMe();
console.log('My wallet:', wallet);
} catch (error) {
if (error.code === 'AUTH_NO_WALLET') {
console.error('No wallet configured. Initialize with privateKey or walletAdapter.');
console.error('Suggestion:', error.suggestion);
} else if (error.message.includes('404')) {
console.error('Wallet not found on platform');
} else {
console.error('Error:', error.message);
}
}Notes
- Authentication: Required - wallet must be configured
- Throws: If no wallet is configured (
AUTH_NO_WALLETerror) - Under the Hood: Uses
getWalletAddress()andgetByAddress()internally - Auto-Created: Wallets are created automatically on first platform interaction
Related
- wallets.getByAddress() - Get any wallet by address
- wallets.update() - Update profile
- wallets.getStats() - Get wallet statistics
- Configuration - Setting up authentication