Skip to main content

Type Definitions

Payment Requirement

Returned by server in 402 response.

interface FHEPaymentRequirement {
scheme: 'fhe-transfer';
network: string;
chainId: number;
payTo: `0x${string}`;
maxAmountRequired: string;
asset: `0x${string}`;
resource: string;
description: string;
mimeType: string;
maxTimeoutSeconds: number;
facilitator?: string;
}
FieldTypeDescription
schemestringAlways 'fhe-transfer'
networkstringNetwork name (e.g., 'sepolia')
chainIdnumberChain ID (e.g., 11155111)
payToaddressMerchant address
maxAmountRequiredstringRequired amount in token decimals
assetaddressERC7984 token contract
resourcestringProtected resource URL
descriptionstringHuman-readable description
mimeTypestringContent type of resource
maxTimeoutSecondsnumberPayment timeout
facilitatorstringOptional facilitator URL

Decryption Signature

User authorization for server-side decryption.

interface FHEDecryptionSignature {
signature: string;
publicKey: string;
privateKey: string;
userAddress: `0x${string}`;
contractAddresses: `0x${string}`[];
startTimestamp: number;
durationDays: number;
}
FieldTypeDescription
signaturestringWallet signature
publicKeystringEphemeral public key
privateKeystringEphemeral private key
userAddressaddressUser's Ethereum address
contractAddressesaddress[]Authorized contracts
startTimestampnumberUnix timestamp
durationDaysnumberValidity period

The privateKey is ephemeral, not the user's wallet key.


Payment Payload

Sent by client after transfer.

interface FHEPaymentPayload {
x402Version: 1;
scheme: 'fhe-transfer';
network: string;
chainId: number;
payload: {
txHash: `0x${string}`;
decryptionSignature: FHEDecryptionSignature;
};
}
FieldTypeDescription
x402VersionnumberAlways 1
schemestringAlways 'fhe-transfer'
networkstringNetwork name
chainIdnumberChain ID
payload.txHashstringTransfer transaction hash
payload.decryptionSignatureobjectDecryption authorization

Verify Result

Response from facilitator verification.

interface FHEPaymentVerifyResult {
isValid: boolean;
invalidReason?: string;
txHash?: `0x${string}`;
amount?: string;
}
FieldTypeDescription
isValidbooleanPayment validity
invalidReasonstringError explanation
txHashstringVerified transaction
amountstringDecrypted amount

ConfidentialTransfer Event

ERC7984 transfer event data.

interface ConfidentialTransferEvent {
from: `0x${string}`;
to: `0x${string}`;
amount: `0x${string}`;
}
FieldTypeDescription
fromaddressSender
toaddressRecipient
amountbytes32Encrypted handle

The amount field is an encrypted handle, not the actual value.