import { toHex } from 'viem';
const value = BigInt(amount); // quoted amount from step 1
const nonce = toHex(crypto.getRandomValues(new Uint8Array(32)));
const validBefore = String(Math.floor(Date.now() / 1000) + 3600);
const signature = await signTypedDataAsync({
domain: { name: 'USD Coin', version: '2', chainId, verifyingContract: USDC_ADDRESS },
types: {
TransferWithAuthorization: [
{ name: 'from', type: 'address' },
{ name: 'to', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'validAfter', type: 'uint256' },
{ name: 'validBefore', type: 'uint256' },
{ name: 'nonce', type: 'bytes32' },
],
},
primaryType: 'TransferWithAuthorization',
message: { from: owner, to: vaultAddress, value, validAfter: 0n, validBefore: BigInt(validBefore), nonce },
});