Skip to content

aztemi/solidity-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solidity-utils

Utility extensions for solidity smart contracts

Available extensions

Below is the only contract extension made available at the moment. More are planned for later.

1. RandomIDsGenerator.sol

It randomly generates number IDs. It can be used to assign token IDs for a random mint.

Usage:

// Step 1. Import the RandomIDsGenerator contract
import "@aztemi/solidity-utils/contracts/RandomIDsGenerator.sol";

// Step 2. Derive your contract from it
contract MyContract is RandomIDsGenerator {
  uint256 constant NFT_MAX_SUPPLY = 1000;

  // Step 3. Initialize with the max amount of IDs supply
  constructor() RandomIDsGenerator(NFT_MAX_SUPPLY) {}

  function getRandomTokenID() public returns (uint256) {
    // Step 4. Generate next random ID
    uint256 tokenId = _nextID();

    return tokenId;
  }

  // No of NFTs available for minting
  function availableSupply() public view returns (uint256) {
    // Step 5 (Optional). Get number of IDs remaining
    return _remainingSupply();
  }

  // No of NFTs already minted
  function mintedSupply() public view returns (uint256) {
    return NFT_MAX_SUPPLY - _remainingSupply();
  }

  // Total number of NFTs
  function maxSupply() public pure returns (uint256) {
    return NFT_MAX_SUPPLY;
  }
}

About

Utility libraries for solidity smart contracts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published