npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@alljoint-next/erc721aj

v0.1.2

Published

ERC721AJ contract for Solidity

Downloads

4

Readme

ERC721AJ

ERC721AJ is a tool set of the ERC721 Non-Fungible Token Standard that bases on ERC721A.

Overview

Tool List

  • contracts
    • ERC721AJ.sol
    • ERC721AJSaleable.sol
  • tasks
    • hardhat accounts
    • hardhat balance
    • hardhat generate
    • hardhat shuffle
    • hardhat compress
    • hardhat upload

Contracts

Installation

$ yarn add @hash-it/erc721aj --dev # or npm install --save-dev @hash-it/erc721aj

Usage

Once installed, you can use the contracts in the library by importing them:

ERC721AJ

pragma solidity ^0.8.4;

import '@hash-it/erc721aj/contracts/ERC721AJ.sol';

contract HashIt is ERC721AJ {
  constructor() ERC721A('HashIt', 'HI') {}

  function mint(uint256 quantity) external payable {
    // _safeMint's second argument now takes in a quantity, not a tokenId.
    _safeMint(msg.sender, quantity);
  }
}

ERC721AJSaleable

pragma solidity ^0.8.4;

import '@hash-it/erc721aj/contracts/extensions/ERC721AJSaleable.sol';

contract HashIt is ERC721AJSaleable {
  constructor() ERC721A('HashIt', 'HI') {}
}

API

ERC721AJ

Implementation of ERC721 Non-Fungible Token Standard, including the Metadata extension. And it inherits all the methods and properties from Ownable, Pausable, ERC721A, ERC721ABurnable, ERC721AOwnersExplicit, ERC721AQueryable.

Variables

version
string public version = 'v0.1.0';
_baseOrigin
string private _baseOrigin = '';
_baseExtension
string private _baseExtension = '.json';

Methods

constructor
constructor(string memory name_, string memory symbol_);
currentIndex
function currentIndex() public view virtual returns (uint256);

The next token ID to be minted.

totalBurned
function totalBurned() public view virtual returns (uint256);

The number of tokens burned.

totalMinted
function totalMinted() public view virtual returns (uint256);

Returns the total amount of tokens minted in the contract.

numberMintedBy
function numberMintedBy(address owner) public view virtual returns (uint256);

Returns the number of tokens minted by owner.

numberBurnedBy
function numberBurnedBy(address owner) public view virtual returns (uint256);

Returns the number of tokens burned by or on behalf of owner.

tokenURI
function tokenURI(uint256 tokenId)
  public
  view
  virtual
  override
  returns (string memory);

See IERC721Metadata-tokenURI. Returns the Uniform Resource Identifier (URI) for tokenId token. tokenURI = _baseURI + '/' + tokenId + _baseExtension

_baseURI
function _baseURI() internal view virtual override returns (string memory);

Base URI for computing tokenURI. _baseURI = _baseOrigin + '/'

setBaseURI
function setBaseURI(string memory origin, string memory extension)
  public
  virtual
  onlyOwner;

Set the origin and extension of the base uri.

pause
function pause() public virtual onlyOwner whenNotPaused;

Triggers paused state.

unpause
function unpause() public virtual onlyOwner whenPaused;

Returns to normal state.

ERC721AJSaleable

Enums

LaunchStage
enum LaunchStage {
  Auction,
  Whitelist,
  Public
}

We split the stage into 3 stage.

  • Auction: "Dutch Auction", It means an auction in which begins with a high asking price in the case of selling, and lowers it until some participant accepts the price, or it reaches a reserve price.
  • Whitelist: It means that the user can mints the token who is in the whitelist.
  • Public: Anyone can mints the token.

Structs

SaleConfig
struct SaleConfig {
  LaunchStage stage;
  bool isActive;
  bool isLimited;
  uint64 maxBalance;
  uint256 totalMinted;
  uint256 tierMinted;
}
  • LaunchStage: Current stage.
  • isActive: It's on sale or not.
  • isLimited: It's limited the max minted size.
  • maxBalance: The max number of balance of owner.
  • totalMinted: The max number of minted size.
  • tierMinted: The tier number of minted size.
SaleConfig
struct SaleConfig {
  LaunchStage stage;
  bool isActive;
  bool isLimited;
  uint64 maxBalance;
  uint256 totalMinted;
  uint256 tierMinted;
}
  • LaunchStage: Current stage.
  • isActive: It's on sale or not.
  • isLimited: It's limited the max minted size.
  • maxBalance: The max number of balance of owner.
  • totalMinted: The max number of minted size.
  • tierMinted: The tier number of minted size.
StageConfig
struct StageConfig {
  uint64 startAt;
  uint64 maxMint;
  uint64 price;
}
  • startAt: The stage starts at "unix timestamp".
  • maxMint: The max number of caller mint in one times.
  • price: The price of token.
AuctionStageConfig
struct AuctionStageConfig {
  uint64 startAt;
  uint64 maxMint;
  uint64 startPrice;
  uint64 endAt;
  uint64 endPrice;
  uint64 step;
}

Kind of StageConfig.

  • startAt: The auction starts at "unix timestamp".
  • maxMint: The max number of caller mint in one times.
  • startPrice: The higher price of auction.
  • endAt: The stage sale ends at "unix timestamp".
  • endPrice: The lower price of auction.
  • step: The step of auction.

example:

  • startAt: 11:00
  • endAt: 12:00
  • startPrice: 1 eth
  • endPrice: 0.5 eth
  • step: 6

| Step | Time | Price | | ---- | :-----------------: | ------- | | 0 | 11:00:00 - 11:09:59 | 1.0 eth | | 1 | 11:10:00 - 11:19:59 | 0.9 eth | | 2 | 11:20:00 - 11:29:59 | 0.8 eth | | 3 | 11:30:00 - 11:39:59 | 0.7 eth | | 4 | 11:40:00 - 11:49:59 | 0.6 eth | | 5 | 11:50:00 - 11:59:59 | 0.5 eth |

SaleableConfigs
struct AuctionStageConfig {
  SaleConfig currentSaleConfig;
  AuctionStageConfig currentAuctionStageConfig;
  StageConfig currentWhitelistSaleConfig;
  StageConfig currentPublicSaleConfig;
}

Variables

saleConfig
SaleConfig public saleConfig;

The config fo sale.

auctionStageConfig
AuctionStageConfig public auctionStageConfig;

the config of auction stage.

whitelistStageConfig
StageConfig public whitelistStageConfig;

The config of whitelist stage.

publicStageConfig
StageConfig public publicStageConfig;

The config of public stage.

whitelistMerkleRoot
bytes32 public whitelistMerkleRoot;

The merkle root of whitelist. See Merkle Tree.

_feePart
uint256 private _feePart;

The part of fee. Fee = balance * _feePart / 1000

_feeAddress
address private _feeAddress;

The address of fee.

Methods

_checkStageSaleable
function _checkStageSaleable(
  SaleConfig memory _saleConfig,
  StageConfig memory _stageConfig,
  LaunchStage stage,
  uint64 qty
) internal view virtual;

Check if it can be sold according to configs.

Error Messages:

  • Saleable: not on sale
  • Saleable: sold out
  • Saleable: exceed max balance
  • Saleable: exceed max mint
  • Saleable: insufficient funds
preserve
function preserve(uint64 qty, address to) public onlyOwner;

Owner can preserves token anytime.

Error Messages:

  • Saleable: sold out
_refundIfOver
function _refundIfOver(uint64 totalPrice) internal;

Refunds if the funding over the total price.

mintPublic
function mintPublic(uint64 qty) external payable virtual nonReentrant;

Mints in the public stage.

mintWhitelist
function mintWhitelist(uint64 qty, bytes32[] calldata merkleProof)
  external
  payable
  virtual
  nonReentrant;

Mints in the whitelist stage, if caller can provides the proof.

getAuctionPrice
function getAuctionPrice(uint64 qty) public view virtual returns (uint64 price);

Gets current the auction price.

mintAuction
function mintAuction(uint64 qty) external payable virtual nonReentrant;

Mints in the auction stage.

setSaleConfig
function setSaleConfig(SaleConfig memory config) public onlyOwner;

Sets the config of sale.

setAuctionStageConfig
function setAuctionStageConfig(AuctionStageConfig memory config)
  public
  onlyOwner;

Sets the config of auction stage.

setWhitelistStageConfig
function setWhitelistStageConfig(StageConfig memory config) public onlyOwner;

Sets the config of whitelist stage.

setPublicStageConfig
function setPublicStageConfig(StageConfig memory config) public onlyOwner;

Sets the config of public stage.

setWhitelist
function setWhitelist(bytes32 _whitelistMerkleRoot) public onlyOwner;

Sets the merkle root of whitelist.

setFee
function setFee(address target, uint64 num) public onlyOwner;

Sets config of the fee.

withdraw
function withdraw(address to) external onlyOwner nonReentrant;

Owner can withdraw the all balance to address and fee address.

getWhitelistSeats
function getWhitelistSeats(address to) public view returns (uint64);

Gets whitelist seats which you can mint.

getSaleableConfigs
function getSaleableConfigs()
  public
  view
  returns (SaleableConfigs memory currentConfigs);

Gets all config.

Tasks

accounts

$ yarn hardhat [GLOBAL OPTIONS] accounts # For global options help run: yarn hardhat help, for command options help run: yarn hardhat accounts --help

Prints the list of accounts of current nemonic or private key.

balance

$ yarn hardhat [GLOBAL OPTIONS] balance --account <ADDRESS> # For global options help run: yarn hardhat help, for command options help run: yarn hardhat balance --help

Prints an account's balance of current mnemonic or private key. Or you can set a specific address of account.

generate

$ yarn hardhat [GLOBAL OPTIONS] generate --description <STRING> [--dry] [--duplicate] [--extension <STRING>] --input <STRING> --name <STRING> --output <STRING> --seed <STRING> --skip <INT> --start <INT> --total <STRING> # For global options help run: yarn hardhat help, for command options help run: yarn hardhat generate --help

Generate media and metadata of NFT. It can set the layer, ratios of traits, traits randomness pick, metadata.

Usage

  1. Prepares the trait.

    We supports .png, .gif file.

  2. Setups the folder of layer.

    folder name: <z-index>.<trait-type>

    Type of trait: Background, Actor, Hat
    Z index of trait: Hat > Actor > Background, Actor 在 Background 之上
    .
    ├── 1.Background
    ├── 2.Actor
    └── 3.Hat
  3. Setups the rarity of trait.

    file name: <trait-value>__<ratio>.<file-extension>

    Name of trait: Blue (AUD).png, Red (AUD).png, Yellow (AUD).png
    Ratio of trait: 60%, 20%, 20%
    .
    ├── 1.Background
    │   ├── Blue (AUD)__60%.png # 60%
    │   ├── Red (AUD)__20%.png # 20%
    │   └── Yellow (AUD)__20%.png # 20%
    ├── 2.Actor
    │   ├── Boy White__60%.png # 60%
    │   └── Girl White__40%.png # 40%
    └── 3.Hat
        ├── Bandana Paisley (AUD).png # 33%
        ├── Bandana Super Star (AUD).png # 33%
        └── Camp Cap (AUD).png # 34%
  4. Executes the command.

    $ yarn hardhat generate --description "PFP of MeMe" --input "MeMe" --name "MeMe" --output "MeMe Output" --total 1000
  5. Checks the output folder.

    Output:

    .
    ├── Media
    │   └── 0.png
    └── Metadata
        └── 0.json

    Metadata:

    {
      "name": "Meme #0",
      "description": "PFP of MeMe",
      "attributes": [
        {
          "trait_type": "Background",
          "value": "Yellow"
        },
        {
          "trait_type": "Hat",
          "value": "Bandana Paisley (AUD)"
        }
      ],
      "image": "../Media/0.png"
    }

shuffle

$ yarn hardhat [GLOBAL OPTIONS] shuffle --input <STRING> --seed <STRING> # For global options help run: yarn hardhat help, for command options help run: yarn hardhat shuffle --help

Shuffle files inside both 'Media' and 'Metadata' folder under input parameter.

Usage

  1. After execute generate command and get your output folder.

  2. Executes the command.

$ yarn hardhat shuffle --input "Project Output Path" --seed "Hash it"
  1. The shuffle is Complete!!

P.S. Using identical seed get the same suffle.

compress

$ yarn hardhat [GLOBAL OPTIONS] compress [--extension <STRING>] --fit <STRING> --height <INT> --input <STRING> --level <STRING> --output <STRING> --quality <INT> --range <STRING> --width <INT> # For global options help run: yarn hardhat help, for command options help run: yarn hardhat compress --help

Compress all media inside 'Media' folder under input parameter. The extension is default to .png, change as your input media extension.

Usage

  1. After execute generate command and get your output folder.

  2. Executes the command.

$ yarn hardhat compress --input "Project Output Path"
  1. The compress is Complete!!

upload

$ yarn hardhat [GLOBAL OPTIONS] upload --auth <STRING> [--extension <STRING>] --input <STRING> --name <STRING> # For global options help run: yarn hardhat help, for command options help run: yarn hardhat upload --help

Upload files inside both 'Media' and 'Metadata' folder under input parameter to Pinata.

Upload project name is default to dirName. Set name if want to change.

Usage

  1. After execute generate command and get your output folder.

  2. Executes the command.

$ yarn hardhat upload --input "Project Output Path" --auth "YOUR Pinata JWT Token"
  1. The upload is Complete!!

Contact