This repo contains a Solidity smart contract that implements functionality for minting and managing licenses as non-fungible tokens (NFTs). The contract is based on the ERC-1155
token standard.
-
Minting Licenses: Users can mint new licenses by paying 0.0042 ether. This payment is evenly split between two specified partner addresses. Each license is represented as a unique
ERC-1155
token. -
License Duration and Expiry: Each license is valid for a specific duration from the time of minting. The contract includes a mapping from token IDs to their expiry timestamps, allowing for easy verification of whether a license is still valid or not.
-
License Ownership: The contract keeps track of the licenses owned by each account, allowing for quick retrieval of the license IDs associated with an address.
-
License Verification: The contract provides functions to check if a particular account is the owner of a specific license. It also includes a function to determine the remaining days of validity for a license.
-
IPFS Metadata: The contract includes a function that returns a hardcoded IPFS URI for all tokens.
To interact with this contract using the Remix IDE:
- Deploy your NFT image to IPFS and copy the CID of it.
- Paste the CID to
metadata.json
file and customize the metadata file. - Deploy the
metadata.json
file to IPFS and save the CID of it to use it in the smart contract. - Go to Remix.
- Click on the file icon from the left panel to open up the file explorer.
- Then click on the "New File" icon to create a new file and name it
"MyLicenseContract.sol"
. - Copy and paste the Solidity code into this new file.
- Paste the
metadata.json
file's CID to theuri
function. - You can customize some part of the contract. e.g.
licensePrice, licenseDuration, partner1 and partner2
- Make sure the compiler version in the Remix IDE matches the version specified in the contract (0.8.4).
- Compile the contract by clicking on the "Solidity Compiler" button or press Ctrl + S.
- Deploy the contract by going to the "Deploy & Run Transactions" section, choose the appropriate environment and click the "Deploy" button.
- You can now interact with the contract with using the buttons that have appeared in the "Deployed Contracts" section.
- Additionally you can deploy to the Goerli Test Network and test it with better interface.
This contract uses OpenZeppelin's contracts and libraries for secure and reliable development.
@openzeppelin/contracts/token/ERC1155/ERC1155.sol
: For the basic functionality of the ERC-1155 token standard.@openzeppelin/contracts/utils/Counters.sol
: For managing token IDs.@openzeppelin/contracts/access/Ownable.sol
: For owner-only functionality.@openzeppelin/contracts/utils/Strings.sol
: For string conversion.
This contract is intended for educational purposes and should not be used in production without further testing and security measures.