Bug
Agent wallet binding (setAgentWallet) fails in the Farcaster miniapp with:
"Unable to parse chainId from eth_signTypedData_v4 params"
Works fine with MetaMask on desktop.
Root Cause
The EIP-712 domain in AgentManage.tsx and AgentRegister.tsx uses BigInt for chainId:
const EIP712_DOMAIN = {
chainId: BigInt(BASE_CHAIN_ID), // BigInt
};
Viem's serializeTypedData() calls its custom stringify() which converts BigInt to string: BigInt(8453).toString() → "8453".
The JSON sent to the wallet becomes:
{ "domain": { "chainId": "8453" } }
- MetaMask: injected provider, lenient parser — accepts string
"8453" ✓
- Farcaster miniapp: JSON-RPC bridge to native Warpcast app, strict parser — expects number
8453, rejects string "8453" ✗
Fix
Change BigInt(BASE_CHAIN_ID) to Number(BASE_CHAIN_ID) in the EIP-712 domain. Number survives JSON.stringify as a number literal (8453), not a string.
const EIP712_DOMAIN = {
name: "ERC8004IdentityRegistry",
version: "1",
chainId: Number(BASE_CHAIN_ID), // Number, not BigInt
verifyingContract: ERC8004_REGISTRY,
};
Note: BASE_CHAIN_ID is already a Number (from constants.ts line 14), so BigInt() wrapping was unnecessary.
Files to modify
src/components/AgentManage.tsx — line 24: BigInt(BASE_CHAIN_ID) → Number(BASE_CHAIN_ID)
src/components/AgentRegister.tsx — same change in EIP712_DOMAIN
Branch
task/625-eip712-chainid-fix
Acceptance criteria
Bug
Agent wallet binding (
setAgentWallet) fails in the Farcaster miniapp with:Works fine with MetaMask on desktop.
Root Cause
The EIP-712 domain in
AgentManage.tsxandAgentRegister.tsxusesBigIntfor chainId:Viem's
serializeTypedData()calls its customstringify()which converts BigInt to string:BigInt(8453).toString()→"8453".The JSON sent to the wallet becomes:
{ "domain": { "chainId": "8453" } }"8453"✓8453, rejects string"8453"✗Fix
Change
BigInt(BASE_CHAIN_ID)toNumber(BASE_CHAIN_ID)in the EIP-712 domain.NumbersurvivesJSON.stringifyas a number literal (8453), not a string.Note:
BASE_CHAIN_IDis already aNumber(fromconstants.tsline 14), soBigInt()wrapping was unnecessary.Files to modify
src/components/AgentManage.tsx— line 24:BigInt(BASE_CHAIN_ID)→Number(BASE_CHAIN_ID)src/components/AgentRegister.tsx— same change in EIP712_DOMAINBranch
task/625-eip712-chainid-fixAcceptance criteria