• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 1 year ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This repository implements a generic CCIP-Read gateway for fetching state proofs of data on other EVM chains. The intended use is for contracts on L1 to be able to fetch and verify data from contracts on L2 in a read context.

EVM CCIP-Read Gateway

This repository implements a generic CCIP-Read gateway framework for fetching state proofs of data on other EVM chains. This allows L1 smart contracts to fetch and verify state from L2s. The library is built to be as modular and interchangeable as possible. This means:

  • Anyone can operate their own gateway, but...
  • Only one gateway needs to be operated for each chain, regardless of the applications requesting data from it.
  • Gateways do not need to be trusted; their responses are fully verified on L1.
  • Contracts can fetch L2 state using a simple builder interface and callbacks.
  • Contracts can change targets (eg, a different L2) just by swapping out the address of a verifier contract for another.

While this functionality is written primarily with read calls in mind, it also functions for transactions; using a compliant library like Ethers, a transaction that includes relevant L2 proofs can be generated and signed.

Usage

  1. Have your contract extend EVMFetcher.
  2. In a view/pure context, use EVMFetcher to fetch the value of slots from another contract (potentially on another chain). Calling EVMFetcher.fetch() terminates execution and generates a callback to the same contract on a function you specify.
  3. In the callback function, use the information from the relevant slots as you see fit.

Example

The example below fetches another contract's storage value testUint.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { EVMFetcher } from '@ensdomains/evm-verifier/contracts/EVMFetcher.sol';
import { EVMFetchTarget } from '@ensdomains/evm-verifier/contracts/EVMFetchTarget.sol';
import { IEVMVerifier } from '@ensdomains/evm-verifier/contracts/IEVMVerifier.sol';

contract TestL2 {
    uint256 testUint; // Slot 0
    
    constructor() {
        testUint = 42;
    }
}

contract TestL1 is EVMFetchTarget {
    using EVMFetcher for EVMFetcher.EVMFetchRequest;

    IEVMVerifier verifier;
    address target;

    constructor(IEVMVerifier _verifier, address _target) {
        verifier = _verifier;
        target = _target;
    }

    function getTestUint() public view returns(uint256) {
        EVMFetcher.newFetchRequest(verifier, target)
            .getStatic(0)
            .fetch(this.getSingleStorageSlotCallback.selector, "");
    }

    function getSingleStorageSlotCallback(bytes[] memory values, bytes memory) public pure returns(uint256) {
        return uint256(bytes32(values[0]));
    }
}

Packages

This is a monorepo divided up into several packages:

A framework for constructing generic CCIP-Read gateways targeting different EVM-compatible chains. This repository implements all the functionality required to fetch and verify multiple storage slots from an EVM-compatible chain, omitting only the L2-specific logic of determining a block to target, and verifying the root of the generated proof.

An instantiation of evm-gateway that targets Ethereum L1 - that is, it implements a CCIP-Read gateway that generates proofs of contract state on L1.

This may at first seem useless, but as the simplest possible practical EVM gateway implementation, it acts as an excellent target for testing the entire framework end-to-end.

It may also prove useful for contracts that wish to trustlessly establish the content of storage variables of other contracts, or historic values for storage variables of any contract.

A Solidity library that verifies state proofs generated by an evm-gateway instance. This library implements all the functionality required make CCIP-Read calls to an EVM gateway and verify the responses, except for verifying the root of the proof. This library is intended to be used by libraries for specific EVM-compatible chains that implement the missing functionality.

A complete Solidity library that facilitates sending CCIP-Read requests for L1 state, and verifying the responses.

This repository also contains the end-to-end tests for the entire stack.

An instantiation of evm-gateway that targets Optimism. Combined with op-verifier, makes it possible for L1 contracts to fetch contract state data from Optimism.

A complete Solidity library that facilitates sending CCIP-Read requests for Optimism state, and verifying the responses.

More Repositories

1

ens

Implementations for ENS core functionality: The registry, registrars, and public resolvers.
JavaScript
1,159
star
2

ens-contracts

The core contracts of the ENS protocol
TypeScript
576
star
3

ens-app

Legacy ENS manager app
JavaScript
223
star
4

ensjs-v2

Javascript bindings for the Ethereum Name Service
JavaScript
206
star
5

subdomain-registrar

A registrar that sells subdomains to users on behalf of their owners
CSS
185
star
6

governance-contracts

Governance contracts for the ENS DAO
JavaScript
160
star
7

address-encoder

Encodes and decodes address formats for various cryptocurrencies
TypeScript
148
star
8

offchain-resolver

TypeScript
142
star
9

docs

Main documentation site for the ENS protocol
TypeScript
136
star
10

ens-app-v3

The official ENS manager app. Register and manage your ENS names here.
TypeScript
126
star
11

ensjs

ENS javascript library for contract interaction
TypeScript
123
star
12

ensdomains-landing

ENS Homepage V2, the main homepage of the ENS protocol.
TypeScript
105
star
13

ethregistrar

Solidity
92
star
14

thorin

A web3 native design system.
TypeScript
81
star
15

ens-metadata-service

TypeScript
71
star
16

resolvers

A collection of resolvers for ENS domains
JavaScript
69
star
17

dnssec-oracle

A DNSSEC oracle for Ethereum
Solidity
57
star
18

react-ens-address

React Component to resolve ENS names or reverse resolve addresses
JavaScript
57
star
19

ui

UI components and reusable functions
JavaScript
55
star
20

l2gateway-demo

A simple demonstration of a proposed L2 gateway specification
JavaScript
52
star
21

name-wrapper

JavaScript
45
star
22

ens-avatar

ENS Avatar resolver library for both nodejs and browser.
TypeScript
40
star
23

solsha1

Pure-solidity implementation of the SHA1 hash function.
Solidity
39
star
24

ens.domains

JavaScript
31
star
25

reverse-records

JavaScript
27
star
26

dnsprovejs

A tool to convince an Ethereum DNSSEC oracle of the contents of DNS records
TypeScript
25
star
27

buffer

A library for working with mutable byte buffers in Solidity.
Solidity
25
star
28

governance-web-react

JavaScript
23
star
29

governance-docs

Governance documentation for the ENS DAO
22
star
30

offchain-resolver-example

CCIP Offchain ENS Resolver example implementation
TypeScript
21
star
31

dnsregistrar

DNS registrar for ENS
Solidity
21
star
32

ens-manager

JavaScript
19
star
33

ethers-ccip-read

Ethers-rs CCIP-Read Middleware
Rust
19
star
34

media-kit

ens media kit resources
CSS
17
star
35

ens-validation

TypeScript
17
star
36

root

New ENS root contract
JavaScript
16
star
37

op-resolver

JavaScript
15
star
38

ens-twitter-api

TypeScript
14
star
39

ens-avatar-worker

Cloudflare worker that facilitates gasless avatar record updates via the ENS manager app
TypeScript
13
star
40

dnssecoraclejs

TypeScript/JavaScript library for generating DNSSEC proofs for the ENS DNSSEC oracle contract
TypeScript
11
star
41

court

Basic smart contracts for the arbitration processes.
Solidity
11
star
42

docs-v2

The Ethereum Name Service (ENS) is a distributed, open, and extensible naming system based on the Ethereum blockchain. This repository contains documentation, examples, and much more.
HTML
11
star
43

blacklist

Blacklisting tools for ENS
Solidity
10
star
44

optimistic-dnssec

Optimistic Implementation of the DNSSEC Registrar
Solidity
10
star
45

ens-archived-contracts

Collection of compiled ENS smart contracts
Solidity
10
star
46

hackathon-registrar

A simple ENS registrar for Hackathons
Solidity
9
star
47

gas-estimate-worker

Cloudflare worker for estimating registration gas costs with tenderly
TypeScript
9
star
48

name-reservations

Repository for 3-6 character name reservations in .eth.
CSS
9
star
49

enschain

Solidity
9
star
50

frontend-template

Starter web app for web3 developers
TypeScript
8
star
51

offchain-gateway-rs

Offchain CCIP Gateway Resolver implementation in Rust
Rust
7
star
52

learn-docs

Documentation for learning about ENS domains
7
star
53

renewal-widget

ENS Renewal widget displays a popup window if there are any expiring ENS names.
JavaScript
7
star
54

arb-resolver

JavaScript
7
star
55

ensips

ENS Improvement Proposals
TypeScript
7
star
56

hack.ens.domains

JavaScript
7
star
57

k-ens

ENS formally verified
6
star
58

auction

An auction contract for a one-off vickery style auction of 3-6 character names
JavaScript
6
star
59

my-ens-app

HTML
6
star
60

ccip-read-dns-gateway

ENS CCIP-Read DNSSEC Gateway
TypeScript
5
star
61

dnssectool

JavaScript
5
star
62

short-name-claims-app

A webapp for submitting claims for ENS short names (3-6 characters)
TypeScript
5
star
63

blog

Official Ethereum Name Service Blog
TypeScript
5
star
64

hack2018

5
star
65

research

ENS relevant research.
5
star
66

ccip-tools

CCIP Multitool for testing your offchain resolver!
TypeScript
5
star
67

ens-support-docs

ENS Support Docs
CSS
4
star
68

ens-reclaim-deposit-subgraph

TypeScript
4
star
69

hackathon-registrar-app

JavaScript
4
star
70

renewal

JavaScript
4
star
71

ens-print

Micro App for printing ENS stickers
JavaScript
4
star
72

ethlink-request

It fetches newly created subdomain and send request to eth.link to add to the DoH proxy
TypeScript
4
star
73

mock

Module for mocking ENS locally
JavaScript
4
star
74

integrations

List of integrations for ENS
TypeScript
4
star
75

reclaim

TypeScript
3
star
76

moonpay-worker

JavaScript
3
star
77

normalise-refund

JavaScript
3
star
78

test-utils

ENS test utilities
JavaScript
3
star
79

tldclaims

JavaScript
3
star
80

verify-ratification

Code to verify the votes ratifying the ENS constitution
JavaScript
3
star
81

usd-oracle

USD oracle research
3
star
82

batch-gateway

3
star
83

short-name-claims-subgraph

A subgraph for indexing ENS .eth short name claims
TypeScript
3
star
84

migration-scripts

Python
3
star
85

ens-faucet-worker

Cloudflare worker to help distribute testnet ETH to ENS manager app users
TypeScript
3
star
86

ens-bigquery-udf

JavaScript
3
star
87

ens-evmgateway

TypeScript
3
star
88

crypto-addr-serialize

Encode/Decode various cryptocurrency addresses
JavaScript
3
star
89

ens-og-image

TypeScript
2
star
90

enscluster

Config files for the ensdomains Kubernetes clusters
Python
2
star
91

dnssec-oracle-anchors

JavaScript
2
star
92

dao-pm

Project management repository for the ENS DAO
2
star
93

context-resolver

TypeScript
2
star
94

constitution-book-claim

ENS DAO constitution book claim site
TypeScript
2
star
95

ens-avatar-fallback

JavaScript
2
star
96

arbitrum-resolver

JavaScript
1
star
97

pm

an place to hold ENS project issues which cannot be assigned to any existing repos
1
star
98

ens-cfw

TypeScript
1
star
99

rasterize-gcp

ENS NFT Rasterization Service
JavaScript
1
star
100

punycode

Solidity
1
star