Skip to content

Commit

Permalink
Merge pull request #747 from lukso-network/update-create-lsp7-nft-col…
Browse files Browse the repository at this point in the history
…lection

update create NFT collection with LSP7 for v0.14.0
  • Loading branch information
Hugoo authored Dec 12, 2023
2 parents 1707bd5 + c551e09 commit 570a023
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions docs/learn/smart-contract-developers/create-nft-collection-lsp7.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,13 @@ npm install @lukso/lsp-smart-contracts

## Create the Smart Contracts

When creating smart contracts representing digital assets on LUKSO, you will need to specify the token type and data keys for the 📄 [LSP4 Digital Asset Metadata](../../standards/tokens/LSP4-Digital-Asset-Metadata) that will be stored in the 🗂️ [ERC725Y](../../standards/lsp-background/erc725.md#erc725y-generic-data-keyvalue-store) storage of the Digital Asset. There are three different token types:
When creating smart contracts representing digital assets on LUKSO, you will need to specify the token type and data keys for the 📄 [LSP4 Digital Asset Metadata](../../standards/tokens/LSP4-Digital-Asset-Metadata) that will be stored in the 🗂️ [ERC725Y](../../standards/lsp-background/erc725.md#erc725y-generic-data-keyvalue-store) storage of the Digital Asset. There are three different [token types](../../standards/tokens/LSP4-Digital-Asset-Metadata.md#lsp4tokentype):

- `0` = Token
- `1` = NFT
- `2` = Collection

```solidity title="contracts/TokenTypes.sol"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
bytes32 constant _LSP4_TOKEN_TYPE_DATA_KEY = 0xe0261fa95db2eb3b5439bd033cda66d56b96f92f243a8228fd87550ed7bdfdb3; // kecca256 hash of the word `LSP4TokenType`
enum TokenType {
TOKEN,
NFT,
COLLECTION
}
```

After defining the type of the asset you can create a custom 🌄 [LSP7 Digital Asset Collection](../../standards/tokens/LSP7-Digital-Asset.md) that extends [LSP7Mintable](../../contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md) so that new assets can be created within the smart contract.
For this example we will use the `Token` token type. You can create a custom 🌄 [LSP7 Digital Asset Token](../../standards/tokens/LSP7-Digital-Asset.md) that extends [LSP7Mintable](../../contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md) so that new assets can be minted by the [`owner`](../../contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md#owner) of the smart contract.

```solidity title="contracts/Example1/EventTicketsNFT.sol"
// SPDX-License-Identifier: MIT
Expand All @@ -58,8 +45,9 @@ pragma solidity ^0.8.4;
import {
LSP7Mintable
} from "@lukso/lsp-smart-contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol";
import {_LSP4_TOKEN_TYPE_DATA_KEY, TokenType} from "../TokenTypes.sol";
import {
_LSP4_TOKEN_TYPE_TOKEN
} from "@lukso/lsp-smart-contracts/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol";
contract EventTicketsNFT is LSP7Mintable {
constructor(
Expand All @@ -71,12 +59,10 @@ contract EventTicketsNFT is LSP7Mintable {
eventName,
tokenSymbol,
contractOwner,
_LSP4_TOKEN_TYPE_TOKEN, // set the token type as Token
true // make the token non divisible
)
{
// set the token type
_setData(_LSP4_TOKEN_TYPE_DATA_KEY, abi.encode(TokenType.TOKEN));
}
{}
}
```

Expand Down

0 comments on commit 570a023

Please sign in to comment.