IPrivacy.deposit
deposit(
PrivacyDepositRequest calldata request
) external payable returns (bool success) Shields native OKRW into the privacy pool by locking msg.value (in aokrw) under the privacy precompile's fixed escrow and committing a new note to the Merkle tree. The deposit amount is carried by native EVM msg.value — the request struct no longer carries an amount field. On success a PrivacyDeposit event is emitted where the recorded amount is the Cosmos-coin-formatted value of msg.value under the runtime native denom.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
request | PrivacyDepositRequest | ✓ | Deposit payload. Struct is { bytes noteCommitment; bytes encryptedNote; bytes proof; } — the amount is no longer part of the struct. noteCommitment is the MiMC commitment of the new note; encryptedNote is the recipient-encrypted note payload; proof is the deposit ZK proof binding the commitment to msg.value. |
Returns
bool Returns true on success. Failure paths revert with a plain string reason (this precompile declares no typed errors).
Errors
| Code | Name | Description |
|---|---|---|
privacy deposit value is required | privacy deposit value is required | Plain-string revert when the call carries no msg.value. deposit is payable and requires a positive value in aokrw. |
privacy deposit actor must be the non-zero operator | privacy deposit actor must be the non-zero operator | Plain-string revert when the effective sender is the zero address or does not match the operator (direct call only — the removed depositWithAuthorization path is no longer available to decouple these two). |
privacy precompile only supports native denom | privacy precompile only supports native denom "%s", got "%s" | Plain-string revert when the runtime native denom resolved from chain params does not match what the precompile is configured for. |
invalid fixed privacy deposit funder | invalid fixed privacy deposit funder | Plain-string revert when the fixed escrow address (the privacy precompile itself) fails an internal consistency check. Not reachable in normal use. |
Examples
Deposit 10,000,000 OKRW into the privacy pool (viem)
import { createWalletClient, http, parseEther } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const PRIVACY = "0x100000000000000000000000000000000000000b" as const;
const privacyAbi = [{
type: "function",
name: "deposit",
stateMutability: "payable",
inputs: [{
name: "request",
type: "tuple",
components: [
{ name: "noteCommitment", type: "bytes" },
{ name: "encryptedNote", type: "bytes" },
{ name: "proof", type: "bytes" },
],
}],
outputs: [{ type: "bool" }],
}] as const;
const wallet = createWalletClient({
account: privateKeyToAccount(process.env.DEPOSITOR_KEY as `0x${string}`),
transport: http("https://rpc-testnet.maroo.io"),
});
// Client-side prover produces these three fields bound to the deposit amount.
const { noteCommitment, encryptedNote, proof } = await buildDepositWitness({
amountAokrw: parseEther("10000000"), // 10,000,000 OKRW in aokrw
});
await wallet.writeContract({
address: PRIVACY,
abi: privacyAbi,
functionName: "deposit",
args: [{ noteCommitment, encryptedNote, proof }],
value: parseEther("10000000"), // native OKRW flows via msg.value now
}); Migrating from the pre-payable ABI
Existing integrations that encoded amount as a Cosmos-coin string ("10000000000000000000000000aokrw") inside the request must instead forward the value through msg.value. The precompile now derives the deposit amount from the transaction value under the runtime native denom.
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.22;
import "@maroo-chain/contracts/precompiles/privacy/IPrivacy.sol";
contract PrivacyDepositor {
IPrivacy constant PRIVACY = IPrivacy(0x100000000000000000000000000000000000000b);
/// @notice The request struct no longer carries `amount`. The deposit
/// amount is the native value forwarded as msg.value (aokrw).
function shield(
bytes calldata noteCommitment,
bytes calldata encryptedNote,
bytes calldata proof
) external payable {
require(msg.value > 0, "deposit value required");
PrivacyDepositRequest memory req = PrivacyDepositRequest({
noteCommitment: noteCommitment,
encryptedNote: encryptedNote,
proof: proof
});
bool ok = PRIVACY.deposit{value: msg.value}(req);
require(ok, "privacy deposit failed");
}
}