Skip to main content

Create an LSP7 Digital Asset (Token)

This guide will teach you how to create an LSP7 Digital Asset contract.

Deploy an LSP7 Digital Asset contract

We will use a specific implementation of LSP7, called LSP7Mintable. It allows the contract deployer to mint new tokens.

Make sure you have the following dependencies installed:

Install the dependencies
npm install web3 @lukso/lsp-smart-contracts

Step 1 - Setup imports and constants

At this point you will need a private key in order to deploy an LSP7Mintable contract. We will import LSP7Mintable in order to get the ABI and bytecode of the contract that will be deployed.

import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json';
import Web3 from 'web3';

const web3 = new Web3('https://rpc.testnet.lukso.network');

// initialize your EOA
const privateKey = '0x...';
const account = web3.eth.accounts.wallet.add(privateKey);

Step 2 - Instantiate contracts

At this point, the LPS7Mintable contract is being prepared for deployment.

const myToken = new web3.eth.Contract(LSP7Mintable.abi, {
gas: 5_000_000,
gasPrice: '1000000000',
});

Step 3 - Send transaction

Finally, deploy the contract.

Deploy the LSP7 Digital Asset contract
await myToken.deploy({
data: LSP7Mintable.bytecode,
arguments: [
'My LSP7 Token', // token name
'LSP7', // token symbol
account.address, // new owner, who will mint later
false, // isNonDivisible = TRUE, means NOT divisible, decimals = 0)
],
})
.send({ from: account.address });

Final code

import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json';
import Web3 from 'web3';

const web3 = new Web3('https://rpc.testnet.lukso.network');

// initialize your EOA
const privateKey = '0x...';
const account = web3.eth.accounts.wallet.add(privateKey);

// create a contract instance
const myToken = new web3.eth.Contract(LSP7Mintable.abi, {
gas: 5_000_000,
gasPrice: '1000000000',
});

// deploy the token contract
await myToken.deploy({
data: LSP7Mintable.bytecode,
arguments: [
'My LSP7 Token', // token name
'LSP7', // token symbol
account.address, // new owner, who will mint later
false, // isNonDivisible = TRUE, means NOT divisible, decimals = 0)
],
})
.send({ from: account.address });