M2 Domain is a Blockcahain base domain service build on Polygon Pos chain, that help individual, organisation to register their domain name on the smart contract and own it. It allows suers to register a domain name and associate it with a digital asset as NFT which is a digital representation of the domain name created insted of a long complex address. The domain is mapped such that only the owner of the domain can have access to the editing feature, except a full ownership has been transfer to another user.
The Domains contract inherits from ERC721URIStorage, which is an OpenZeppelin library contract that implements the ERC721 interface for non-fungible tokens with a URI-based metadata extension.
owner
: the address of the contract owner, who has the ability to withdraw funds from the contract._tokenIds
: a Counters.Counter object that is used to keep track of the current token ID when minting new tokens.names
: a mapping of token IDs to domain names.records
: a mapping of domain names to records.domains
: a mapping of domain names to owner addresses.tld
: a string representing the top-level domain for all registered domains.SVG_PART_ONE
: a string containing SVG data for a graphical representation of the domain name.
constructor
: sets the contract owner and top-level domain.register
: allows a user to register a domain name by minting a new token with the given name.setRecord
: allows the owner of a domain to set the record associated with the domain.getRecord
: allows anyone to retrieve the record associated with a domain.transfer
: allows the owner of a domain to transfer ownership of the domain to another Ethereum addressgetDomainOwner
: allows anyone to retrieve the owner address associated with a domain.tokenURI
: overrides the tokenURI function from the ERC721URIStorage contract to return metadata for a given token ID.
In addition, the contract includes several modifiers for access control:
onlyOwner
: restricts access to functions that can only be called by the contract owner (specified in the owner variable)isAuthorized
: restricts access to functions that can only be called by the owner of a particular domainunregistered
: can be applied to functions that require a domain name that has not already been registered.
Base64
: contains functions for encoding and decoding base64 strings.StringUtils
: contains string manipulation functions.
- React
- TelwinCss
- Hardhat
- Metamask
- Quicknode end point
- Solidity
- Openzepelin
- Polygon testscan
- Mumbai Testnet
- ERC721
Node.js v16 or higher
Hardhat v2.0 or higher
solidity v^0.8.10
Polygon mumbai test network
- Fork the repo
- Clone the repo
cd domainscontract
runnpm install
to install all the dependencies- After cloning the repo, go to [Quicknode](https://www.quicknode.com/endpoints) to make an account and generate your API endpoint key
- Rename the
.env.example
file on the root of the project to.env
, then paste your API endpont key in the.env
file - Run
npx hardhat run scripts/deploy.js --network mumbai
to deploy the contract to the polygon mumbai network - Your result of successful deployment should look like this:
Contract deployed to: 0x0AB61D0c7286c5c12Ef0eaaFD90B446e643DFe26
Minted domain grandidah.m2
Set record for grandidah.m2
Owner of domain grandidah: 0xC475cbd2225B641266C2CB9d0151982C3596085C
Contract balance: 0.1
https://mumbai.polygonscan.com/address/0x0AB61D0c7286c5c12Ef0eaaFD90B446e643DFe26
- From the project root directory:
- Run
npm install
to install all the dependencies - Run
npm run start
to start the project - Go to http://localhost:3000 to see the project running
- Go to https://domain-serviceon-polygon.vercel.app/
- Click on Connect wallet to connect your wallet and switch to mumbai
- Enter the domain you want to mint, provide the Domain description, and click 'mint' to continue
- Your domain will show as the recent mint domain on the dashboard
- Click on the Domain to see your digital representation of the domain on opensea testnet
If you want to contribute to this project, please read the contributing guide. If you have any ideas or suggestions, feel free to open an issue or a pull request. If you like this project, please give it a star ⭐️
Built with 💗 by samailamalima. Inspired by BuiltSpace, powered by Grandidah LLC.
This project is mainly for educational and demonstration purposes only. The smart contract has not been audited and should not be used in a production environment. Always thoroughly review and test any smart contract before deploying it.