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';

const myEOA = '<address-of-up-owner>';
const tokenParams = [
'My LSP7 Token', // token name
'LSP7', // token symbol
myEOA, // new owner
false, // isNFT (make your token divisible or not)
];

// 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: tokenParams })
.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.

const bobUP = '<bob-up-address>';
const amount = 15;

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

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

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