/consent-before-attest

Say goodbye to defamatory data on-chain and hello to consent and privacy. No one can publish data about you unless you approve it with our attestation signing protocol. Take control of your digital identity today!

Primary LanguageSolidity

consent-before-attest

Say goodbye to defamatory data on-chain and hello to consent and privacy. No one can publish data about you unless you approve it with our attestation signing protocol. Take control of your digital identity today!

Project Description

Introducing Consent-Before-Attest: A Solution for Secure and Responsible On-Chain Attestations

In today's digital age, data is the new currency. It's valuable and can be used to build identity and reputation layers on-chain. AttestationStation, rolled out by Optimism, is a powerful library of key-value pairs that can be used to create a secure and trusted identity layer on the blockchain. However, there are some issues with the current approach. The biggest issue is that there is no consent taken from the subject of the attestation. Anyone can put up private or defaming data about someone else without their permission. This leads to a lack of data integrity and privacy concerns.

Moreover, once data is written on the blockchain, it's there forever. There's no right to be forgotten, and there's no way to erase data once it's written. This poses a challenge for individuals who want to protect their privacy and reputation.

To address these issues, we present Consent-Before-Attest, a solution that enables individuals to securely and responsibly store data on the blockchain. With Consent-Before-Attest, the subject of the attestation must provide their consent before any data is put on-chain. This ensures that only authorised and verified data is stored on the blockchain. This is important because it helps maintain data integrity and privacy.

So how does Consent-Before-Attest work?


Let's say Alice wants to make an attestation about Bob. She must initiate the process by submitting the key-value pair she wants to put on-chain. Bob then views this data and approves it by signing the payload. Alice can then send this signed payload to the smart contract which verifies that Bob's consent has been taken. Now we have successfully made an attestation with a win-win for both parties. Bob is sure that any data about him has to be approved before it goes on-chain. Alice gets the benefit of data integrity because Bob has approved the attestation and the data is being uploaded more responsibly rather than without consent.

Consent-Before-Attest provides a secure and responsible way to store data on the blockchain. It ensures that all data is verified and authorised, providing a high level of data integrity and privacy. Moreover, since only authorised data is stored on-chain, there's no need to worry about defamatory or private data being published without consent. This provides a safer and more secure way to build an identity and reputation layer on the blockchain.

Consent-Before-Attest is built on top of AttestationStation, taking advantage of its powerful features while addressing its limitations. With Consent-Before-Attest, we can unlock the full potential of the blockchain for identity and reputation management, while ensuring the highest standards of data integrity and privacy.

In conclusion, Consent-Before-Attest is a game-changer in the world of on-chain data storage. It provides a responsible and secure way to store data on the blockchain, ensuring that all data is verified and authorised. With Consent-Before-Attest, we can build a more trusted and secure identity layer on the blockchain, enabling new opportunities and unlocking the full potential of this powerful technology.

ConsentualAttestationStation Contract - Optimism Goerli




Optimism

Optimism starterkit.


This is a Optimism + wagmi + Foundry + Rainbowkit + Vite project originally bootstrapped with create-wagmi built with ❤️ for hackers.

Who is this for?

This starter is a great choice for any of the following groups:

Getting Started

Install Node

See here. Note that you need Node at a later version than 14.18.0, or 16 and above. These instructions were verified with Node 18.

Install Foundry

You will need to install Foundry to build your smart contracts.

  1. Run the following command:

    curl -L https://foundry.paradigm.xyz | bash
  2. Source your environment as requested by Foundry.

  3. Run foundryup.

Start the application

starter-app-screenshot

  1. Clone/fork the optimism-starter repo

    git clone https://github.com/ethereum-optimism/optimism-starter.git
  2. Install the necessary node packages:

    cd optimism-starter
    npm install
  3. Start the frontend with npm run dev

    npm run dev

    If you get errors during this step, you might need to update your Foundry to the latest version.

  4. Open localhost:5173 in your browser.

    Once the webpage has loaded, changes made to files inside the src/ directory (e.g. src/App.tsx) will automatically update the webpage.

See below for general usage instructions or FAQ for answers to general questions such as:

Generate ABIs & React Hooks

This project comes with @wagmi/cli built-in, which means you can generate wagmi-compatible (type safe) ABIs & React Hooks straight from the command line.

To generate ABIs & Hooks, follow the steps below.

Generate code

To generate ABIs & React Hooks from your Foundry project (in ./contracts), you can run:

npm run wagmi

This will use the wagmi config (wagmi.config.ts) to generate a src/generated.ts file which will include your ABIs & Hooks that you can start using in your project.

Here is an example of Hooks from the generated file being used.

Deploying Contracts

To deploy your contracts to a network, you can use Foundry's Forge – a command-line tool to tests, build, and deploy your smart contracts.

You can read a more in-depth guide on using Forge to deploy a smart contract here, but we have included a simple script in the package.json to get you started.

Below are the steps to deploying a smart contract to Ethereum Mainnet using Forge:

Set up environment

Get an Etherscan key

  1. Register for Etherscan on Optimism. This account is different from your normal Etherscan account.

  2. Go to the API keys page and click Add to create a new API key.

Specify .env

You will first need to set up your .env to tell Forge where to deploy your contract.

  1. Copy .env.example to .env.

    cp .env.example .env
  2. Edit your .env to specify the environment variables.

    • ETHERSCAN_API_KEY: Your Etherscan API Key.

    • FORGE_RPC_URL: The RPC URL of the network to which you deploy. If you use Alchemy, your URL will look like this: https://opt-goerli.g.alchemy.com/v2/<Alchemy API Key>

    • FORGE_PRIVATE_KEY: The private key of the wallet you want to deploy from.

Deploy contract

You can now deploy your contract!

npm run deploy

Developing with Anvil (Optimism Mainnet Fork)

Let's combine the above sections and use Anvil alongside our development environment to use our contracts (./contracts) against an Optimism fork.

Start dev server

Run the command:

npm run dev:foundry

This will:

  • Start a vite dev server,
  • Start the @wagmi/cli in watch mode to listen to changes in our contracts, and instantly generate code,
  • Start an Anvil instance (Goerli Optimism Fork) on an RPC URL.

Deploy our contract to Anvil

Now that we have an Anvil instance up and running, let's deploy our smart contract to the Anvil network:

npm run deploy:anvil

Start developing

Now that your contract has been deployed to Anvil, you can start playing around with your contract straight from the web interface!

Head to localhost:5173 in your browser, connect your wallet, and try increment a counter on the Foundry chain. Use the generated code in src/generated.ts to do it and follow the Attestooooor component as an example

Tip: If you import an Anvil private key into your browser wallet (MetaMask, Coinbase Wallet, etc) – you will have 10,000 ETH to play with 😎. The private key is found in the terminal under "Private Keys" when you start up an Anvil instance with npm run dev:foundry.

Attestation station

This starterkit comes preloaded with tools for working with the attestation station!

@eth-optimism/atst - Is a typescript sdk for easily interacting with the attestation in vanilla javascript and react. The react hooks for your convenience are also in this package at src/generated.ts

Also included is a CLI for interacting with the attestation. To get started run

npx atst --help

preview

Alternatives

Looking to use burner wallets? Prefer hardhat? Prefer NEXT.js? Check out these amazing alternatives:

  • create wagmi cli - A flexible cli with many templates (this starterkit was started from vite-react-cli-foundry)
  • scaffold-eth - The new 2nd version of a popular NEXT.js based starter including hardhat, burner wallets, great documentation, and an active telegram for support
  • Awesome wagmi - Has other alternative examples
  • Create Eth App - Uses a wagmi alternative called useDapp that is used at OP Labs

Learn more

To learn more about Optimism, Vite, Foundry, Rainbow kit or wagmi, check out the following resources: