near / core-contracts

Core contracts: reference staking pool, lockup, voting, whitelist, multisig.
321 stars 130 forks source link

[contract] Top Level Name Registrar #25

Open ilblackdragon opened 4 years ago

ilblackdragon commented 4 years ago

Description

NEAR Protocol uses human-readable account names. This allows for much better user experience for regular blockchain use cases. We also expect that these accounts will be used across various novel use cases (e.g., DNS, certification, and applications) as they represent the user’s digital identity that is also connected to finances, data ownership, and cryptography—and, in the future, supporting more of Decentralized Identifier (DID) standard.

We split account names into two groups by length: those longer than 32 characters and those shorter. We expect that shorter accounts names will have way more value for users compared to longer ones. Longer account names can register on a first-come-first-serve basis.

To give everyone a fair chance to acquire short account names, a naming auction will start shortly after MainNet launch.

Each week’s account names—such that sha256(account_id) % 52 is equal to the week since the launch of the auction—will open for bidding. Auctions will run for seven days after the first bid, and anyone can bid for a given name. A bid consists of a bid and mask, allowing the bidder to hide the amount that they are bidding. After the seven days run out, participants must reveal their bid and mask within the next seven days. The winner of the auction pays the second-largest price.

Proceeds of the auctions then get burned by the naming contract, benefiting all the token holders.

Spec

API

struct Bid {
  amount: Balance,
  commitment: Base58Hash
}

struct Auction {
   start_blockheight: BlockHeight,
   bids: Map<AccountId, Bid>,
   reveals: Vec<AccountId, Balance>,
}

struct Registrar {
  start_blockheight: BlockHeight,
  auctions: Map<AccountId, Auction>
}

impl Registrar {
   /// Construct this contract and record starting block height.
   pub fn new(auction_period: BlockHeight, reveal_period: BlockHeight) -> Self;
   /// Attached deposit serves as locking funds for given account name.
   /// Commitment is `hash(masked amount + salt)` in base58 encoding.
   /// bid fails if `account_id` is not yet on the market based on `hash(account_id) % 52 > weeks from start_blockhegiht`
   /// bid records a new auction if auction for this name doesn't exist yet.
   /// bid fails if auction period expired.
   pub fn bid(account_id: AccountId, commitment: Base58Hash);

   /// Reveal shows the masked amount and salt. Invalid reveals are declined.
   /// Reveal fails if auction is still going.
   /// Reveal fails if `hash(masked_amount + salt)` != `commitment` by env::predeccessor_account_id()`
   pub fn reveal(account_id: AccountId, masked_amount: U128, salt: String);

   /// Withdraw funds for loosing bids.
   /// Withdraw fails if account_id doesn't exist, if `env::predeccessor_account_id()` didn't bid or if auction is still in progress or not all bids were revealed yet.
   /// If not all bids were revealed but required reveal period passed, can withdraw.
   pub fn withdraw(account_id: AccountId);

   /// Creates the new name with given public key for the winer.
   pub fn claim(account_id: AccountId, public_key: Base58PublicKey);
}

State machine

Name auction can be in the next states:

bowenwang1996 commented 4 years ago

What happens when there is no bid for some name?

ilblackdragon commented 4 years ago

@bowenwang1996 If there is no bid - there is no auction. Auction starts with the first bid.

ilblackdragon commented 3 years ago

It worth noting that there are some TLAs that are valuable for user experience and user onboarding (examples are .eth, .aurora) as well as proper nouns of popular companies (.google, .binance).

It make sense to have a list of such names that are not allowed to be auctioned off. Instead a DAO would be managing what is deployed there or pass ownership to the company owner for proper name.

We should build a list of these names and use Sputnik DAO for managing it.

Registrar contract should allow DAO "owner" contract to execute registration for this whitelisted set.

joshuajbouw commented 2 years ago

Would the bidding and selling of these take place at all? Or were these plans scraped?