Skip to main content

Transfer LSP7 Token

This guide will teach you how to tranfer an existing LSP7 Digital Asset across Universal Profiles.

info

The full code of this example can be found in the ðŸ‘ū lukso-playground.

The 🆙 Universal Profile Extension makes it easy to send token transactions without having to interact with the smart contract of the Universal Profile. If you are building a service or backend, you can also ðŸ‘ū execute transfers by directly calling the profile contract and preparing the calldata.

Setup​

The following code snippets require to install a web3 provider like web3 or ethers, as well as using smart contract schemas. The 📃 @lukso/lsp-smart-contracts library is the most convenient way to interact with LSP-based smart contracts.

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

Sending LSP7 Tokens from a Universal Profile​

As the initial step, you have to set up the Universal Profile and LSP7 Token. Both require an ABI that can be imported from the @lukso/lsp-smart-contracts library. After setting up the contracts, you can set up the parameters for the LSP7 token transfer.

import Web3 from 'web3';

// Import schemas and ABI
import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json';

const web3 = new Web3(window.lukso);

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

// Instantiate the token with an address
const myToken = new web3.eth.Contract(LSP7Mintable.abi, '0x...');

await myToken.methods
.transfer(
accounts[0], // sender address
'0x...', // receiving address
15, // token amount
false, // force parameter
'0x', // additional data
)
.send({ from: accounts[0] });