Message Signing
Message Structure
I approve the transfer of {allowanceAmount} {originSymbol} from {originChain} to {targetAddress} on {targetChain}.Example
import { Address } from "viem";
import { avalanche } from "viem/chains";
// however these are obtained in your app
import { getUserWalletAddress, fetchFeeData, getUserFeeChoice } from "../utils";
const walletAddress = getUserWalletAddress()
const feeData = await fetchFeeData()
const isFeeFromOrigin = getUserFeeChoice() // boolean
const message = isFeeFromOrigin
? feeData.transactionValues.feeFromOrigin.message
: feeData.transactionValues.feeFromTarget.message
const walletClient = createWalletClient({
account: walletAddress as Address,
chain: avalanche,
transport: custom(window.ethereum),
})
const signature = await walletClient.signMessage({
account: walletAddress as Address,
message
})Why sign a message?
Last updated