Skip to main content

Create an LSP7 Digital Asset (Token)

This guide will teach you how to create our token (LSP7 Digital Asset) and transfer it between Universal Profiles (UP).

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.

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

// create an 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
myEOA, // new owner, who will mint later
false, // isNonDivisible = TRUE, means NOT divisible, decimals = 0)
]
})
.send({
from: myEOA,
});

Mint tokens for your Universal Profile

The code snippet below shows how to mint 100 tokens with your Universal Profile as a beneficiary.

await myToken.methods.mint('<up-address>', 100, false, '0x').send({
from: myEOA,
});

Transfer tokens to an other Universal Profile

The following code snippet shows how to transfer 15 tokens from your UP to another UP called bobUP.

// 1. generate the payload to transfer tokens
const tokenPayload = myToken.methods
.transfer('<up-address>', '<bob-up-address>', 15, false, '0x')
.encodeABI();

// 2. generate payload for Universal Profile to execute the token transfer on the token contract
const upPayload = myUniversalProfile.methods
.execute(
0, // operation 0 CALL
myToken._address,
0, // 0 LYX sent
tokenPayload
)
.encodeABI();

// 3. execute via the KeyManager
await myKeyManager.methods.execute(upPayload).send({
from: myEOA,
gas: 5_000_000,
gasPrice: '1000000000',
});