Skip to main content

LSP7 Digital Asset

Deprecation of LSP7CompatibleERC20

The LSP7CompatibleERC20 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. They are not recommended to be used. However, if you want to still use them, they remain available up to the version 0.14.0.

The LSP7 Digital Asset contract is the newest advanced version of the existing ERC token standards, such as ERC20 and ERC1155. It comes with many features that enhance the security and the overall user experience and compatibility with ERC725Accounts and Universal Receivers.

The LSP7DigitalAsset contract represents digital assets for fungible tokens where minting and transferring are specified with an amount of tokens. Their functions were inspired from ERC20 and ERC1155 with more upgraded features.

Installation & Usage

The LSP7 smart contracts and their ABIs are available are available in their own individual package. To use them, install @lukso/lsp7-contracts as a dependency in your project.

npm install @lukso/lsp7-contracts

LSP7DigitalAsset.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:

  • the LSP7Mintable preset contract that contains a public mint(...) function callable only by the contract's owner.
  • or extend the LSP7DigitalAsset contract (see below) and create your own supply mechanism by defining public methods that use the internal _mint(...) and _burn(...) functions.

Token Metadata

LSP7 uses the LSP4DigitalAssetMetadata standard under the hood. Since LSP4 uses an ERC725Y General Data Key/Value Store, it allows any form of metadata to be defined and set. This could include things such as list of creators, JSON files, exchanges where the token is listed, etc...

It is within this contract that the Token-Metadata (name and symbol) is set for the LSP7DigitalAsset on deployment / initialization.

Example use cases

An LSP7 can serves as:

  • a Divisible Token Contract when isNonDivisible bool is set to false in the constructor(...)
  • otherwise serves as a Non-Divisible Token Contract.

This can be useful to set isNonDivisible to true, rather than deploying a LSP8 contract to achieve the same goal.

Comparisons with ERC20

DescriptionERC20LSP7
Transferring tokens as an owner.transfer(address,uint256)transfer(address,address,uint256,bool,bytes)
Transferring tokens as an operator.transferFrom(address,address,uint256)
Approving an operator to spend tokens on behalf of the owner.approve(address,uint256)authorizeOperator(address,uint256)

In ERC20 the following functions can be used to transfer tokens from the token holder:

  • transfer(address,uint256) can only be used by the token holder. Therefore, the caller must be token holder.
  • transferFrom(address,address,uint256) can be used by operator to transfer tokens on behalf of a token holder (as long as this token holder has been approved and given an allowance).

In comparison in LSP7, a single function transfer(address,address,uint256,bool,bytes) can be used by both operator and token owner.

  • if a token holder want to transfer its own token, it can call directly the function (be the caller) and specify its address for the first parameter from.
  • if an operator want to transfer tokens for a token holder that it has been approved for (via the authorizeOperator(...) function), it can call the function and specify the address of the token holder as the from address as well.

Therefore as you can see from the table above, the only thing that changes when transferring token as a token owner or an operator is the caller of the function. The parameters remain the same.