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 makes it easy to send LYX transaction 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.
Setupâ
- web3.js
- ethers.js
npm install web3@v1
npm install ethers
Transfer LYX from a Universal Profileâ
The Universal Profile browser extension will magically wrap all the calls internally so you don't have to worry about crafting custom transactions. Simply use eth_sendTransaction
as you always did while working with EOA.
- web3.js
- ethers.js
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
})
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
});