Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnidan/guestbook-712
Example Guestbook contract using EIP-712 signatures
https://github.com/gnidan/guestbook-712
Last synced: 23 days ago
JSON representation
Example Guestbook contract using EIP-712 signatures
- Host: GitHub
- URL: https://github.com/gnidan/guestbook-712
- Owner: gnidan
- Created: 2021-11-23T08:51:31.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T17:07:00.000Z (over 2 years ago)
- Last Synced: 2024-10-07T18:41:04.027Z (about 1 month ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# guestbook-712
Example Guestbook contract using [EIP-712](https://eips.ethereum.org/EIPS/eip-712)
signatures## Contents
This repository houses a Truffle project.
It contains the following core components:
- [`Guestbook.sol`](https://github.com/gnidan/guestbook-712/blob/master/contracts/Guestbook.sol)
smart contract in Solidity using @openzeppelin/contracts for EIP-712
verification.
- [`guestbookUtils.js`](https://github.com/gnidan/guestbook-712/blob/master/guestbookUtils.js)
helpers for performing signature operations for a given deployed `Guestbook`### Notes about this Truffle project
- There's no `Migrations.sol`. Yep, that file is completely optional.
- Compiler version is specified as `version: "pragma"`. Did you know you could
do that? :smile:
- Ignore the weird RPC URL. No secret unreleased features here. :shushing_face:
- The `console:` section in `truffle-config.js` is recent new functionality.
Pretty handy!## `Guestbook` contract
Aggregates signed log entries. This contract defines an EIP-712 schema and
verifies the validity of the signature for each entry.Anyone may spend gas to submit a signed guestbook log from anyone else, as long
as the signature and message match.## `guestbookUtils.js` module
This module serves as a `truffle console` "require" hook, adding the
`forGuestbook` global function to the console scope.### Usage
1. Run `truffle console` or `truffle develop`
2. Ensure you have run migrations (i.e. with `truffle migrate` command)
3. Initialize utils:```javascript
// get deployed guestbook
truffle(develop)> const guestbook = await Guestbook.deployed();// pass instance to function defined by "require" hook
truffle(develop)> const utils = forGuestbook(guestbook);// read current guestbook logs
truffle(develop)> utils.read();// sign message and capture result to variable
truffle(develop)> const signedMessage = await utils.sign("hi!");// submit signed message in transaction to save
truffle(develop)> utils.submit(signedMessage);// read guestbook logs again and see new entry
truffle(develop)> utils.read();
```