0.1.2 • Published 3 years ago

@paperxyz/contracts v0.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

Paper is a developer-first NFT checkout solution that easily onboards users without wallets or cryptocurrencies.

This package allows developers to easily integrate their solidity smart contracts with paper.

Usage

Create a Paper ERC721 primary contract. You will receive a key which you should give a privileged role. This key will be use to verify that the contract is being called by us instead of someone else.

In order to do so, we provide the onlyPaper modifier which you can use by first inheriting from PaperVerification and passing in the _paperKey as a param in the contractor.

import "@paperxyz/contracts/verification/PaperVerification.sol"

contract YourNFTContract is ... , PaperVerification{

    constructor(address _paperKey, .... ) PaperVerification(_paperKey) ... { ... }

    ...
}

Finally to guard a method so that only we can call it, use the onlyPaper modifier and pass in the MintData.

    ...
    function paperMint(
            PaperMintData.MintData calldata _mintData,
            bytes calldata _data
        ) external onlyPaper(_mintData) {
            // your mint function here
            _safeMint(_mintData.recipient, _mintData.quantity, _data);
    }
    ...
}

Full Snippet

import "@paperxyz/contracts/verification/PaperVerification.sol"

contract YourNFTContract is ... , PaperVerification{

    constructor(address _paperKey, .... ) PaperVerification(_paperKey) ... { ... }

    ...
    function paperMint(
            PaperMintData.MintData calldata _mintData,
            bytes calldata _data
        ) external onlyPaper(_mintData) {
            // your mint function here
            _safeMint(recipient, quantity);
    }
    ...
}

MintData

The Mint data is a basic solidity struct that looks like

struct MintData {
    address recipient;
    uint256 quantity;
    uint256 tokenId;
    bytes32 nonce;
    bytes signature;
}

If you did not specify tokeId in your checkout, then 0 will be pass in by default. nonce and signature are used by paper to ensure that the same data is not used twice.

Installation

Install the SDK with your favorite package manager npm or yarn or pnpm.

npm install @paperxyz/contracts

yarn add @paperxyz/contracts

pnpm add @paperxyz/contracts

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago