Skip to content

Instantly share code, notes, and snippets.

Goal

Currently the way to use sourcify is through the repo.sourcify.dev domain. This app talks to the sourcify backend in order to resolve metadata about the contract. This is fragile because if the sourcify backend were to for some reason be censored or disappear access to smart contract metadata would not be possible. This document outlines an approach to publishing contract metadata directly on Ethereum using ENS+IPFS, without having to make any additional on-chain transactions. The core idea is to resolve <address>.<chain-id>.sourcify.eth to a website with full verification of smart contract at that address.

Spec

The overall approach relies on the on-chain contract metadata hash, a custom ENS resolver, as well as precomputing IPFS objects off-chain.

Custom ENS resolver

import * as u8a from 'uint8arrays'
import sha3 from 'js-sha3'
const { keccak256 } = sha3
import HttpProvider from 'ethjs-provider-http'
import { DefaultStateManager } from '@ethereumjs/statemanager'
import { Trie } from '@ethereumjs/trie'
import { Address } from '@ethereumjs/util'
import { EVM } from '@ethereumjs/evm'
import { RLP } from '@ethereumjs/rlp'
import { Block, BlockHeader } from '@ethereumjs/block'

Exploreing the differences between how capabilities are represetned between UCAN and ReCap.

Comparison

UCAN ReCap
$RESOURSE Needs to be a URI Any String
$ABILITY One ability per resource ref Any nymber of abilities per resource ref
$EXTENSION Additional caveats for a specific resource Additional information, relevant for all resources
All resources Not possible In def property
import * as u8a from 'uint8arrays'
import sha3 from 'js-sha3'
const { keccak256 } = sha3
import HttpProvider from 'ethjs-provider-http'
import { DefaultStateManager } from '@ethereumjs/statemanager'
import { Trie } from '@ethereumjs/trie'
import { Address, toBuffer } from '@ethereumjs/util'
import { Blockchain } from '@ethereumjs/blockchain'
import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { EEI } from '@ethereumjs/vm'
@oed
oed / recap.md
Created November 25, 2022 16:51

This document describes how ReCap can adopt the capability format that is used by UCAN. Note that the design of UCANs structure is still in discussion, and if it changes we would want to adopt those changes (for v1 of UCAN).

Going to demonstrate by example. Here is what the ReCap json structure should look like.

{
  "att": {
    "http://example.com/public/photos/": {
        "crud/delete": []
 },
did:3:kjzl6cwe1jw149tlplc4bgnpn1v4uwk9rg9jkvijx0u0zmfa97t69dnqibqa2as
did:key:z6Mkqi6drzRN1raNjLcA8cQL4LvW6UWnHSti9DbfyJyZqr2T
did:key:z6MkkHCY8s5AL7fLT8J6QcjkWzF8rHAsKuSKZ2hNRCYCjmUb
<!doctype html>
<html>
<head>
<title>Webrtc Demo</title>
<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.js"></script>
</head>
<body>
<script type="text/javascript">
@oed
oed / asf
Created February 15, 2020 17:45
fdsfd