Understand Attestations! Ultimate Guide📚
Published: 2024-01-30 00:40:20

---
title: Understand Attestations! Ultimate Guide📚
published: true
description: 
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3l05zpen41ecd4zl8qv7.png
# Use a ratio of 100:42 for best results.
# published_at: 2024-01-19 00:11 +0000
---

This is the ultimate guide on attestations. What are they? What are they used for? Do they matter? We'll go from 0 to 100% with practical and relevant examples for users and developers. Why am I making this article? I believe they are not a fad but will be a fundamental part of web3 in areas such as governance, DeFi, protection against AI issues, among others. Also, in recent months, I have had direct contact with the creators of EAS to better understand this topic in depth. So I invite you to read the article to the end where I will be sharing advanced tips.

## First Use Cases

EAS has already been launched on Ethereum Mainnet and also on various L2s such as Optimism, Arbitrum, Scroll, Base, and Linea. Although EAS is a fairly recent project, there are a couple of applications that have already launched or are about to launch. The one that caught my attention the most is the integration of [Gitcoin Passport](https://passport.gitcoin.co/), which will simplify the process of proving your humanity. Another interesting use case is how EAS can help Coinbase comply with the complexity of regulation in the United States through [on-chain verification on Base](https://help.coinbase.com/en/coinbase/getting-started/verify-my-account/onchain-verification). And moving on from identity, we have Optimism RPGF v3 that used EAS to register [Badge Holders](https://optimism.easscan.org/attestations/forSchema/0xfdcfdad2dbe7489e0ce56b260348b7f14e8365a8a325aef9834818c00d46b31b?page=4&limit=50), [applications](https://optimism.easscan.org/schema/view/0x76e98cce95f3ba992c2ee25cef25f756495147608a3da3aa2e5ca43109fe77cc) and more. I love this example becuase I used it and wasn't even aware that EAS was the backbone.

## Future Use Cases

I share with you the most relevant future use cases below:

- Proof of trade, to build on-chain reputation and open up possibilities for collateral-free loans or access to different types of derivatives.
- Legaltech, RWA, letters of intent. I previously worked in legaltech in web2 and see how EAS can improve the standard of validity and backing for all types of legal documents.
- Decentralized identity graphs, reputation proofs, anti-Sybil mechanisms.
- Proof of humanity, differentiation between AI and humans, anti-deepfake proofs.

These are my favorite use cases; for more use cases, check out [this official ideas list](https://docs.attest.sh/docs/category/example-use-cases).

## Let's Create an Attestation from the Website

You can create an attestation based on an existing schema or create your own. Schemas define the format in which attestations will be made, and in this case, we will use the [Is Human schema](https://scroll-sepolia.easscan.org/attestation/attestWithSchema/0x8af15e65888f2e3b487e536a4922e277dcfe85b4b18187b0cf9afdb802ba6bb6) to attest that the owner of a certain address is human. For this example, you only need to connect your [Metamask](https://metamask.io/) wallet (or any wallet) to Scroll Sepolia, then enter the address you want to attest and click `Make attestation`. You can choose whether you want the off-chain attestation, i.e., free, obtained only by signing a transaction. Alternatively, you can choose to make it on-chain and pay for the transaction to make it public and connect it to smart contract logic. In this case, you will need to obtain funds in Scroll Sepolia through a [Scroll Sepolia Faucet](https://docs.scroll.io/en/user-guide/faucet/).

![How to make an Attestation Using EAS Scan easscan](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2wr6i2wmqrprdp2wcu5.png)

## Advanced Example: Swap Attestations

This contract attests swaps from `WETH` to `GHO` in Uni V3 in Scroll Sepolia. It's an example that can help you understand how to integrate EAS into any protocol autonomously, all through Smart Contracts. To test it, you can deploy this contract and call the `swap()` function, passing the amount of `WETH` you want to exchange. Then, you can view your attestation in the corresponding schema on [EAS Scan](https://scroll-sepolia.easscan.org/schema/view/0x5312f94781cdc373a4f16ddb71e8aee048bc0e3fac0819ca0258cc170c646a1d). Remember that you need to have `WETH` in advance, which you can obtain through the `deposit()` function [here](https://sepolia.scrollscan.dev/address/0x5300000000000000000000000000000000000004#writeContract).

```javascript
// SPDX-License-Identifier: MIT

pragma solidity 0.8.23;

import { IEAS, AttestationRequest, AttestationRequestData, RevocationRequest, RevocationRequestData } from "@ethereum-attestation-service/eas-contracts/contracts/IEAS.sol";
import { NO_EXPIRATION_TIME, EMPTY_UID } from "@ethereum-attestation-service/eas-contracts/contracts/Common.sol";

struct ExactInputSingleParams {
    address tokenIn;
    address tokenOut;
    uint24 fee;
    address recipient;
    uint amountIn;
    uint amountOutMinimum;
    uint160 sqrtPriceLimitX96;
}

interface IUniswapV3Router {
    function exactInputSingle(
        ExactInputSingleParams calldata params
    ) external payable returns (uint amountOut);
}

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 value) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 value) external returns (bool);
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

contract SwapAttestation
{
    address WETH = 0x5300000000000000000000000000000000000004;
    address GHO  = 0xD9692f1748aFEe00FACE2da35242417dd05a8615;
    address uniswapRouter = 0x17AFD0263D6909Ba1F9a8EAC697f76532365Fb95;
    uint24 poolFee = 500;// 100 500 3000 10000
    address easAddress = 0xaEF4103A04090071165F78D45D83A0C0782c2B2a;
    bytes32 schema = 0x5312f94781cdc373a4f16ddb71e8aee048bc0e3fac0819ca0258cc170c646a1d;

    function swap(uint amountIn) public
    {
        IERC20(WETH).transferFrom(msg.sender, address(this), amountIn);
        IERC20(WETH).approve(uniswapRouter, amountIn);
        ExactInputSingleParams memory params =
            ExactInputSingleParams({
                tokenIn: WETH,
                tokenOut: GHO,
                fee: poolFee,
                recipient: msg.sender,
                amountIn: amountIn,
                amountOutMinimum: 0,
                sqrtPriceLimitX96: 0
            }
        );
        uint amountOut = IUniswapV3Router(uniswapRouter).exactInputSingle(params);

        IEAS(easAddress).attest(
                AttestationRequest({
                    schema: schema,
                    data: AttestationRequestData({
                        recipient: msg.sender,
                        expirationTime: NO_EXPIRATION_TIME,
                        revocable: false,
                        refUID: EMPTY_UID,
                        data: abi.encode(WETH, GHO, amountIn, amountOut),
                        value: 0 // No value/ETH
                    })
                })
            );
    }
}
```

## What else can I do with EAS

Now that we experimented with attestations, let's explore what else we can do with them by looking at some examples.

- You can create schemas from [code](https://github.com/Turupawn/ContributionsNFTsAPI/blob/master/contracts/ContributionsNFT.sol#L91) or from [EAS Scan](https://easscan.org/schema/create).
- You can make [revocable attestations](https://github.com/ethereum-attestation-service/eas-contracts-example/blob/master/contracts/Attester.sol#L50).
- You can set up callbacks to execute any code after each attestation through [Resolvers](https://github.com/ethereum-attestation-service/eas-contracts-example/blob/master/contracts/LogResolver.sol). This can help automating any type of execution and connecting EAS with the broader smart contract ecosystem.
- You can me [expirable](https://github.com/ethereum-attestation-service/eas-contracts-example/blob/master/contracts/Attester.sol#L37) attestations.
- You can verify attestations [offchain, for free](https://github.com/ethereum-attestation-service/eas-contracts-example/blob/master/contracts/OffchainAttestationVerifier.sol).

## Intersting recent EAS developments

- [Private data attestations](https://docs.attest.sh/docs/tutorials/private-data-attestations), where we merkalize data and attest to the root to keep the original data encrypted on the leafs
- Account Abstraction signature verification [using EIP 1271](https://ethdaily.io/coinbase-verifications-powered-by-eas/)
- Open source [indexer](https://github.com/ethereum-attestation-service/eas-indexing-service).
- [Metamask Snap](https://snaps.metamask.io/snap/npm/ethereum-attestation-service/eas-metamask-snap/) that makes easy to expose information when signing

## Before designing your attestations, make sure of this

Recently, while designing my attestations, I had the opportunity to talk with the EAS development team. I showed them a design of a schema very similar to the one below, regarding book rating attestations.

- Book Rating Schema
  - Book name
  - Author name
  - Rating

The EAS team warned me that when designing attestations, in some cases is best to create "Attestations of attestations" to make attestations more composable and also helps saving gas. They recommended creating 2 schemas as detailed below:

- Book Schema
  - Name
  - Author name
- Book Rating Schema
  - Book UID
  - Rating

Where `Book UID` is a reference passed as the `refUID` field. It represents an existing attestation of `Book Schema`. This makes it easier to index information and search for all attestations of a book. Additionally, it saves gas by not storing the details of each book (Author and Name) for each attestation.

**Thank you for reading this article!**

Follow me on dev.to and on [Youtube](https://www.youtube.com/@filosofiacodigoinenglish4031) for everything related to Blockchain development.