Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

ethers-addressbook crate #769

Merged
merged 7 commits into from
Jan 7, 2022
Merged

Conversation

roynalnaruto
Copy link
Collaborator

@roynalnaruto roynalnaruto commented Jan 7, 2022

Motivation

The ethers-addressbook crate adds the addresses of frequently used contracts for various networks (mainnet, ropsten, etc.). We expose a function contract:

pub fn contract<S: Into<String>>(symbol: S) -> Option<Contract>;

A Contract struct is simply a hash map, mapping a network name to that contract's address on that network.

use ethers_core::types::{Address, Chain};

struct Contract {
    addresses: HashMap<Chain, Address>,
}

The goal is to use this crate as dependency in Foundry to allow users to cast send transactions targeting contracts such as DAI, USDC or other commonly used ones as per the below UX:

$ cast send dai transfer vitalik.eth 100

Future PRs are expected to be limited to simply adding more contracts and/or their addresses for more networks (chain IDs) in the ethers-addressbook/src/contracts/contracts.json JSON file.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@roynalnaruto roynalnaruto changed the title tokenlist crate ethers-addressbook crate Jan 7, 2022
Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, interested in any thoughts/comments on this from @brockelmore @prestwich @mattsse. We can start hardcoding more addresses, e.g. the ones from MEV Inspect https://github.com/flashbots/mev-inspect-rs/blob/master/src/addresses.rs, or figure out some nice way (maybe a build.rs?) to further populate the addressbook with tokenlist information for token name / ticker / addr

@gakonst gakonst merged commit 2d05ea6 into gakonst:master Jan 7, 2022
@mds1
Copy link

mds1 commented Jan 7, 2022

Just came across this feature, and really like this idea and how it fits into cast. Two thoughts:

  1. Use chain ID instead of networks names. This will remove any chance of ambiguity but also make it easier to seed the address book from a tokenlist
  2. TrueBlocks already maintains a mapping of contract address to names, which you can see by installing it and running chifra names. I don't know the details about how that list was generated, where it lives, or how to update it, but it might be a good idea to leverage that and have a global Ethereum address book instead of building up a brand new one from scratch here. cc'ing @tjayrush from TrueBlocks

@tjayrush
Copy link

tjayrush commented Jan 7, 2022

Thanks, Matt. Yeah. We've been collecting names and addresses since about 2016, so there are currently ~11,300 names in our database. It's here: https://github.com/TrueBlocks/trueblocks-core/blob/master/src/other/install/names/names.tab

No guarantee that it's accurate (except for the entries that have on-chain as their source (~4,750) which we pulled from the token's own on-chain data.

We always wanted this to be public -- we don't feel bad about collecting names if people are going to post them on Twitter for example, so would be totally open to building something that works.

If you look at the rest of TrueBlocks, you'll see we publish a periodic manifest of the index we build to IPFS. This lets us run this index database without any infrastructure costs. Our code reads the IPFS hash of the manifest from a smart contract and pulls the entire index database from IPFS with no servers.

We're going to be adding the names database to that manifest soon, so you're very welcome to read that data as we do.

Here's a short video explaining that process: https://unchainedindex.io/

I made basically the same comment here: https://community.tokenlists.org/t/putting-these-token-lists-on-ipfs-and-then-publishing-the-ipfs-hash-to-a-smart-contract/596

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants