UNPKG

erc721a-upgradeable

Version:
141 lines (92 loc) 5.41 kB
[![Docs][docs-shield]][docs-url] [![NPM][npm-shield]][npm-url] [![CI][ci-shield]][ci-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] <!-- OTHER BADGES --> <!-- [![Contributors][contributors-shield]][contributors-url] --> <!-- [![Forks][forks-shield]][forks-url] --> <!-- [![Stargazers][stars-shield]][stars-url] --> <!-- ANNOUNCEMENT --> > **📢 Version 4.x introduces several breaking changes. [Please refer to the documentation for more details.](https://chiru-labs.github.io/ERC721A/#/migration)** _We highly recommend reading the migration guide_, **especially** _the part on [`supportsInterface`](https://chiru-labs.github.io/ERC721A/#/migration?id=supportsinterface) if you are using with OpenZeppelin extensions_ (e.g. ERC2981). <!-- ABOUT THE PROJECT --> ## About The Project This repository hosts the Upgradeable variant of [ERC721A](https://github.com/chiru-labs/ERC721A), meant for use in upgradeable contracts. This variant is available as separate package called `erc721a-upgradeable`. This version uses the [diamond storage layout pattern](https://eips.ethereum.org/EIPS/eip-2535). It follows all of the rules for [Writing Upgradeable Contracts]: constructors are replaced by initializer functions, state variables are initialized in initializer functions, and we additionally check for storage incompatibilities across minor versions. [writing upgradeable contracts]: https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable > **Warning** > > There will be storage incompatibilities across major versions of this package, which makes it unsafe to upgrade a deployed contract from one major version to another, for example from 3.4.0 to 4.0.0. > > **It is strongly encouraged to use these contracts together with a tool that can simplify the deployment of upgradeable contracts, such as [OpenZeppelin Upgrades Plugins](https://github.com/OpenZeppelin/openzeppelin-upgrades).** This repository is generated by a transpiler. **Chiru Labs is not liable for any outcomes as a result of using ERC721A and ERC721A-Upgradeable.** DYOR. <!-- Docs --> ## Docs https://chiru-labs.github.io/ERC721A/ <!-- Installation --> ## Installation ```sh npm install --save-dev erc721a-upgradeable ``` <!-- USAGE EXAMPLES --> ## Usage Once installed, you can use the contracts in the library by importing them: ```solidity pragma solidity ^0.8.4; import 'erc721a-upgradeable/contracts/ERC721AUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; contract Something is ERC721AUpgradeable, OwnableUpgradeable { // Take note of the initializer modifiers. // - `initializerERC721A` for `ERC721AUpgradeable`. // - `initializer` for OpenZeppelin's `OwnableUpgradeable`. function initialize() initializerERC721A initializer public { __ERC721A_init('Something', 'SMTH'); __Ownable_init(); } function mint(uint256 quantity) external payable { // `_mint`'s second argument now takes in a `quantity`, not a `tokenId`. _mint(msg.sender, quantity); } function adminMint(uint256 quantity) external payable onlyOwner { _mint(msg.sender, quantity); } } ``` <!-- CONTRIBUTING --> ## Contributing This repository is automatically transpiled from the main [ERC721A](https://github.com/chiru-labs/ERC721A) repository by a workflow. Any changes to the `contracts` and `test` directories will be overwritten. If you want to make a contribution to the transpiler workflow: 1. Fork the Project 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the Branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request ### Running tests locally 1. `npm install` 2. `npm run test` <!-- LICENSE --> ## License Distributed under the MIT License. See `LICENSE.txt` for more information. <!-- CONTACT --> ## Contact - 2pm.flow (owner) - [@2pmflow](https://twitter.com/2pmflow) - location tba (owner) - [@locationtba](https://twitter.com/locationtba) - cygaar (maintainer) - [@cygaar_dev](https://twitter.com/cygaar_dev) - vectorized.eth (maintainer) - [@optimizoor](https://twitter.com/optimizoor) Project Link: [https://github.com/chiru-labs/ERC721A-Upgradeable](https://github.com/chiru-labs/ERC721A-Upgradeable) <!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> [docs-shield]: https://img.shields.io/badge/docs-%F0%9F%93%84-blue?style=for-the-badge [docs-url]: https://chiru-labs.github.io/ERC721A/#/upgradeable [npm-shield]: https://img.shields.io/npm/v/erc721a-upgradeable.svg?style=for-the-badge [npm-url]: https://www.npmjs.com/package/erc721a-upgradeable [ci-shield]: https://img.shields.io/github/actions/workflow/status/chiru-labs/ERC721A-Upgradeable/run-tests.yml?label=build&style=for-the-badge&branch=main [ci-url]: https://github.com/chiru-labs/ERC721A-Upgradeable/actions/workflows/run-tests.yml [issues-shield]: https://img.shields.io/github/issues/chiru-labs/ERC721A-Upgradeable.svg?style=for-the-badge [issues-url]: https://github.com/chiru-labs/ERC721A-Upgradeable/issues [license-shield]: https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge [license-url]: https://github.com/chiru-labs/ERC721A-Upgradeable/blob/main/LICENSE.txt