import {
PrivacyBoost,
PrivacyBoostConfig,
KeySource,
AuthResult,
SdkError,
} from '@sunnyside-io/privacy-boost-react-native';
const config = PrivacyBoostConfig.create({
serverUrl: 'https://optimism.sepolia.privacyboost.io',
chainId: undefined, // discovered from server
shieldContractAddress: undefined, // discovered from server
wethContractAddress: '0x4200000000000000000000000000000000000006',
teePublicKey: undefined,
appId: 'app_abc123xyz',
persistenceStorage: undefined,
persistenceUnlock: undefined,
});
const sdk = new PrivacyBoost(config);
// Authenticate with a WalletDelegate you implement
const result = await sdk.authenticate(
myWalletDelegate,
new KeySource.WalletDerived(),
undefined,
);
if (AuthResult.Authenticated.instanceOf(result)) {
console.log('Privacy address:', result.loginResult.privacyAddress);
} else if (AuthResult.CredentialRequired.instanceOf(result)) {
// Prompt user for PIN/biometric, then call sdk.submitCredential(...)
} else if (AuthResult.MnemonicGenerated.instanceOf(result)) {
// First-time user — display mnemonic, then call sdk.proceedAfterMnemonic(...)
} else if (AuthResult.RecoveryRequired.instanceOf(result)) {
// Vault is in a recovery state — see Authentication concepts
}
// Shield 1 ETH-equivalent of WETH
const amount = sdk.parseAmount('1.0', 18);
const shielded = await sdk.shield(
'0x4200000000000000000000000000000000000006',
amount,
);
console.log('Shield tx:', shielded.txHash);