Bitcoin Name System (BNS)
Register your domain
Let's build the Bitcoin Name System (BNS), a decentralized, open, and permissionless naming system on Bitcoin.
buy and sell BNS name
register a human-readable name like 'kevin.bit' or 'bob.btc'
map a human-readable name like 'jill.btc' to a machine-readable id like a Bitcoin address
Write the BNS smart contract
It turns out that writing the Bitcoin Name System smart contract is very simple. Here is a basic contract to provide a DNS-like naming system on BitcoinEVM.
Extending ERC-721, we only need to implement the register()
function to register a new name as an NFT and the map()
function to map a human-readable name like 'bob.sat' to a machine-readable id like a wallet address.Sending and receiving a BNS name is now as simple as sending and receiving an NFT. You can also trade the BNS name on open markets since it's an ERC-721.
Clone the smart contract examples
We've prepared a few different examples for you to get started. The BNS example is located at smart-contract-examples/contracts/BNS.sol.git clone https://github.com/bitcoinevm/smart-contract-examples.git
Compile the contracts
To compile your contracts, use the built-in hardhat compile
task.cd smart-contract-examplesnpm installnpx hardhat compile
Deploy the contracts
Review config file hardhat.config.ts
. The network configs should look like this.networks:
Make sure the accounts in hardhat.config.ts have some BTC.
Interact with the contracts
Once the contracts are deployed, you can interact with them. We've prepared a few hardhat tasks
to make it easy for you to interact with the contracts.
Last updated