Skip to main content

SDK API (Essentials)

Key classes and methods from the TypeScript SDK.

AccountManager

const manager = new AccountManager(config: AccountConfig, provider?: 'google' | string);
  • googleClientId (required)
  • googleClientSecret?
  • aztecRpcUrl? (default http://localhost:8080)
  • redirectUri?

Methods

  • getAuthUrl(): string — build provider auth URL.
  • exchangeCode(code): Promise<AuthResult> — swap OAuth code for JWT/tokens.
  • accountExistsForIdentity(authResult): Promise<AztecAddress | null> — lookup by derived account ID.
  • createAccount(authResult): Promise<AccountInfo> — derive account ID, generate proof, deploy contract, set session owner.
  • recoverAccount(authResult, contractAddress): Promise<AccountInfo> — verify identity and set a new session owner on an existing contract.

Returns

AccountInfo:

{
address: AztecAddress;
accountId: Field;
sessionOwner: string;
txHash: string;
}

GoogleProvider (low-level)

  • getAuthUrl()
  • exchangeCode(code)
  • parseJWT(idToken)
  • getPublicKey()

ProofGenerator (low-level)

const proof = await generator.generateProof({
jwt,
jwtLen: jwt.length,
googlePublicKey,
accountId,
sessionOwnerNonce,
});

Returns { proof, publicInputs: [accountId, nonce] }.

AztecClient (low-level)

  • getAccountAddress(accountId)
  • deployContract(contractArtifact, [accountId])
  • sendTransaction(tx)

Types

type AuthResult = {
idToken: string;
accessToken?: string;
refreshToken?: string;
expiresAt?: number;
};

type AccountConfig = {
googleClientId: string;
googleClientSecret?: string;
aztecRpcUrl?: string;
redirectUri?: string;
};

Migration notes (v0.0.x → v0.1.0)

  • exchangeCode now returns AuthResult.
  • Proof generation is async.
  • The SDK uses ES modules.