Smart Contract Implementation
The smart contracts are public and open source. They can be found on GitHub and in the @lukso/lsp-smart-contracts
NPM package.
This section contains the reference contract implementations of LUKSO Standard Proposals.
Some of the standards do not have a contract implementation as they represent Metadata-Standards to be used in the implementation contracts.
Developers wishing to understand the standards in terms of code and the tradeoffs within are well-advised to read these documents alongside the Solidity code itself.
Installation
npm install @lukso/lsp-smart-contracts
Overview
The contracts can be divided by their usage. Some are related to Universal Profiles, while others are related to Digital Assets and NFT 2.0. Finally, some standards are for more general use cases.
Universal Profile
The Universal Profile contracts allow a better representation of the identity on the blockchain and better control over it.
- LSP0ERC725Account: a contract that can be used as an account and represents an identity on-chain.
- LSP1UniversalReceiverDelegateUP: a contract that allows the account to react to the calls that it receives (Normal transaction, Token transfer, Vaults transfer, etc.).
- LSP6KeyManager: a contract that allows multi-control over the account using different permissions.
Digital Assets
The Digital Asset (Token and NFT 2.0) contracts are the newest advanced version of the existing token standards. They come with many features that enhance the security and the overall user experience and compatibility with ERC725Accounts and Universal Receivers.
- LSP4DigitalAssetMetadata: a contract that sets the metadata of the Digital Asset.
- LSP7DigitalAsset: a contract that either represents a fungible or non-fungible token (NFT).
- LSP8IdentifiableDigitalAsset: a contract that represents a non-fungible token (NFT). It uses a bytes32 tokenId to allow many uses of token identification, including numbers, contract addresses, and hashed values (e.g., serial numbers).
Periphery
These contracts are not just related to one specific section and could be used with the Universal Profile, Digital Asset, and NFT 2.0 contracts.
- LSP9Vault: a contract representing a Vault able to execute and hold assets could be owned by an LSP0ERC725Account contract.
- LSP1UniversalReceiverDelegateVault: a contract that allows the vault to react to the calls it receives (Normal transaction, Token transfer, etc.).
Usage
Create a Universal Profile
// MyUP.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@lukso/lsp-smart-contracts/contracts/UniversalProfile.sol";
contract MyUP is UniversalProfile {
constructor() UniversalProfile(msg.sender) {
// ..
}
}
Create a Fungible Token
// MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@lukso/lsp-smart-contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol";
contract MyToken is LSP7DigitalAsset {
// 4th argument (false) marks that this contract serves as a Fungible Token and not as a NFT.
constructor() LSP7DigitalAsset("MyToken","MTKN",msg.sender,false) {
// ..
}
function mint() public {
_mint(...);
}
}