Socket
Socket
Sign inDemoInstall

@allowlist/dev

Package Overview
Dependencies
116
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @allowlist/dev

The easiest and most-flexible library for adding Allowlists to Solidity smart contracts.


Version published
Maintainers
1
Install size
27.2 MB
Created

Readme

Source

Allowlist.dev SDK + Contracts

The easiest and most-flexible library for adding Allowlists to Solidity smart contracts.

For a complete guide on installation and usage, visit https://allowlist.dev.

Quickstart

1. Add the Allowlist packages.

npm add @allowlist/dev

2. Generate your allowlist.json

allowlist gen winners.csv 
? Enter your BIP39 mnemonic seed phrase: ...

This will generate an allowlist.json file in the current directory, and tell you which signer addresses to use:

Generated the following allowlist groups:

Group:   0x12345...
Wallets: 1234

Note - if you need to generate a BIP39 mnemonic, use:

allowlist bip39

3. Add functions and modifiers to your Smart Contract

Add the mint groups to your contract, and use the allowlist helpers for your mint function.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@allowlist/dev/contracts/AllowList.sol";
import "erc721a/contracts/ERC721A.sol";

contract MyNFT is ERC721A, AllowList {
    constructor() ERC721A("My NFT", "NFT") {
        _addAllowList(
            address(0x12345...), // group address
            0.1 ether,           // the mint price
            1672552800,          // start timestamp
            1675231200,          // end timestamp
            1                    // max per wallet
        );
    }

    function allowListMint(
        address _address,
        uint256 _count,
        bytes calldata _signature,
        uint256 _nonce
    ) 
      external 
      payable 
      useSignature(_address, _count, _signature, _nonce) 
    {
        _mint(_address, _count);
    }
}

4. Mint from your Frontend

Call the mint function from your frontend of choice.

Example with React + wagmi:

import { useAccount, useContract } from 'wagmi'
import { useSignature } from "@allowlist/dev"

const signatures = require("path/to/allowlist.json")
 
function MyComponent() {
  const contract = useContract({
    address: '0x...',
    abi: [ /* ... your abi ... */ ] 
  })
  const { address } = useAccount()
  const sig = useSignature(address)
  
  const handleMint = () => {
    if (!sig) return
    const amountToMint = 1 // or mint the full allotment of sig.n
    contract
      .allowListMint(address, amountToMint, sig.s, sig.n)
      .then((tx) => tx.wait())
      .then((receipt) => {
        console.log("Mint Successful, tx: ", receipt.transactionHash)
      })
      .catch((err) => {
        console.error("Mint Failed", err)
      })
  }

  return <>
    <button onClick={handleMint}>Mint</button>
  </>
}

Keywords

FAQs

Last updated on 30 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc