@unique-nft/contracts
Advanced tools
Comparing version 0.0.2 to 0.1.0
{ | ||
"name": "@unique-nft/contracts", | ||
"description": "Smart Contract library for Unique Network", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"files": [ | ||
@@ -37,3 +37,3 @@ "/**/*.sol", | ||
"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 && yarn remove-dist" | ||
"local-release": "yarn ci && cd ./dist && changeset version && changeset publish && yarn remove-dist" | ||
}, | ||
@@ -59,4 +59,3 @@ "dependencies": { | ||
"@types/node": ">=18.0.0", | ||
"@unique-nft/contracts": "^0.0.2", | ||
"@unique-nft/sdk": "^0.7.7", | ||
"@unique-nft/sdk": "2.5.0", | ||
"@unique-nft/utils": "^0.3.20", | ||
@@ -63,0 +62,0 @@ "chai": "^4.2.0", |
101
README.md
@@ -8,3 +8,3 @@ # Unique Network | Contracts | ||
- [Unique Network | Contracts](#unique-network--contracts) | ||
- [Installation](#installation) | ||
- [Installation and configuration](#installation-and-configuration) | ||
- [API](#api) | ||
@@ -17,3 +17,3 @@ - [Structs](#structs) | ||
- [`TokenMinter.sol`](#tokenmintersol) | ||
- [TokenManager.sol](#tokenmanagersol) | ||
- [`TokenManager.sol`](#tokenmanagersol) | ||
- [`AddressValidator.sol`](#addressvalidatorsol) | ||
@@ -23,4 +23,6 @@ - [Example Usage](#example-usage) | ||
## Installation | ||
## Installation and configuration | ||
Install packages: | ||
```sh | ||
@@ -30,2 +32,19 @@ npm install @unique-nft/contracts | ||
Find 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 | ||
> [!IMPORTANT] | ||
> Configure your project: | ||
> | ||
> 1. Compatible Solidity versions are `>=0.8.18 <=0.8.24` | ||
> 2. Use via-IR compilation pipeline. | ||
> | ||
> In hardhat.config file set: | ||
> | ||
> ```ts | ||
> solidity: { | ||
> version: "0.8.24", | ||
> settings: { viaIR: true }, | ||
> }, | ||
> ``` | ||
## API | ||
@@ -59,28 +78,36 @@ | ||
`import "@unique-nft/contracts/CollectionMinter";` | ||
`import "@unique-nft/contracts/CollectionMinter.sol";` | ||
Provides functions to create collections in the Unique Schema V2. | ||
| `constructor(bool _mutable, bool _admin, bool _tokenOwner)` | | ||
| --------------------------------------------------------------------------------------- | | ||
| Initializes the contract and sets the default permissions for token properties mutation | | ||
--- | ||
`constructor(bool _mutable, bool _admin, bool _tokenOwner)` | ||
Initializes the contract and sets the default permissions for token properties mutation | ||
--- | ||
| `_createCollection(string _name, string _description, string _symbol, string _collectionCover)` | | ||
| ----------------------------------------------------------------------------------------------------------------- | | ||
| Creates a collection with specified name, description, symbol, collection cover, and allowed nesting permissions. | | ||
`_createCollection(string _name, string _description, string _symbol, string _collectionCover)` | ||
Creates a collection with specified name, description, symbol, collection cover, and allowed nesting permissions. | ||
--- | ||
#### [`TokenMinter.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/TokenMinter.sol) | ||
`import "@unique-nft/contracts/TokenMinter";` | ||
`import "@unique-nft/contracts/TokenMinter.sol";` | ||
Provides functions to create tokens in the Unique Schema V2. | ||
| `_createToken(address _collectionAddress, string _image, Attribute[] _attributes, CrossAddress _to) internal returns (uint256)` | | ||
| ------------------------------------------------------------------------------------------------------------------------------- | | ||
| Internal function to create a new token with specified image and attributes in a given collection. | | ||
--- | ||
#### [TokenManager.sol](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/TokenManager.sol) | ||
`_createToken(address _collectionAddress, string _name, string _description, string _image, Attribute[] _attributes, CrossAddress _to) internal returns (uint256)` | ||
Internal function to create a new token with specified image and attributes in a given collection. | ||
--- | ||
#### [`TokenManager.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/TokenManager.sol) | ||
`import "@unique-nft/contracts/TokenManager.sol";` | ||
@@ -90,40 +117,46 @@ | ||
| `_setImage(address _collection, uint256 _tokenId, bytes memory _newImage) internal` | | ||
| ----------------------------------------------------------------------------------- | | ||
| Sets a new image for a specific token in a collection. | | ||
--- | ||
`_setImage(address _collection, uint256 _tokenId, bytes memory _newImage) internal` | ||
Sets a new image for a specific token in a collection. | ||
--- | ||
| `_setTrait(address _collection, uint256 _tokenId, bytes memory _traitType, bytes memory _traitValue) internal` | | ||
| -------------------------------------------------------------------------------------------------------------- | | ||
| Sets a new trait (attribute) for a specific token in a collection. | | ||
`_setTrait(address _collection, uint256 _tokenId, bytes memory _traitType, bytes memory _traitValue) internal` | ||
Sets a new trait (attribute) for a specific token in a collection. | ||
--- | ||
| `_getImage(address _collection, uint256 _tokenId) internal view returns (bytes memory)` | | ||
| --------------------------------------------------------------------------------------- | | ||
| Retrieves the image data of a specific token in a collection. | | ||
`_getImage(address _collection, uint256 _tokenId) internal view returns (bytes memory)` | ||
Retrieves the image data of a specific token in a collection. | ||
--- | ||
| `_getTraitValue(address _collection, uint256 _tokenId, bytes memory _traitType) internal view returns (bytes memory)` | | ||
| --------------------------------------------------------------------------------------------------------------------- | | ||
| Retrieves the value of a specific trait for a token in a collection. | | ||
`_getTraitValue(address _collection, uint256 _tokenId, bytes memory _traitType) internal view returns (bytes memory)` | ||
Retrieves the value of a specific trait for a token in a collection. | ||
--- | ||
#### [`AddressValidator.sol`](https://github.com/UniqueNetwork/unique-contracts/blob/main/contracts/AddressValidator.sol) | ||
`import "@unique-nft/contracts/AddressValidator";` | ||
`import "@unique-nft/contracts/AddressValidator.sol";` | ||
Provides modifiers for validating addresses in token-related operations, ensuring that the caller is authorized. | ||
| `onlyTokenOwner(uint256 _tokenId, address collectionAddress)` | | ||
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Restricts access to the owner of the token with ID `_tokenId` in the collection at `collectionAddress`. Reverts if `msg.sender` is not the token owner. | | ||
--- | ||
`onlyTokenOwner(uint256 _tokenId, address collectionAddress` | ||
Restricts access to the owner of the token with ID `_tokenId` in the collection at `collectionAddress`. Reverts if `msg.sender` is not the token owner. | ||
--- | ||
| `onlyMessageSender(CrossAddress memory _crossAddress)` | | ||
| ----------------------------------------------------------------------------------------------------------------------- | | ||
| Restricts access to the address represented by `_crossAddress`. Reverts if `_crossAddress` does not match `msg.sender`. | | ||
`onlyMessageSender(CrossAddress memory _crossAddress)` | ||
Restricts access to the address represented by `_crossAddress`. Reverts if `_crossAddress` does not match `msg.sender`. | ||
## Example Usage | ||
@@ -130,0 +163,0 @@ |
Sorry, the diff of this file is not supported yet
52642
28
179