Privacy API Reference

Privacy API Reference

APIs for integrating with Macro's privacy features.

Privacy Profiles API

Detect and respect Privacy Profiles:

macro_getCurrentProfile

Get information about active profile.

const profile = await ethereum.request({
  method: 'macro_getCurrentProfile'
});

// Returns:
// {
//   name: 'Work',
//   id: 'profile_xyz',
//   color: '#3B82F6',
//   type: 'work' // 'work' | 'degen' | 'anon' | 'custom'
// }

Use case: Adapt UI based on profile type.

VPN API

Check and suggest VPN usage:

macro_getVPNStatus

const status = await ethereum.request({
  method: 'macro_getVPNStatus'
});

// Returns:
// {
//   enabled: true,
//   connected: true,
//   exitRegion: 'DE',
//   entryNode: 'node-us-1',
//   exitNode: 'node-de-3',
//   routeHealth: 'good',
//   latency: 52,
//   hops: 3
// }

macro_suggestVPN

Suggest user enable VPN (doesn't force).

await ethereum.request({
  method: 'macro_suggestVPN',
  params: [{
    reason: 'For privacy when interacting with this dApp',
    required: false // If true, blocks interaction until VPN enabled
  }]
});

User sees: Non-intrusive suggestion to enable VPN.

Signing Policy API

Integrate with signing sandbox:

macro_getSigningPolicy

Get current policy for your dApp.

const policy = await ethereum.request({
  method: 'macro_getSigningPolicy',
  params: [window.location.origin]
});

// Returns:
// {
//   maxApproval: '1000000000000000000',
//   maxGasPrice: '100000000000',
//   allowedFunctions: ['swap', 'deposit'],
//   blockedFunctions: [],
//   requiresHardwareWallet: false,
//   riskLevel: 'medium' // 'low' | 'medium' | 'high'
// }

macro_requestTransactionPreview

Request transaction preview before sending.

const preview = await ethereum.request({
  method: 'macro_requestTransactionPreview',
  params: [{
    from: '0x...',
    to: '0x...',
    data: '0x...',
    value: '0x...'
  }]
});

// Returns:
// {
//   decodedFunction: 'swapExactETHForTokens',
//   parameters: {
//     amountOutMin: '...',
//     path: ['0xC02...', '0x6B1...'],
//     to: '0x...',
//     deadline: '...'
//   },
//   riskAssessment: 'low',
//   estimatedGas: '150000',
//   willApprove: true // Based on current policy
// }

Use case: Show preview in your UI before requesting signature.

Privacy Mixer API

Integrate mixer functionality:

macro_getMixerStatus

Check mixer availability.

const status = await ethereum.request({
  method: 'macro_getMixerStatus'
});

// Returns:
// {
//   available: true,
//   supportedTokens: ['ETH', '0x6B17...'], // Token addresses
//   minimumAmount: '100000000000000000', // 0.1 ETH
//   anonymitySetSize: 1247, // Current pool size
//   averageDelay: 2400 // seconds
// }

macro_estimateMixerFee

Estimate mixing fee.

const fee = await ethereum.request({
  method: 'macro_estimateMixerFee',
  params: [{
    token: 'ETH',
    amount: '1000000000000000000'
  }]
});

// Returns:
// {
//   fee: '10000000000000000', // 0.01 ETH
//   feePercentage: 1.0
// }

Private Swap API

MEV-protected swaps:

macro_estimatePrivateSwap

Estimate swap outcome.

const estimate = await ethereum.request({
  method: 'macro_estimatePrivateSwap',
  params: [{
    fromToken: 'ETH',
    toToken: '0x6B17...',
    amount: '1000000000000000000'
  }]
});

// Returns:
// {
//   estimatedOutput: '2547...',
//   priceImpact: 0.23,
//   route: ['ETH', 'USDC', 'DAI'],
//   fee: '3000000000000000' // 0.003 ETH
// }

Best Practices

When using privacy APIs:

  • Request privacy features, don't require them

  • Explain why privacy features benefit the user

  • Provide graceful fallback if feature unavailable

  • Respect user's privacy settings

  • Don't fingerprint or track users who use privacy features


Performance Optimization Guide

Last updated