@paperxyz/contracts v0.1.2
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago