ModuleSDK
Accounts
encode1271Hash

encode1271Hash

Encodes a hash to be signed with ERC-1271 by an account. Note that while you should sign this hash, the unformatted hash is what should be sent to the contract.

Usage

const unformattedHash = keccak256(toHex("hash"));
 
const formattedHash = encode1271Hash({
  account: "0x1234...",
  chainId: 1,
  validator: OWNABLE_VALIDATOR_ADDRESS,
  hash: unformattedHash,
});

Parameters

account

The address of the account to validate the 1271 signature.

chainId

The chain ID of the network to validate the signature on.

validator

The address of the validator to validate the 1271 signature.

hash

The hash to encode.

Returns

encodedHash

The encoded 1271 hash to be signed.