IPrivacy.withdrawWithAuthorization

withdrawWithAuthorization(
  PrivacyWithdrawRequest request,
  PrivacyActionAuthorization authorization
) external returns (bool)

effectiveSender가 서명한 EIP-712 인증을 사용하여 실드 풀의 자금을 투명한 EVM 수신자에게 대리 인출합니다. executor(일반적으로 릴레이어)가 트랜잭션을 제출하며, 프리컴파일이 서명을 검증하고 nonce와 deadline으로 재사용을 차단한 뒤 직접 withdraw 메서드와 동일한 널리파이어 소비 상태 전이를 수행합니다. amount 필드는 체인이 파싱하는 코인 문자열입니다(예: 10 OKRW는 "10000000000000000000atokrw").

파라미터

이름 타입 필수 설명
request PrivacyWithdrawRequest ✓ 실드 인출 페이로드입니다. proof, root, nullifier, amount(코인 문자열, 예: "10000000000000000000atokrw"), recipient(투명 EVM 주소), chainId, expiresAtUnix로 구성됩니다. amount는 64비트 실드 금액 필드에 들어가야 합니다. 연산 하나당 최대 2^64-1 atokrw, 즉 18.446744073709551615 OKRW이며, 이를 넘으면 증명 검증이나 널리파이어 소비 전에 요청 검증 단계에서 거부되며, EVM 호출자에게는 인자 없는 SDKInvalidRequest()만 보입니다. 노드 쪽 사유(withdraw amount exceeds 64-bit shielded amount limit)는 revert 데이터에 담기지 않습니다. 실패 사유 전체 목록은 IPrivacy.withdraw에 있고, 이 메서드는 인증 검사만 추가합니다.
authorization PrivacyActionAuthorization ✓ effectiveSender의 EIP-712 서명 인증입니다. executor는 반드시 msg.sender와 일치해야 하며, 표준 도메인은 privacy-authorization-eip712-domain을 참고합니다.

반환값

타입: bool

성공 시 true를 반환합니다. 실패는 revert됩니다.

예제

10 OKRW 릴레이 인출

import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { iPrivacyAbi } from "@maroo-chain/contracts/abi/precompiles/privacy/IPrivacy";

const PRIVACY = "0x100000000000000000000000000000000000000b" as const;
const relayer = createWalletClient({
  account: privateKeyToAccount(process.env.RELAYER_KEY as `0x${string}`),
  transport: http("https://rpc-testnet.maroo.io"),
});

// The proof, this request and the owner's EIP-712 signature are made together, off-chain: the proof binds
// the amount, recipient and expiresAtUnix, and the signature covers its deadline and the hash of this
// request. Pass the values they were made for — a new expiresAtUnix needs a new proof and a new signature.
const withdrawRequest = {
  proof:         proofBytes,
  root:          merkleRoot,
  nullifier:     nullifierBytes,
  amount:        "10000000000000000000atokrw", // 10 OKRW
  recipient:     "0x1111111111111111111111111111111111111111" as const, // TODO: replace before production
  // The chain's Cosmos chain-id, EXACTLY — read it from the node:
  // GET /cosmos/base/tendermint/v1beta1/node_info → default_node_info.network.
  // A mismatch reverts with a bare `SDKInvalidRequest()` that does not say which
  // value was expected, so check it before you sign.
  chainId:       process.env.MAROO_COSMOS_CHAIN_ID as string,
  expiresAtUnix: provedExpiresAtUnix, // the deadline the proof was generated for
};

await relayer.writeContract({
  address: PRIVACY,
  abi: iPrivacyAbi,
  functionName: "withdrawWithAuthorization",
  args: [
    withdrawRequest,
    {
      effectiveSender,
      executor:          relayer.account.address,
      nonce,
      deadline:          signedDeadline, // the deadline the owner signed
      authorizationKind: 1, // AUTH_KIND_EOA — the SIGNATURE SCHEME, not the action.
                            // 2 = ERC-1271 contract signature, 3 = EIP-7702 delegated EOA.
      signature:         eip712Signature,
    },
  ],
});
ESC
검색어를 입력하세요