Skip to content

lgaroche/monique-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monique 👵

⚠️ Work in progress: See below for the current status

✅ Live demo: https://monique.app

Monique is an Ethereum address index.
Every address that is referenced in the chain (e.g. sent or received a transaction, a token, also every contract created...) is assigned a unique number. This number can be converted from and to a short word mnemonic for easy sharing and memorization.
The API can be integrated in wallets, block explorers, and other tools where users read or write addresses.

There are two distinct ranges for the index:

  1. Immutable index. Automatically calculated for every address witnessed on-chain, about 537 million addresses can fit in 3 words, the next trillion addresses will fit in 4-words. There are currently 255 million addresses in the index.
  2. Mutable index. These indices will be registerable in a smart contract and transferrable as an ERC-721 NFT. They will cover the 1 and 2-word range. This is still in development.

The blockchain is indexed according to the rules defined below.

Conversion between mnemonic and index follows the BIP39 logic, with a few modifications:

  • Indices are padded with 0s to fit in 7, 18, 28 or 40 bits.
  • Then they are prefixed with a 4-bit checksum:
    • Up to index 218 (mutable index), the checksum is the last 4 bits of the hash of the index.
    • Above index 218 (immutable index), the checksum is the last 4 bits of the hash of associated address.
  • The resulting number (whose bit length is a multiple of 11 bits) is split in 11-bit chunks, each chunk representing a word in the BIP39 english wordlist.

Indexing rules

The immutable index is an ordered set of addresses. To allow room for the mutable range, the first index is 262144 (218).
Addresses are indexed in the following order, for each block:

  1. Block author (miner/producer)
  2. For each transaction in the block:
    1. Sender (from)
    2. Receiver (to)
    3. For each log in the transaction:
      1. If the log is an ERC-20 or ERC-721 Transfer:
        1. Transfer from
        2. Transfer to
      2. If the log is an ERC-1155 TransferSingle or TransferBatch:
        1. Transfer operator
        2. Transfer from
        3. Transfer to
  3. Block withdrawals recipients, in order

Things to do

  • Mutable monics smart contract
  • Index integrity (e.g. use a trie with root hash as checkpoints)
  • Rebuild index from flat db?
  • Better code documentation
  • API docs
  • Support multiple RPC endpoints type

How to build the index

Building the index requires a full Ethereum node synced with all the block receipts history. I have tested with a local Erigon archive node and a Reth node with the following pruning config:

# Reth pruning configuration
[prune.parts]
# senders_recovery pruning is optional, but may speed up the sync
# senders_recovery = { distance = 65_536 }
transaction_lookup = { distance = 65_536 }
account_history = { distance = 65_536 }
storage_history = { distance = 65_536 }

It will take about 5 days to build the first index, depending on your hardware.
The API will be available as soon as the indexer start but may be slow to respond during index commit to disk.

Query the API

The indexer exposes the API on port 8000. The Monique API has 3 routes. Each route return a JSON object describing the Monic:

{
  "index": "number",
  "monic": "string",
  "address": "string"
}
  • GET /index/:index
    Query by index.
  • GET /alias/:address
    Query by address.
  • GET /resolve/:monic
    Resolve a monic.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages