Package Logo
base_names
base_names@v0.1.0
Total Downloads
16
Published
1 months ago
Publisher
User Avatar PaulieB14

Readme

Base Name Service Substreams

A Substreams package for indexing Base Name Service (Base's ENS-compatible naming system) on the Base network.

🚀 Features

  • Full ENS Compatibility: Indexes all Base Name Service events (registrations, transfers, reverse resolution)
  • Real-time Processing: Processes events as they happen on Base network
  • No RPC Rate Limiting: Uses Substreams for efficient data processing
  • GraphQL Output: Generates GraphQL-compatible entity changes
  • Reverse Resolution: Supports wallet address to domain name lookups

📋 Prerequisites

🏗️ Building

# Build the Substreams package
cargo build --target wasm32-unknown-unknown --release

# Generate protobuf code
cargo build

🚀 Deployment

1. Deploy to Substreams Sink

# Deploy to The Graph's Substreams Sink
substreams deploy \
  --package-path substreams.yaml \
  --endpoint https://base.substreams.pinax.network:443 \
  --network base \
  --start-block 0

2. Deploy to Graph Studio

# Deploy to Graph Studio for GraphQL API
graph deploy \
  --product hosted-service \
  --node https://api.studio.thegraph.com/deploy/ \
  --ipfs https://api.thegraph.com/ipfs/ \
  base-names-substreams

📊 Data Sources

The Substreams package indexes events from these Base Name Service contracts:

  • Registry: 0x03c4738ee98ae44591e1a4a4f3cab6641d95dd9a
  • BaseRegistrar: 0x4ccb0bb02fcaba27e82a56646e81d8c5bc4119a5
  • RegistrarController: 0x79ea96012eea67a83431f1701b3dff7e37f9e282
  • ReverseRegistrar: 0xb94704422c2a1e396835a571837aa5ae53285a95

🔍 Indexed Events

Registry Events

  • NewOwner: Domain ownership transfers
  • NewResolver: Resolver contract assignments
  • NewTTL: TTL updates

Registrar Events

  • NameRegistered: New domain registrations
  • NameRenewed: Domain renewals
  • Transfer: NFT transfers

Controller Events

  • NameRegistered: Registration events from controller
  • NameRenewed: Renewal events from controller

Reverse Events

  • ReverseClaimed: Reverse resolution claims

📈 Performance Benefits

Compared to traditional subgraphs:

  • 10-100x faster indexing
  • No RPC rate limiting issues
  • Real-time processing from deployment
  • Efficient data streaming

🔧 Configuration

Environment Variables

# Base network RPC (optional - Substreams handles this)
BASE_RPC_URL=https://mainnet.base.org

# Substreams endpoint
SUBSTREAMS_ENDPOINT=https://base.substreams.pinax.network:443

Start Block

The package starts indexing from block 0 to capture all historical Base Name Service data.

📝 Usage Examples

Query Domains

{
  domains(first: 10) {
    id
    name
    labelName
    owner
    resolver
  }
}

Query Registrations

{
  registrations(first: 10) {
    id
    domain {
      id
      name
    }
    registrationDate
    expiryDate
    registrant
  }
}

Reverse Resolution

{
  reverseRegistrations(first: 10) {
    id
    domain {
      id
      name
    }
    address
  }
}

🛠️ Development

Local Testing

# Run locally with Substreams GUI
substreams gui substreams.yaml map_registry_events

# Test with sample data
substreams run substreams.yaml map_registry_events \
  --start-block 18000000 \
  --end-block 18000100

Adding New Events

  1. Add event signature to constants in src/lib.rs
  2. Create parsing function
  3. Add to appropriate mapping function
  4. Update protobuf definitions if needed

📚 Resources

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

Documentation

Modules

Maps icon
Maps

map
map_registry_events

9443dd5362251d5e333ecb7e13f7fa81de230431
map map_registry_events (
paramsstring
blocksf.ethereum.type.v2.Block
)  -> base_names.v1.RegistryEvents
substreams gui base-names@v0.1.0 map_registry_events

map
map_registrar_events

979fe96d15da04d42198094407b2bf8c170d5625
map map_registrar_events (
paramsstring
)  -> base_names.v1.RegistrarEvents
substreams gui base-names@v0.1.0 map_registrar_events

map
map_controller_events

37f30972b8ce75871acf476c105d023381865472
map map_controller_events (
paramsstring
)  -> base_names.v1.ControllerEvents
substreams gui base-names@v0.1.0 map_controller_events

map
map_reverse_events

1ee2a203d972b6d654b6c932ed417d94a299db68
map map_reverse_events (
paramsstring
)  -> base_names.v1.ReverseEvents
substreams gui base-names@v0.1.0 map_reverse_events
Protobuf

Protobuf Docs Explorer

base_names.v1