> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inco.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Transactions

> Approve, deploy wrappers, shield, send, and unshield with exact amounts.

`token` means the underlying ERC-20. Pass `amount` as a decimal string or bigint base units; numbers are unsupported.

| Method             | Arguments                    | Resolves to                     | Work performed                                                                                                |
| ------------------ | ---------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `deposit`          | `{ token, amount, onStep? }` | `{ hash: Hex, amount: bigint }` | Resolve/create wrapper, check allowance, approve if needed, then wrap.                                        |
| `approve`          | `{ token, amount }`          | `{ hash: Hex }`                 | ERC-20 approval to the cToken address. Does not wrap or deploy the wrapper.                                   |
| `allowanceOf`      | `{ token, amount }`          | `boolean`                       | Check whether the current owner's allowance to the resolved cToken covers the requested amount. No signature. |
| `ensureWrapper`    | `{ token, onStep? }`         | `Address`                       | Return registered wrapper; deploy and confirm if absent. Returns the wrapper address, not a transaction hash. |
| `confidentialSend` | `{ token, to, amount }`      | `{ hash: Hex }`                 | Require registered wrapper, encrypt amount, read Inco fee, call payable confidential transfer.                |
| `withdraw`         | `{ token, amount }`          | `{ hash: Hex, amount: bigint }` | Read owner's balance checkpoint, attest checkpoint ≥ amount, estimate gas, unwrap to the current owner.       |
| `networkFee`       | No arguments                 | `bigint`                        | Read current ciphertext-ingest fee in wei; separate from gas.                                                 |

## Shield / deposit

```ts theme={null}
const result = await ctoken.deposit({
  token: USDC,
  amount: "1.25",
  onStep: (step) => console.log(step),
});
console.log(result.hash, result.amount); // bigint base units
```

Steps: `creating` → `approving` → `wrapping`, skipping completed setup. Each transaction is independent: approval/deployment persists if wrapping is declined. Approval targets the cToken.

```ts theme={null}
// Optional two-step UI.
if (!(await ctoken.allowanceOf({ token: USDC, amount: "1.25" }))) {
  await ctoken.approve({ token: USDC, amount: "1.25" });
}
await ctoken.deposit({ token: USDC, amount: "1.25" });
```

`approve()` requires a positive amount; it cannot revoke with zero. Pre-approval may use a predicted wrapper address before deployment.

## Send confidential tokens

```ts theme={null}
const { hash } = await ctoken.confidentialSend({
  token: USDC,
  to: recipient,
  amount: "0.5",
});
```

Requires a nonzero recipient and registered wrapper. Encryption binds to the sender/cToken; ETH covers `networkFee()` plus gas. Confirmation alone does not prove the recipient’s decrypted balance.

## Unshield / withdraw

```ts theme={null}
const result = await ctoken.withdraw({ token: USDC, amount: "0.25" });
console.log(result.hash, result.amount);
```

Withdraws to the current owner. If incoming transfers invalidate the checkpoint, let the user retry from fresh state.

## Confirmation semantics

Final writes wait for configured confirmations and return the mined hash, including fee-only replacements. Errors: `TX_CANCELLED` for cancellation, `TX_REPLACED` for a different operation, `TX_REVERTED` for reverts. Wallet/RPC causes can propagate.
