{"_id":"@unique-nft/contracts","_rev":"2-b8af49be6c6a4918b0d43b499ab4996c","name":"@unique-nft/contracts","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@unique-nft/contracts","version":"0.0.1","keywords":["unique network","blockchain","polkadot","nft","contracts"],"license":"MIT","_id":"@unique-nft/contracts@0.0.1","maintainers":[{"name":"max.andreev","email":"maxick20@gmail.com"},{"name":"ashkuc","email":"ashkucc@gmail.com"},{"name":"ut-akuznetsov","email":"andreyk@unique.network"},{"name":"lach","email":"iam@lach.pw"},{"name":"nonfungible","email":"gz@unique.network"}],"homepage":"https://github.com/UniqueNetwork/unique-contracts","bugs":{"url":"https://github.com/UniqueNetwork/unique-contracts/issues"},"dist":{"shasum":"ed7090eec09d0758f78754054b39e9261a29762b","tarball":"https://registry.npmjs.org/@unique-nft/contracts/-/contracts-0.0.1.tgz","fileCount":10,"integrity":"sha512-VLJWoKeT6lsbSqr6I7N6t6/ORraqk3PZtvmy3NcxUHoBe/tsc1lLuj7lpDzPJ1oP7Y80kXNcQWIavcgQ3oPgOg==","signatures":[{"sig":"MEYCIQDQ5thbZpyQDDXnk7oz6OkiqDeMX+M4Pk2Q//QOK7OCZgIhANfaxPwdz2zq5JEiMfCQCuv1bDeEtrs8r4etUcci4cCv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":46393},"gitHead":"3b18abdc2d39e2d96496a4472a76ea4be6a4e3dd","scripts":{"ci":"yarn compile:f && yarn test:f","test":"yarn compile && yarn test:hh & yarn test:f","run:hh":"npx hardhat run --no-compile","test:f":"forge test --gas-report","compile":"yarn compile:hh & yarn compile:f","test:hh":"npx hardhat test --no-compile --config ./hardhat.test.config.ts --network testnet","changeset":"npx changeset","codestyle":"prettier . --write","compile:f":"forge compile --force","compile:hh":"npx hardhat compile --force","local-release":"changeset version && changeset publish","prepublishOnly":"yarn ci"},"_npmUser":{"name":"max.andreev","email":"maxick20@gmail.com"},"repository":{"url":"git+https://github.com/UniqueNetwork/unique-contracts.git","type":"git"},"_npmVersion":"10.5.0","description":"Smart Contract library for Unique Network","directories":{},"_nodeVersion":"20.12.0","dependencies":{"@unique-nft/solidity-interfaces":"^1.0.1"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22","devDependencies":{"chai":"^4.2.0","dotenv":"^16.4.5","ethers":"^6.13.2","hardhat":"^2.22.7","ts-node":">=8.0.0","prettier":"^3.3.3","typechain":"^8.3.2","typescript":"~5.0.4","@types/chai":"^4.2.0","@types/node":">=18.0.0","@types/mocha":">=9.1.0","@changesets/cli":"^2.27.8","@unique-nft/sdk":"^0.7.7","@unique-nft/utils":"^0.3.20","solidity-coverage":"^0.8.0","@typechain/hardhat":"^9.1.0","@typechain/ethers-v6":"^0.5.1","hardhat-gas-reporter":"^1.0.8","@types/chai-as-promised":"^7.1.6","prettier-plugin-solidity":"^1.3.1","@nomicfoundation/hardhat-ethers":"^3.0.6","@nomicfoundation/hardhat-verify":"^2.0.0","@nomicfoundation/hardhat-foundry":"^1.1.2","@nomicfoundation/hardhat-toolbox":"^5.0.0","@nomicfoundation/hardhat-ignition":"^0.15.0","@nomicfoundation/hardhat-chai-matchers":"^2.0.7","@nomicfoundation/hardhat-ignition-ethers":"^0.15.5","@nomicfoundation/hardhat-network-helpers":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/contracts_0.0.1_1727960067127_0.23334862931765232","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@unique-nft/contracts","version":"0.0.2","keywords":["unique network","blockchain","polkadot","nft","contracts"],"license":"MIT","_id":"@unique-nft/contracts@0.0.2","maintainers":[{"name":"max.andreev","email":"maxick20@gmail.com"},{"name":"ashkuc","email":"ashkucc@gmail.com"},{"name":"ut-akuznetsov","email":"andreyk@unique.network"},{"name":"lach","email":"iam@lach.pw"},{"name":"nonfungible","email":"gz@unique.network"}],"homepage":"https://github.com/UniqueNetwork/unique-contracts","bugs":{"url":"https://github.com/UniqueNetwork/unique-contracts/issues"},"dist":{"shasum":"915f18fc2c542030541c2887692d54bf245099e2","tarball":"https://registry.npmjs.org/@unique-nft/contracts/-/contracts-0.0.2.tgz","fileCount":11,"integrity":"sha512-+ITrJCP0Tz3fLkh2i+attCL8mfHPXIOBp4tjZS44Xa+HOmsu7shYkSbIPf3Bcx/+DNHXAATLmT9L7efXiYAaLQ==","signatures":[{"sig":"MEQCIFT61r+m5iUS5grzOpoTH31YgOk+bltvMD53BUhmQg8jAiBfG6nRz+NOK2RNN66d8RPadIIChCGf2Ua7D3IdRc0MrQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52488},"gitHead":"ef4654a9efe59256c604dcc7372eac976804496f","scripts":{"ci":"yarn compile:f && yarn test:f","test":"yarn compile && yarn test:hh & yarn test:f","build":"yarn remove-dist && mkdir -p dist && cp -r package.json README.md CHANGELOG.md .changeset dist/ && rsync -a contracts/ dist/","run:hh":"npx hardhat run --no-compile","test:f":"forge test --gas-report","compile":"yarn compile:hh & yarn compile:f","test:hh":"npx hardhat test --no-compile --config ./hardhat.test.config.ts --network testnet","changeset":"npx changeset","codestyle":"prettier . --write","compile:f":"forge compile --force","compile:hh":"npx hardhat compile --force","remove-dist":"rm -rf dist","local-release":"yarn ci && cd ./dist && changeset version && yarn remove-dist","prepublishOnly":"yarn ci"},"_npmUser":{"name":"max.andreev","email":"maxick20@gmail.com"},"repository":{"url":"git+https://github.com/UniqueNetwork/unique-contracts.git","type":"git"},"_npmVersion":"10.7.0","description":"Smart Contract library for Unique Network","directories":{},"_nodeVersion":"22.1.0","dependencies":{"@unique-nft/solidity-interfaces":"^1.0.1"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22","devDependencies":{"chai":"^4.2.0","dotenv":"^16.4.5","ethers":"^6.13.2","hardhat":"^2.22.7","ts-node":">=8.0.0","prettier":"^3.3.3","typechain":"^8.3.2","typescript":"~5.0.4","@types/chai":"^4.2.0","@types/node":">=18.0.0","@types/mocha":">=9.1.0","@changesets/cli":"^2.27.8","@unique-nft/sdk":"^0.7.7","@unique-nft/utils":"^0.3.20","solidity-coverage":"^0.8.0","@typechain/hardhat":"^9.1.0","@typechain/ethers-v6":"^0.5.1","hardhat-gas-reporter":"^1.0.8","@unique-nft/contracts":"^0.0.2","@types/chai-as-promised":"^7.1.6","prettier-plugin-solidity":"^1.3.1","@nomicfoundation/hardhat-ethers":"^3.0.6","@nomicfoundation/hardhat-verify":"^2.0.0","@nomicfoundation/hardhat-foundry":"^1.1.2","@nomicfoundation/hardhat-toolbox":"^5.0.0","@nomicfoundation/hardhat-ignition":"^0.15.0","@nomicfoundation/hardhat-chai-matchers":"^2.0.7","@nomicfoundation/hardhat-ignition-ethers":"^0.15.5","@nomicfoundation/hardhat-network-helpers":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/contracts_0.0.2_1728399993060_0.010368654818347922","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"@unique-nft/contracts","description":"Smart Contract library for Unique Network","version":"0.1.0","license":"MIT","keywords":["unique network","blockchain","polkadot","nft","contracts"],"homepage":"https://github.com/UniqueNetwork/unique-contracts","bugs":{"url":"https://github.com/UniqueNetwork/unique-contracts/issues"},"repository":{"type":"git","url":"git+https://github.com/UniqueNetwork/unique-contracts.git"},"scripts":{"test":"yarn compile && yarn test:hh & yarn test:f","test:f":"forge test --gas-report","test:hh":"npx hardhat test --no-compile --config ./hardhat.test.config.ts --network testnet","run:hh":"npx hardhat run --no-compile","compile":"yarn compile:hh & yarn compile:f","compile:hh":"npx hardhat compile --force","compile:f":"forge compile --force","codestyle":"prettier . --write","ci":"yarn compile:f && yarn test:f","prepublishOnly":"yarn ci","changeset":"npx changeset","remove-dist":"rm -rf dist","build":"yarn remove-dist && mkdir -p dist && cp -r package.json README.md CHANGELOG.md .changeset dist/ && rsync -a contracts/ dist/","local-release":"yarn ci && cd ./dist && changeset version && changeset publish && yarn remove-dist"},"dependencies":{"@unique-nft/solidity-interfaces":"^1.0.1"},"devDependencies":{"@changesets/cli":"^2.27.8","@nomicfoundation/hardhat-chai-matchers":"^2.0.7","@nomicfoundation/hardhat-ethers":"^3.0.6","@nomicfoundation/hardhat-foundry":"^1.1.2","@nomicfoundation/hardhat-ignition":"^0.15.0","@nomicfoundation/hardhat-ignition-ethers":"^0.15.5","@nomicfoundation/hardhat-network-helpers":"^1.0.0","@nomicfoundation/hardhat-toolbox":"^5.0.0","@nomicfoundation/hardhat-verify":"^2.0.0","@typechain/ethers-v6":"^0.5.1","@typechain/hardhat":"^9.1.0","@types/chai":"^4.2.0","@types/chai-as-promised":"^7.1.6","@types/mocha":">=9.1.0","@types/node":">=18.0.0","@unique-nft/sdk":"2.5.0","@unique-nft/utils":"^0.3.20","chai":"^4.2.0","dotenv":"^16.4.5","ethers":"^6.13.2","hardhat":"^2.22.7","hardhat-gas-reporter":"^1.0.8","prettier":"^3.3.3","prettier-plugin-solidity":"^1.3.1","solidity-coverage":"^0.8.0","ts-node":">=8.0.0","typechain":"^8.3.2","typescript":"~5.0.4"},"packageManager":"yarn@1.22.22","_id":"@unique-nft/contracts@0.1.0","gitHead":"49f0f30b76f4c7237dce78c375d5ff9dfe17f84c","_nodeVersion":"22.1.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-G/2BfWCAvP2vfNthWzYWSC9b2bPG9kac29+qGh2MfJNRxy94+QhWaBYZIN7g90V0vjT/TQdaPJ6mrwjVhik8Vw==","shasum":"9c0a013851b51c0d86aeff457e626033cc0a95e2","tarball":"https://registry.npmjs.org/@unique-nft/contracts/-/contracts-0.1.0.tgz","fileCount":11,"unpackedSize":52642,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCln8gtO0n9GCzmZoqlcvUaPxZ3aSS1Kvd+exXG4aLbmgIgIZfx1pKsl5xApKjZU1tIllNA8oI7bD3u0XszCIMJGOw="}]},"_npmUser":{"name":"max.andreev","email":"maxick20@gmail.com"},"directories":{},"maintainers":[{"name":"ut-akuznetsov","email":"andreyk@unique.network"},{"name":"nonfungible","email":"gz@unique.network"},{"name":"lach","email":"iam@lach.pw"},{"name":"ashkuc","email":"ashkucc@gmail.com"},{"name":"max.andreev","email":"maxick20@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/contracts_0.1.0_1737040171930_0.7773873887241975"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-03T12:54:27.006Z","modified":"2025-01-16T15:09:32.397Z","0.0.1":"2024-10-03T12:54:27.288Z","0.0.2":"2024-10-08T15:06:33.222Z","0.1.0":"2025-01-16T15:09:32.146Z"},"bugs":{"url":"https://github.com/UniqueNetwork/unique-contracts/issues"},"license":"MIT","homepage":"https://github.com/UniqueNetwork/unique-contracts","keywords":["unique network","blockchain","polkadot","nft","contracts"],"repository":{"type":"git","url":"git+https://github.com/UniqueNetwork/unique-contracts.git"},"description":"Smart Contract library for Unique Network","maintainers":[{"name":"ut-akuznetsov","email":"andreyk@unique.network"},{"name":"nonfungible","email":"gz@unique.network"},{"name":"lach","email":"iam@lach.pw"},{"name":"ashkuc","email":"ashkucc@gmail.com"},{"name":"max.andreev","email":"maxick20@gmail.com"}],"readme":"# Unique Network | Contracts\n\n[![npm version](https://img.shields.io/npm/v/@unique-nft/contracts.svg)](https://www.npmjs.com/package/@unique-nft/contracts)\n\nThis repository contains smart contracts for minting collections and tokens using Solidity in the [Unique Schema V2](https://docs.uniquenetwork.dev/reference/schemas).\n\n- [Unique Network | Contracts](#unique-network--contracts)\n  - [Installation and configuration](#installation-and-configuration)\n  - [API](#api)\n    - [Structs](#structs)\n      - [Attribute](#attribute)\n      - [CrossAddress](#crossaddress)\n    - [Contracts](#contracts)\n      - [`CollectionMinter.sol`](#collectionmintersol)\n      - [`TokenMinter.sol`](#tokenmintersol)\n      - [`TokenManager.sol`](#tokenmanagersol)\n      - [`AddressValidator.sol`](#addressvalidatorsol)\n  - [Example Usage](#example-usage)\n  - [Run tests](#run-tests)\n\n## Installation and configuration\n\nInstall packages:\n\n```sh\nnpm install @unique-nft/contracts\n```\n\nFind the RPC endpoint in the [official documentation](https://docs.unique.network/reference). You can get `OPL` (Opal testnet) tokens for free at https://t.me/unique2faucet_opal_bot\n\n> [!IMPORTANT]\n> Configure your project:\n>\n> 1. Compatible Solidity versions are `>=0.8.18 <=0.8.24`\n> 2. Use via-IR compilation pipeline.\n>\n> In hardhat.config file set:\n>\n> ```ts\n>   solidity: {\n>     version: \"0.8.24\",\n>     settings: { viaIR: true },\n>  },\n> ```\n\n## API\n\n### Structs\n\n#### Attribute\n\nRepresents an attribute of a token.\n\n| Parameter  | Type     | Description             |\n| ---------- | -------- | ----------------------- |\n| trait_type | `string` | Type of the attribute.  |\n| value      | `string` | Value of the attribute. |\n\n#### CrossAddress\n\nRepresents ethereum or substrate account. Only one property can be filled out to consider the structure valid. Learn more about EVM in Unique Network and compatibility with substrate accounts in the [official documentation](https://docs.unique.network/build/evm/).\n\nThe `AddressUtils` library provides helper methods to work with the `CrossAddress` struct.\n\n| Parameter | Type      | Description                                                         |\n| --------- | --------- | ------------------------------------------------------------------- |\n| eth       | `address` | Ethereum address or `address(0)` if the origin is substrate account |\n| sub       | `uin256`  | Substrate public key or `0` if the caller is ethereum account       |\n\n### Contracts\n\n#### [`CollectionMinter.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/CollectionMinter.sol)\n\n`import \"@unique-nft/contracts/CollectionMinter.sol\";`\n\nProvides functions to create collections in the Unique Schema V2.\n\n---\n\n`constructor(bool _mutable, bool _admin, bool _tokenOwner)`\n\nInitializes the contract and sets the default permissions for token properties mutation\n\n---\n\n`_createCollection(string _name, string _description, string _symbol, string _collectionCover)`\n\nCreates a collection with specified name, description, symbol, collection cover, and allowed nesting permissions.\n\n---\n\n#### [`TokenMinter.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/TokenMinter.sol)\n\n`import \"@unique-nft/contracts/TokenMinter.sol\";`\n\nProvides functions to create tokens in the Unique Schema V2.\n\n---\n\n`_createToken(address _collectionAddress, string _name, string _description, string _image, Attribute[] _attributes, CrossAddress _to) internal returns (uint256)`\n\nInternal function to create a new token with specified image and attributes in a given collection.\n\n---\n\n#### [`TokenManager.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/TokenManager.sol)\n\n`import \"@unique-nft/contracts/TokenManager.sol\";`\n\nProvides utility functions for managing token data, such as setting and retrieving images and traits for tokens within a collection.\n\n---\n\n`_setImage(address _collection, uint256 _tokenId, bytes memory _newImage) internal`\n\nSets a new image for a specific token in a collection.\n\n---\n\n`_setTrait(address _collection, uint256 _tokenId, bytes memory _traitType, bytes memory _traitValue) internal`\n\nSets a new trait (attribute) for a specific token in a collection.\n\n---\n\n`_getImage(address _collection, uint256 _tokenId) internal view returns (bytes memory)`\n\nRetrieves the image data of a specific token in a collection.\n\n---\n\n`_getTraitValue(address _collection, uint256 _tokenId, bytes memory _traitType) internal view returns (bytes memory)`\n\nRetrieves the value of a specific trait for a token in a collection.\n\n---\n\n#### [`AddressValidator.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/AddressValidator.sol)\n\n`import \"@unique-nft/contracts/AddressValidator.sol\";`\n\nProvides modifiers for validating addresses in token-related operations, ensuring that the caller is authorized.\n\n---\n\n`onlyTokenOwner(uint256 _tokenId, address collectionAddress`\n\nRestricts access to the owner of the token with ID `_tokenId` in the collection at `collectionAddress`. Reverts if `msg.sender` is not the token owner.\n\n---\n\n`onlyMessageSender(CrossAddress memory _crossAddress)`\n\nRestricts access to the address represented by `_crossAddress`. Reverts if `_crossAddress` does not match `msg.sender`.\n\n## Example Usage\n\n- [`Minter.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/recipes/Minter.sol): Demonstrates how to create a gasless experience for minting collections and NFTs.\n- [`POAP.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/recipes/POAP.sol): Demonstrates how to create a POAP contract. Tokens minting sponsored by the POAP contract itself. Every account can mint only one NFT that cannot be transferred.\n- [`BreedingGame.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/recipes/BreedingGame.sol): Demonstrates how contracts can mutate token's attributes and image.\n\n## Run tests\n\n1. Install packages and compile contracts\n\n```bash\nyarn\nyarn compile\n```\n\n2. Create `.env` file from `.env.example`\n3. Set at least two private keys with `OPL` balance to `TEST_ACCOUNTS_ETH` env. You can get `OPL` tokens for free at https://t.me/unique2faucet_opal_bot\n\n4. Run tests\n\n```bash\nyarn test\n```\n","readmeFilename":"README.md"}