An open API service indexing awesome lists of open source software.

https://github.com/hazae41/eip712

EIP-712 encoding for the web
https://github.com/hazae41/eip712

Last synced: about 1 month ago
JSON representation

EIP-712 encoding for the web

Awesome Lists containing this project

README

          

# EIP-712: Typed structured data hashing and signing

EIP-712 encoding for the web

```bash
npm install @hazae41/eip712
```

[**📦 NPM**](https://www.npmjs.com/package/@hazae41/eip712)

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Rust-like patterns

## Usage

### Hashing

```tsx
const hash: Uint8Array = eip712.hash({
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" },
],
Person: [
{ name: "name", type: "string" },
{ name: "wallet", type: "address" }
],
Mail: [
{ name: "from", type: "Person" },
{ name: "to", type: "Person" },
{ name: "contents", type: "string" }
],
},
primaryType: "Mail",
domain: {
name: "Ether Mail",
version: "1",
chainId: 1n,
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
},
message: {
from: {
name: "Cow",
wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
},
to: {
name: "Bob",
wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
},
contents: "Hello, Bob!",
},
})
```