Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@unique-nft/contracts
Advanced tools
This repository contains smart contracts for minting collections and tokens using Solidity in the Unique Schema V2.
npm install @unique-nft/contracts
Represents an attribute of a token.
Parameter | Type | Description |
---|---|---|
trait_type | string | Type of the attribute. |
value | string | Value of the attribute. |
Represents 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.
The AddressUtils
library provides helper methods to work with the CrossAddress
struct.
Parameter | Type | Description |
---|---|---|
eth | address | Ethereum address or address(0) if the origin is substrate account |
sub | uin256 | Substrate public key or 0 if the caller is ethereum account |
CollectionMinter.sol
import "@unique-nft/contracts/CollectionMinter";
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 |
_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
import "@unique-nft/contracts/TokenMinter";
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. |
import "@unique-nft/contracts/TokenManager.sol";
Provides utility functions for managing token data, such as setting and retrieving images and traits for tokens within 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. |
_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. |
AddressValidator.sol
import "@unique-nft/contracts/AddressValidator";
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. |
onlyMessageSender(CrossAddress memory _crossAddress) |
---|
Restricts access to the address represented by _crossAddress . Reverts if _crossAddress does not match msg.sender . |
Minter.sol
: Demonstrates how to create a gasless experience for minting collections and NFTs.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.BreedingGame.sol
: Demonstrates how contracts can mutate token's attributes and image.yarn
yarn compile
Create .env
file from .env.example
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
Run tests
yarn test
FAQs
Smart Contract library for Unique Network
The npm package @unique-nft/contracts receives a total of 1 weekly downloads. As such, @unique-nft/contracts popularity was classified as not popular.
We found that @unique-nft/contracts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.