# ethers-eip712

> Ethereum Typed Data Hashing and Signing (EIP712) implementation for ethers.js

Latest version **0.2.0** (published 2020-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install ethers-eip712
pnpm add ethers-eip712
yarn add ethers-eip712
bun add ethers-eip712
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-08-10 |
| First published | 2020-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | github.com/arcadeum |
| Maintainers | pkieltyka |

## Links

- npm: https://www.npmjs.com/package/ethers-eip712
- Repository: https://github.com/arcadeum/ethers-eip712
- Homepage: https://github.com/arcadeum/ethers-eip712#readme
- Issues: https://github.com/arcadeum/ethers-eip712/issues
- npm.io page: https://npm.io/package/ethers-eip712

## Recent versions

- 0.2.0 (latest) — 2020-08-10
- 0.1.0 — 2020-08-07

## README

ethers-eip712
=============

`ethers-eip712` is an npm package that implements the Ethereum Typed Data (EIP712)
for structured data hashing and signing proposal, written in TypeScript for ethers.js.

EIP712: https://eips.ethereum.org/EIPS/eip-712

## Usage

`yarn install ethers-eip712` or `npm install ethers-eip712`

NOTE: both ethers v4 and ethers v5 are compatible by this single library.


## Example

```typescript
import { ethers } from 'ethers'
import { TypedDataUtils } from 'ethers-eip712'

const typedData = {
  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"},  
    ]
  },
  primaryType: 'Person' as const,
  domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
  },
  message: {
    'name': 'Bob',
    'wallet': '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
  }
}

const digest = TypedDataUtils.encodeDigest(typedData)
const digestHex = ethers.utils.hexlify(digest)

const wallet = ethers.Wallet.createRandom()
const signature = wallet.signMessage(digest)
```

[See tests for more examples](./tests/typed-data.test.ts)


## License

MIT

---
_Source: https://npm.io/package/ethers-eip712 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
