Shield & Unshield
The full wrap/unwrap lifecycle: approval, shielding, the two-phase unshield, and interrupted-op resume.
Shielding wraps a public ERC-20 into its confidential ERC-7984 form; unshielding does the reverse. In the app both live on the Wrap page.
Shield (wrap)
A shield is a two-transaction dance: an ERC-20 approve() so the wrapper can pull your tokens, then wrap(), which locks the ERC-20 and mints you an encrypted euint64 balance. ShadowLine runs the approval, waits for its receipt, refreshes the allowance, then wraps — passing approvalStrategy: 'skip'so the SDK doesn't try to approve again.
// 1. Approve (only if current allowance is insufficient)
await writeContract({ address: erc20, abi: ERC20_ABI, functionName: 'approve',
args: [wrapper, amount] });
await waitForTransactionReceipt({ hash });
await refetchAllowance();
// 2. Wrap — allowance is already in place, so skip the SDK's approval step
await shield({ amount, approvalStrategy: 'skip' });approve() that changes a non-zero allowance straight to another non-zero value. If an allowance is already outstanding, zero it first (approve(spender, 0), await the receipt), then approve the real amount. Standard tokens with a zero allowance are unaffected.Unshield (unwrap)
Unshielding is two phases. First an on-chain unwrap()request burns your ciphertext and registers the intent. Then Zama's Gateway produces a decryption proof and finalizes the unwrap — typically ~30–60 seconds later — releasing the underlying ERC-20 back to your address.
- Amounts for unshield always use 6 decimals (wrapper decimals).
- Because finalization is asynchronous, the pending unwrap tx hash is persisted so the operation can be resumed if you close the tab.
Resuming an interrupted unshield
The SDK does not auto-persist the pending unwrap. ShadowLine saves the unwrap tx hash the moment it's submitted; on the next visit it reads it back with loadPendingUnshield and offers a Resume action wired to useResumeUnshield. See the SDK Hooks page for the exact signatures.
