LSP8 Identifiable Digital Asset
LSP8CompatibleERC721The LSP8CompatibleERC721 contracts have been deprecated and deleted from the @lukso/lsp-smart-contracts package since version 0.15.0, because of their unsafe nature and security considerations (See PR #845 for more details).
They are not recommended to be used. However, if you want to still use them, they remain available in the version 0.14.0.
The LSP8 Identifiable Digital Asset contract is the newest advanced version of the existing ERC NFT standards, such as ERC721. LSP8 identifiable digital assets represent Non Fungible Tokens (NFTs) that can be uniquely traded. Each NFT is identified with a tokenId, based on ERC721 and can also have its own metadata set using the setDataForTokenId(...) function.
A bytes32 value is used for tokenId to allow many uses of token identification, including numbers, contract addresses, and hashed values (i.e., serial numbers).
Installation & Usage
The LSP8 smart contracts and their ABIs are available are available in their own individual package. To use them, install @lukso/lsp8-contracts as a dependency in your project.
- npm
- yarn
- pnpm
npm install @lukso/lsp8-contracts
yarn add @lukso/lsp8-contracts
pnpm add @lukso/lsp8-contracts
LSP8IdentifiableDigitalAsset.sol is an abstract contract that is not deployable as is, because it does not contain any public functions by default to manage token supply (e.g: no public mint(...) or burn(...) functions). You can either:
- use the
LSP8Mintablepreset contract that contains a publicmint(...)function callable only by the contract's owner. - or extend the
LSP8IdentifiableDigitalAssetcontract (see below) and create your own supply mechanism by defining public methods that use the internal_mint(...)and_burn(...)functions.
Comparisons with ERC721
| Description | ERC721 | LSP8 |
|---|---|---|
| Transferring tokens as an owner. | transferFrom(address,address,uint256)safeTransferFrom(address,address,uint256)safeTransferFrom(address,address,uint256,bytes) | transfer(address,address,bytes32,bool,bytes) |
| Transferring tokens as an operator. | ||
| Approving an operator to spend tokens on behalf of the owner. | approve(address,uint256) | authorizeOperator(address,bytes32) |
In comparison ERC721 has:
safeTransferFrom(address,address,uint256,bytes)safeTransferFrom(address,address,uint256)transferFrom(address,address,uint256)
All of the above functions can be used by both the owner of the token id or by the operator of the token id in order to transfer the ERC721 token. To be mentioned, both functions safeTransferFrom(...) have a hook that calls the recipient contract.
Looking at LSP7 & LSP8 we have unified transfer(...) & transferBatch(...) functions in both contracts. Those functions contain a hook which is executed conditionally and can be used in any of the above cases.