Transfer LYX
Transfering 0.5 LYXt between two Universal Profiles.
info
The full code of this example can be found in the πΎ lukso-playground repository.
The π Universal Profile Extension magically wraps all the calls internally so you don't have to craft custom transactions.
This makes it easy to send transaction like LYX transfer (= native token transfers). Simply use eth_sendTransaction
as you always did while working with wallets and smart accounts that used EOAs.
No need to make contract calls to instruct the smart contract of the Universal Profile what to do. The Browser Extension handles all of that behind the scene for you!
Setup Dependenciesβ
- ethers
- web3
npm install ethers
npm install web3@v1
Code Examplesβ
- ethers
- web3
import { ethers } from 'ethers';
const provider = new ethers.BrowserProvider(window.lukso);
await provider.send('eth_requestAccounts', []);
const signer = await provider.getSigner();
const account = await signer.getAddress();
// Send transaction
const tx = await signer.sendTransaction({
from: account, // The Universal Profile address
to: '0x...', // Receiving address, can be a UP or EOA
value: ethers.parseEther('0.5'), // 0.5 amount in ETH, in wei unit
});
import Web3 from 'web3';
const web3 = new Web3(window.lukso);
await web3.eth.requestAccounts();
const accounts = await web3.eth.getAccounts();
await web3.eth.sendTransaction({
from: accounts[0], // The Universal Profile address
to: '0x...', // receiving address, can be a UP or EOA
value: web3.utils.toWei('0.5', 'ether'), // 0.5 amount in ETH, in wei unit
});