IPrivacy.withdrawWithAuthorization
withdrawWithAuthorization(
PrivacyWithdrawRequest request,
PrivacyActionAuthorization authorization
) external returns (bool) effectiveSender가 서명한 EIP-712 인증을 사용하여 실드 풀의 자금을 투명한 EVM 수신자에게 대리 인출합니다. executor(일반적으로 릴레이어)가 트랜잭션을 제출하며, 프리컴파일이 서명을 검증하고 nonce와 deadline으로 재사용을 차단한 뒤 직접 withdraw 메서드와 동일한 널리파이어 소비 상태 전이를 수행합니다. amount 필드는 체인이 파싱하는 코인 문자열입니다(예: 10 OKRW는 "10000000000000000000aokrw").
파라미터
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
request | PrivacyWithdrawRequest | ✓ | 실드 인출 페이로드입니다. proof, root, nullifier, amount(코인 문자열, 예: "10000000000000000000aokrw"), recipient(투명 EVM 주소), chainId, expiresAtUnix로 구성됩니다. amount는 64비트 실드 금액 필드에 들어가야 합니다. 연산 하나당 최대 2^64-1 aokrw, 즉 18.446744073709551615 OKRW이며, 이를 넘으면 증명 검증이나 널리파이어 소비 전에 요청 검증 단계에서 withdraw amount exceeds 64-bit shielded amount limit: invalid request로 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";
const PRIVACY = "0x100000000000000000000000000000000000000b" as const;
const relayer = createWalletClient({
account: privateKeyToAccount(process.env.RELAYER_KEY as `0x${string}`),
transport: http("https://rpc-testnet.maroo.io"),
});
const withdrawRequest = {
proof: proofBytes,
root: merkleRoot,
nullifier: nullifierBytes,
amount: "10000000000000000000aokrw", // 10 OKRW
recipient: "0x1111111111111111111111111111111111111111", // TODO: replace before production
// The chain's Cosmos chain-id, EXACTLY. Fixed at genesis, exposed by no precompile, and
// a mismatch reverts with `withdraw chain id mismatch: expected <chain>, got <yours>`
// — which is how you find the right value. Never hardcode it.
chainId: process.env.COSMOS_CHAIN_ID as string,
expiresAtUnix: BigInt(Math.floor(Date.now() / 1000) + 300),
};
await relayer.writeContract({
address: PRIVACY,
abi: privacyAbi,
functionName: "withdrawWithAuthorization",
args: [
withdrawRequest,
{
effectiveSender,
executor: relayer.account.address,
nonce,
deadline: BigInt(Math.floor(Date.now() / 1000) + 300),
authorizationKind: 3, // withdraw
signature: eip712Signature,
},
],
});