Skip to content

namehash/namekit-contracts

Repository files navigation

NameKit contracts

How it works?

This project is one of many components of NameKit. The goal of this contract template is helping ENS grow by incentivizing more wallets and apps to promote ENS name registration and renewal to their users. The contract enables those wallets & apps to define a custom price premium on top of the base rate for .eth names. This enables the creation of recurring revenue streams for builders who help ENS grow. We hope this creates more incentives for wallets & apps to onboard their users into ENS.

Each wallet and app should deploy their own instance of this contract that defines their specialized treasury address.

This contract only works for the registration and renewal of direct subnames of ".eth".

The contract is designed and optimized to spend as little gas overhead as possible. Users pay a little more for the app to have this revenue opportunity.

sequenceDiagram
	autoNumber
	App ->> User: Request base price + custom fee
  User ->> NameKit: Register tx
	NameKit ->> ENS: Forward register tx
	ENS -->> User: Send ENS name
	ENS -->> NameKit: Send refund (custom fee)
  1. The app gets the base price of the desired ".eth" name and adds their customized price premium. The app then requests this total value in the registration transaction to be approved by the user.
  2. The user approves the transaction, interacting with app's custom deployment of the NameKit Controller contract.
  3. The app's custom deployment of the NameKit Controller forwards the transaction to ETHRegistrarController with all the user-provided parameters.
  4. ETHRegistrarController sends the ENS name NFT to the user.
  5. The app's custom deployment of the NameKit Controller accrues their customized price premium, which can be withdrawn to their custom treasury address whenever desired.

Getting started

Required

  • Node and Yarn, to run the scripts
  • Infura API key, to deploy and interact with contracts
  • Etherscan API key, to verify contracts

Deploying your contracts

  1. Install all the dependencies with Node and Yarn.

    yarn
    
  2. Copy the sample.env file and rename it to .env, then complete all missing variables.

  3. If having the same contract address in testnet and mainnet is important to you, then the following steps are needed.

    1. Same treasury address across networks.
      • If it's an EOA (address that comes from private key), no worries.
      • If you want a Safe Multisig, then create your treasury here.
    2. The deployer private key must be a fresh account, with zero transactions. Make sure to send some ETH to this account in order to pay for fees on contract deployment.
  4. Deploying contracts

    • Sepolia
    yarn deploy:sepolia
    
    • Mainnet
    yarn deploy:mainnet
    
  5. Fork this repo and change the NamekitController and treasury addresses on README, for internal documentation.

🎉 Congrats, now you have a new way to generate revenue!!

Commands

Before running these commands, make sure to:

  • Generate the typechain interfaces: yarn compile
  • Change CHAIN_ID in .env to the desired network you want to interact with. 1 = Mainnet, 11155111 = Sepolia.

For registering a name through

  • Make sure to fill the environment variables
    • PLATFORM_URL: For making your registrations to count on ENSIP-14 standard.
    • NAME_TO_REGISTER
yarn register-name

For withdrawing collected fees

yarn withdraw

Contracts deployed

Mainnet

Sepolia

ABIs are avaiable on Etherscan

License

Licensed under the MIT License, Copyright © 2023-present NameHash Labs.

See LICENSE for more information.

About

Earn revenue for helping ENS grow

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published