SDK Reference

sdk.shield()

typescript
const { commitment, txHash } = await sdk.shield(
  tokenAddress,   // string — ERC-20 contract address
  amount          // bigint — amount in base units
);

What happens

  1. 1Derives your spending pubkey from the privkey.
  2. 2Generates a random salt and computes the commitment hash.
  3. 3Runs the shield circuit locally to generate a ZK proof.
  4. 4Calls approve() on the token, then shield() on the pool.
  5. 5Waits for the Shielded event and adds the note to NoteManager.

Return value

typescript
{
  commitment: bigint  // the commitment hash (leaf in the Merkle tree)
  txHash:     string  // on-chain transaction hash
}