Skip to content

A helper library and website for retrieval of the EIP-712 domain of a contract.

Notifications You must be signed in to change notification settings

frangio/eip712domains

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EIP-712 Domain Helper

A helper for retrieval of the EIP-712 domain of a contract. Uses ERC-5267 with fallback to known domains or guided guessing.

npm install eip712domains

Usage

// (1) Create an EIP-712 Domain Client

// (1a) Viem
import { createERC5267Client } from 'eip712domains/viem';
const { getEIP712Domain } = createERC5267Client(publicClient);

// (1b) Ethers
import { createERC5267Client } from 'eip712domains/ethers';
const { getEIP712Domain } = createERC5267Client(provider);

// (1c) HTTP
import { createERC5267Client } from 'eip712domains/http';
const { getEIP712Domain } = createERC5267Client('https://infura.io/...');

// (2) Get the domain for a contract address
const domain = await getEIP712Domain(contractAddress);

if (domain === undefined) {
    // Handle unavailable domain
}

// (3) Request a signature

// (3a) Viem
const signature = await walletClient.signTypedData({ domain, ... });

// (3b) Ethers
const signature = await signer.signTypedData(domain, ...);

About

A helper library and website for retrieval of the EIP-712 domain of a contract.

Resources

Stars

Watchers

Forks