DEV Community

Cover image for EIP 712: A simple example using Ethers.js & Hardhat
ali kim
ali kim

Posted on

EIP 712: A simple example using Ethers.js & Hardhat

Several months ago, I was trying to use EIP712 to create verifiable signatures using structured data. It’s a standard way of signing structured data, so theoretically it should be super simple: Sign a message and then decode to verify it, right?

In practice, I had a tough time getting this to work. I looked at various documentation and code examples, but I noticed they all had:

  • different implementations of signing and verifying (decoding) signature
  • different implementations by ethers version
  • different decode implementations
  • overcomplicated demos
  • No end to end example of using ethers.js (only web3.js)

With all these little issues combined, I just couldn’t do a simple sign & verify using EIP712. I ended up wasting so much time.

Here’s a sample repo to help anyone having trouble using EIP-712. If you can’t do a simple sign & verify within 15 minutes, just use my code: https://github.com/alinobrasil/eip712_product_registry

By utilizing EIP712, you will have:

  1. Enhanced Security: EIP712 helps prevent certain types of replay attacks and phishing attacks, thereby enhancing the security of transactions and interactions within the Ethereum ecosystem.
  2. Improved User Experience: EIP712 provides a better user experience by enabling wallets and dApps to display transaction information in a structured, human-readable format, reducing the likelihood of user errors and increasing overall usability.
  3. Interoperability: EIP712 facilitates interoperability between different wallets and dApps by defining a standard for how transaction data is structured and signed, thereby promoting seamless interaction and integration across the Ethereum network.

Top comments (0)