A set of Solidity smart contracts implementing RMRK legos and the compatible extensions for them.
For each of the MultiAsset, Nestable and Equippable lego combinations, both simple and advanced sample uses are presented in the sample RMRK EVM contracts repository.
NOTE: RMRK smart contract documentation as well as usage instructions and examples can be found in the RMRK EVM developer documentation
To use the RMRK legos and smart contracts contained in this repository, simply add them to your project:
yarn add @rmrk-team/evm-contract
or
npm -i @rmrk-team/evm-contracts
Once the dependency is added to your project, simply import the smart contracts you wish to utilize into your own smart contract.
RMRK is a set of NFT standards which compose several "NFT 2.0 lego" primitives. Putting these legos together allows a user to create NFT systems of arbitrary complexity.
There are various possibilities on how to combine these legos, all of which are ERC721 compatible:
- MultiAsset (Context-Dependent Multi-Asset Tokens)
- Only uses the MultiAsset RMRK lego
- Nestable (Parent-Governed Nestable Non-Fungible Tokens)
- Only uses the Nestable RMRK lego
- Nestable with MultiAsset
- Uses both Nestable and MultiAsset RMRK legos
- Equippable MultiAsset with Nestable and Catalog
- Merged equippable is a more compact RMRK lego composite that uses less smart contracts, but has less space for custom logic implementation
- Split equippable is a more customizable RMRK lego composite that uses more smart contracts, but has more space for custom logic implementation
While we strongly encourage to refer to the documentation, we provide some quick-start notes for the use of our legos:
MultiAsset (RMRKMultiAsset): ERC-5773: Context-Dependent Multi-Asset Tokens
- Deploy the
MultiAsset
contract. - Admin must add assets on a per-token basis. This could be very gas-intensive, so we recommend adding them in batches.
- Mint the tokens using your preferred method.
- Deploy like a regular ERC-721 compliant smart contract.
That's it! This contract can receive and be nested by other instances of RMRKNestable.
NOTE: A smart contract that is only Nestable WILL NOT be compatible with other equippable contracts as a standalone.
A combintation of Nestable and MultiAsset lego is a powerful way of designing Non-Fungible Tokens. To quickstart this implementation (RMRKNestableMultiAsset), you only need to follow the steps outlined for the MultiAsset lego.
RMRK Equippable lego composite comes in two configurations: Merged and Split Equippable. The former is a single contract designed to handle the full implementation of MultiAsset, Nestable, and Equippable. The latter separates Nestable and Equippable with MultiAsset into two mutually dependent contracts to allow for more custom logic in each, if necessary.
- Deploy the RMRKEquippable. This contract implements minting, burning and asset management logic.
- Deploy the RMRKCatalog.
- Initialize your catalog parts (fixed and slot). Address of the RMRKCatalog along with the catalog part IDs need to be passed when initializing your assets in RMRKEquippable.
- Assign token assets in RMRKEquippable as you would in the MultiAsset above, with the added
ExtendedAsset
params,equippableRefId
andcatalogAddress
.
- Deploy the RMRKNestableExternalEquippable. This contract contains core transfer and minting logic.
- Deploy the RMRKExternalEquip. This contract contains equippable and asset management logic.
- Initialize the address of RMRKExternalEquippable in RMRKNestableExternalEquippable via an exposed
setEquippalbeAddress
method. If you're not using a prefab RMRK top-level implementation (found in theimplementations
directory), you will need to expose this yourself. - Deploy RMRKCatalog.
- Initialize your catalog parts (fixed and slot). Address of the RMRKCatalog along with the catalog part IDs need to be passed when initializing your assets in RMRKExternalEquip.
- Assign token assets in RMRKExternalEquippable as you would in the MultiAsset above, with the added
ExtendedAsset
params,equippableRefId
andcatalogAddress
.
NOTE: Please be aware that RMRKEquippable is likely very close to the maximum smart contract deployment size allowed by most EVM environments. If you need more space for custom business logic implementation, we suggest you consider RMRKNestableExternalEquippable.
One of the extensions present in this repository is Emotable
.
It provides the ability for users to react to NFTs using Unicode emojis.
To use it, just import the Emotable
smart contract into the
one you wish to utilize it.
The interfaces of all of the smart contracts are included in this repository. They are prefixed with an I
; so the
interface for the RMRKNestable
is IRMRKNestable
. If you wish to interact with any of the RMRK smart contracts from
your own, you only need to import the desired interface.
In addition to the raw RMRK legos and extensions, this repository also contains implementations of all of them in the
implementations/
directory. These implementations are opinionated and utilize the
extensions that we feel provide the most utility for each of the implementations.