Skip to main content

Mint LSP7 Token

In this guide you will mint some LSP7 Digital Asset tokens as an EOA contract owner.

Setup​

The following code snippets require the installation of the following libraries:

npm install web3 @lukso/lsp-smart-contracts

Imports and constants​

At this point, the LSP7 Mintable contract is being prepared for the following interaction. You construct an instance of a contract, using its ABI and the contract address.

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

const myTokenAddress = '0x...';

const web3 = new Web3(window.lukso);

await web3.eth.requestAccounts();
const accounts = await web3.eth.getAccounts();

Instantiate the contracts​

After defining the core parameters of the LSP7 Mintable contract, you are able to create an instance using its ABI and the contract address.

web3.js
const myToken = new web3.eth.Contract(LSP7Mintable.abi, myTokenAddress);

Send the transaction​

Finally, you can send the transaction to mint some tokens.

warning

The sample contract of this guide only allows the smart contract owner to mint assets. Custom LSP7 implementations might implement different permission sets.

web3.js
// mint 1 token
const amount = web3.utils.toWei('1', 'ether');

const mintTxn = await myToken.methods
.mint(
accounts[0], // recipient address
amount, // token amount
true, // force parameter
'0x', // additional data
)
.send({ from: accounts[0] });

console.log(mintTxn);

// Waiting 10sec to make sure the minting transaction has been processed

const balance = await myToken.methods.balanceOf(accounts[0]);
console.log('ðŸĶ Balance: ', balance.toString());