Skip to content

Instantly share code, notes, and snippets.

@Thegaram
Created August 28, 2024 16:21
Show Gist options
  • Select an option

  • Save Thegaram/3b41aba1a8d9d51773f939326746992e to your computer and use it in GitHub Desktop.

Select an option

Save Thegaram/3b41aba1a8d9d51773f939326746992e to your computer and use it in GitHub Desktop.
author date
Péter Garamvölgyi
2024-08-29

Attestations in Action: Using EAS in Scroll Canvas

2024-08-29

@ Ethereum Meetup Budapest


goals of this talk

learn about EAS (Ethereum Attestation Service)

learn how Scroll Canvas works

get inspired to start building cool stuff


EAS: Attestations as a Building Block

learn the ideas behind the Ethereum Attestation Service


introduction to EAS

EAS is an open-source public good for making attestations

it is a standard and a collection of tools

it's simple, permissionless, composable, and credibly neutral

--

attestation: someone claims something about someone else

signed data with well-defined structure

do I trust it?

how do I interpret it?


example: attestations in a social graph

attestations are simply digital signatures on structured pieces of information

{
    uid: '#123',
    schema: 'FriendsWith',
    attester: 'Alice',
    recipient: 'Bob',
    time: 1671219600,
    revocable: true
}

do I trust it? of course, why would I not believe Alice herself?

how do I interpret it? up to me, but the FiendsWith schema provides a default interpretation

--

EAS has 3 main building blocks: schemas, attestations, and tools


building block: schemas

a schema is a blueprint for attestations, it defines its format and basic properties

anyone can create a schema, and (usually) anyone can attest with a schema

--

schemas are created through the global singleton schema registry contract:

ISchemaRegistry.register("bool isTrue", address(0), false)

see ISchemaRegistry.sol


building block: schemas (2)

{
    "uid": "0xd57de4f41c3d3cc855eadef68f98c0d4edd22d57161d96b7c06d2f4336cc3b49",
    "revocable": true,
    "schema": "address badge, bytes payload",
    "resolver": "0x4560FECd62B14A463bE44D40fE5Cfd595eEc0113"
}

uid: universal unique identifier, a hash of the schema

revocable: can the attestations can be revoked or not? e.g. FriendsWith vs DaughterOf

schema: if the attestation carries additional data, how to parse it? e.g. Vote

resolver: a contract that executes additional actions/checks. e.g. CitizenOf

--

next up: attestations


building block: attestations

The primary purpose of EAS is to serve as a protocol that facilitates the creation of digital signatures on structured information, enhancing both their composability and interoperability, trust, and validation.

a minimal but powerful standard data structure

attestations are created through the global singleton EAS contract:

EAS.attest({ schema: "0xd57de4f41c3d3cc855eadef68f98c0d4edd22d57161d96b7c06d2f4336cc3b49", data: ... })

see IEAS.sol


building block: attestations (2)

{
    "uid": "0x5134f511e0533f997e569dac711952dde21daf14b316f3cce23835defc82c065",
    "schema": "0x27d06e3659317e9a4f8154d1e849eb53d43d91fb4f219884d1684f86d797804a",
    "attester": "0x1e3de6aE412cA218FD2ae3379750388D414532dc",
    "recipient": "0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165",

    "revocable": true,

    "time": 1671219600,
    "expirationTime": 0,
    "revocationTime": 1671219636,

    "data": "0x0000000000000000000000000000000000000000000000000000000000000000"
    "refUID": "0x0000000000000000000000000000000000000000000000000000000000000000",
}

--

next up: tools


building block: tools

EAS explorer

the easiest way to browse attestations

attestation indexer

collect all the attestations that you care about into a local database

GraphQL API

flexible queries over attestations. examples:

  • list all FriendsWith attestations that a wallet received
  • list all Like attestations that a wallet issued

EAS SDK

convenient js API to interact with attestations


Scroll Canvas

a fun identity application build on EAS by Scroll


canvas overview

my colleague, Ming: "hey Peter, you know these pins that you can decorate your Crocs with? I want to build this, but on chain!"

--

users create a profile (aka Canvas), collect badges, and showcase them to others

users earn perks and benefits as a badge holder

projects have a new way to incentivize and reward users

--

product at https://scroll.io/canvas

code at https://github.com/scroll-tech/canvas-contracts

after 1 month, Canvas is now the #1 EAS schema in terms or number of attestations


canvas use cases

Ethereum Year Badge: a digital trophy that shows off the year your wallet made its debut on Ethereum

Ambient Swapooor: for users who have made one or more single swaps on Ambient for $500

Proof of Humanity Badge: this badge serves as a testament to your authenticity as a human participant within the Scroll ecosystem

https://scroll.io/canvas-and-badges#discover

--

future use cases:

reward OG users of your DeFi protocol, offer discounts


canvas architecture: badges

            ┌─────┐  attest  ┌─────────────────────┐  issueBadge   ┌─────────────┐
            │ EAS │ ───────▶ │ ScrollBadgeResolver │ ────────────▶ │ ScrollBadge │
            └─────┘          └─────────────────────┘               └─────────────┘

a badge is a smart contract that adds custom functionality on top of attestations

standard interface:

onIssueBadge and onRevokeBadge: hooks for custom actions/checks

badgeTokenURI: NFT-like standard metadata containing name, description, and badge image


canvas architecture: badges (2)

            ┌─────┐  attest  ┌─────────────────────┐  issueBadge   ┌─────────────┐
            │ EAS │ ───────▶ │ ScrollBadgeResolver │ ────────────▶ │ ScrollBadge │
            └─────┘          └─────────────────────┘               └─────────────┘

badge creation is fully permissionless, but badges must conform to certain standards

--

badge minting can be permissionless: the badge contract checks eligibility on-chain

it can also be backend-authorized: users submit a backend-issued signed permit


canvas architecture: badges (3)

simple example: ScrollBadgeWhale, earn a badge by holding 1000 ETH or more

contract ScrollBadgeWhale is ScrollBadgePermissionless {
    constructor(address resolver_) ScrollBadgePermissionless(resolver_) {
        // empty
    }

    function onIssueBadge(Attestation attestation) internal override returns (bool) {
        // ...
        return attestation.recipient.balance >= 1000 ether;
    }
}

https://github.com/scroll-tech/canvas-contracts/blob/master/src/badge/examples/ScrollBadgeWhale.sol


canvas architecture: badge resolver

            ┌─────┐  attest  ┌─────────────────────┐  issueBadge   ┌─────────────┐
            │ EAS │ ───────▶ │ ScrollBadgeResolver │ ────────────▶ │ ScrollBadge │
            └─────┘          └─────────────────────┘               └─────────────┘

the badge resolver is a global singleton contract

each canvas attestation goes through it; it executes some basic checks

e.g. does the badge contract exist? is the attestation payload well-formed?

https://github.com/scroll-tech/canvas-contracts/blob/master/src/resolver/ScrollBadgeResolver.sol


canvas architecture: profiles

┌─────────────────┐  create  ┌─────────┐
│ ProfileRegistry │ ───────▶ │ Profile │
└─────────────────┘          └─────────┘

user can mint a profile

a profile is an on-chain expression of preferences: what do you want to show to others?

configure an on-chain username and avatar

attach, detach, reorder badges

example: https://scroll.io/canvas/0x8ff5A977E3e6371928b47002c7f96fd7adEDE4BE

Profile


canvas architecture: profile registry

┌─────────────────┐  create  ┌─────────┐
│ ProfileRegistry │ ───────▶ │ Profile │
└─────────────────┘          └─────────┘

profiles are managed in the profile registry global singleton contract

ProfileRegistry


what else can you build with EAS?

how EAS can become a new paradigm for building dapps


EAS ideas

https://docs.attest.org/docs/idea--zone/thought-starters

digital identity & credentials

voting systems

content authenticity

social graphs

--

https://scroll.easscan.org/schemas/explore

Follow, Like, Username, Post

Sign a Document


EAS as a paradigm for dapps -- opportunity

example: social dapp

users can autonomously post their content using the client of their choice as standard attestations

different clients will index different subsets of this data, then interpret and display it in different ways


EAS as a paradigm for dapps -- challenges

on-chain attestations are now cheap -- but not free!

need to sponsor through Account Abstraction or use off-chain attestations

off-chain attestations are harder to distribute

--

EAS is deployed on many chains

how to collect and order events from multiple chains?


attestations in action -- what's next?

go mint your profile at Scroll Canvas

build a Canvas badge

go check out the EAS documentation

get your hands dirty and build cool new dapps!

--

get in touch

twitter/telegram @thegaram33

[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment