Token Integration
Integrate PRIV token into your application, wallet, or exchange.
Basic Integration
Add PRIV to Your Application
typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { getAccount, getAssociatedTokenAddress } from '@solana/spl-token';
// PRIV Token Mint
const PRIV_MINT = new PublicKey('EFy9cEMheBYyrH1HYNonDnKgNzU9tkwiMUMfGNqK4Jua');
// Token metadata
const PRIV_TOKEN = {
symbol: 'PRIV',
name: 'PrivChain',
decimals: 9,
mint: PRIV_MINT,
logoURI: 'https://privchain.io/logo.png'
};Get User Balance
typescript
async function getPrivBalance(
connection: Connection,
userPublicKey: PublicKey
): Promise<number> {
const tokenAccount = await getAssociatedTokenAddress(
PRIV_MINT,
userPublicKey
);
try {
const account = await getAccount(connection, tokenAccount);
return Number(account.amount) / 10 ** 9; // Convert from raw to PRIV
} catch {
return 0; // No token account = 0 balance
}
}
// Usage
const balance = await getPrivBalance(connection, userWallet);
console.log(`Balance: ${balance} PRIV`);Transfer PRIV
typescript
import {
createTransferInstruction,
getAssociatedTokenAddress,
createAssociatedTokenAccountInstruction
} from '@solana/spl-token';
import { Transaction } from '@solana/web3.js';
async function transferPriv(
connection: Connection,
from: Keypair,
to: PublicKey,
amount: number
): Promise<string> {
const fromAta = await getAssociatedTokenAddress(PRIV_MINT, from.publicKey);
const toAta = await getAssociatedTokenAddress(PRIV_MINT, to);
const tx = new Transaction();
// Create recipient's token account if needed
const toAccount = await connection.getAccountInfo(toAta);
if (!toAccount) {
tx.add(
createAssociatedTokenAccountInstruction(
from.publicKey, // payer
toAta, // ata
to, // owner
PRIV_MINT // mint
)
);
}
// Add transfer instruction
tx.add(
createTransferInstruction(
fromAta,
toAta,
from.publicKey,
BigInt(amount * 10 ** 9) // Convert to raw amount
)
);
const signature = await connection.sendTransaction(tx, [from]);
await connection.confirmTransaction(signature);
return signature;
}Wallet Integration
Add to Token List
For wallet providers, add PRIV to your token registry:
json
{
"chainId": 101,
"address": "EFy9cEMheBYyrH1HYNonDnKgNzU9tkwiMUMfGNqK4Jua",
"symbol": "PRIV",
"name": "PrivChain",
"decimals": 9,
"logoURI": "https://privchain.io/logo.png",
"tags": ["privacy", "ai-agents", "defi"],
"extensions": {
"website": "https://privchain.io",
"discord": "https://discord.gg/GbNvjCSN",
"coingeckoId": "privchain"
}
}Phantom/Solflare Custom Token
Users can add PRIV manually:
- Open wallet settings
- Select "Add Custom Token"
- Paste:
EFy9cEMheBYyrH1HYNonDnKgNzU9tkwiMUMfGNqK4Jua
Exchange Integration
Deposit Detection
Monitor for incoming PRIV deposits:
typescript
import { Connection, PublicKey } from '@solana/web3.js';
async function watchDeposits(
connection: Connection,
exchangeTokenAccount: PublicKey
) {
// Subscribe to account changes
const subscriptionId = connection.onAccountChange(
exchangeTokenAccount,
async (accountInfo) => {
const data = accountInfo.data;
// Parse SPL token account data
const amount = data.readBigUInt64LE(64);
console.log('New balance:', Number(amount) / 10 ** 9);
},
'confirmed'
);
return subscriptionId;
}
// Or poll for transactions
async function getRecentDeposits(
connection: Connection,
tokenAccount: PublicKey,
limit = 100
): Promise<any[]> {
const signatures = await connection.getSignaturesForAddress(
tokenAccount,
{ limit }
);
const deposits = [];
for (const sig of signatures) {
const tx = await connection.getParsedTransaction(sig.signature);
// Parse and filter for deposits
deposits.push(tx);
}
return deposits;
}Withdrawal Processing
typescript
async function processWithdrawal(
connection: Connection,
hotWallet: Keypair,
userAddress: string,
amount: number
): Promise<string> {
// Validate amount
if (amount < 1) {
throw new Error('Minimum withdrawal: 1 PRIV');
}
// Check hot wallet balance
const balance = await getPrivBalance(connection, hotWallet.publicKey);
if (balance < amount) {
throw new Error('Insufficient hot wallet balance');
}
// Execute transfer
const recipient = new PublicKey(userAddress);
const signature = await transferPriv(connection, hotWallet, recipient, amount);
return signature;
}Recommended Confirmations
| Deposit Size | Confirmations |
|---|---|
| < 1,000 PRIV | confirmed (~400ms) |
| 1,000-10,000 PRIV | 10 confirmations (~4s) |
| > 10,000 PRIV | finalized (~15s) |
DeFi Integration
Jupiter Aggregator
typescript
import { Jupiter } from '@jup-ag/core';
const jupiter = await Jupiter.load({
connection,
cluster: 'mainnet-beta',
user: userPublicKey
});
// Get swap routes
const routes = await jupiter.computeRoutes({
inputMint: new PublicKey('So11111111111111111111111111111111111111112'), // SOL
outputMint: PRIV_MINT,
amount: 1_000_000_000, // 1 SOL in lamports
slippageBps: 50 // 0.5%
});
// Execute best route
const { execute } = await jupiter.exchange({ routeInfo: routes.routesInfos[0] });
const result = await execute();Raydium Pools
typescript
// For Raydium AMM integration
// See: https://raydium.io/developersPrice Feeds
Pyth Oracle
typescript
import { PythConnection, getPythProgramKeyForCluster } from '@pythnetwork/client';
const pythConnection = new PythConnection(
connection,
getPythProgramKeyForCluster('mainnet-beta')
);
// Subscribe to PRIV/USD price
const priceAccountKey = new PublicKey('PRIV_PYTH_FEED_ADDRESS'); // TBA
pythConnection.onPriceChange(priceAccountKey, (price) => {
console.log(`PRIV/USD: $${price.price}`);
console.log(`Confidence: ±$${price.confidence}`);
});Birdeye API
typescript
// Get price from Birdeye
async function getPrivPrice(): Promise<number> {
const response = await fetch(
'https://public-api.birdeye.so/public/price?address=EFy9cEMheBYyrH1HYNonDnKgNzU9tkwiMUMfGNqK4Jua',
{ headers: { 'X-API-KEY': process.env.BIRDEYE_API_KEY } }
);
const data = await response.json();
return data.data.value;
}Testing
Devnet Testing
typescript
// Use devnet for testing (when available)
const connection = new Connection('https://api.devnet.solana.com');
// Request airdrop for SOL fees
await connection.requestAirdrop(wallet.publicKey, 1_000_000_000);Mainnet Testing
For mainnet integration testing:
- Use small amounts (< 10 PRIV)
- Test all edge cases
- Verify transaction parsing
- Test timeout handling
Support
Need help with integration?