TransferFromWithData
Withdraw Pluri allowance from another address and send the amount to another address, sending metadata alongside the transaction.
// In this example let's pretend you're 0x959FD7Ef9089B7142B6B908Dc3A8af7Aa8ff0FA1 and
// 0x4E90a36B45879F5baE71B57Ad525e817aFA54890 gave you 1n alloance of Pluri. You will
// be transffering it to your wallet.
let allowanceGiverAddress = '0x4E90a36B45879F5baE71B57Ad525e817aFA54890'
let recieverAddress = '0x959FD7Ef9089B7142B6B908Dc3A8af7Aa8ff0FA1'
let data = {"Hello","World"}
let amount = 1n
//Web3.js 4.8 Example
let metadata = web3.utils.utf8ToHex(data);
// Check user whom inititated the transaction has enough to pay the Pluri tax + chosen application fee
const balance = await PluriContract.methods.balanceOf(recieverAddress).call();
if(balance >= (100000000000n + amount)){
PluriContract.methods.transferWithData(allowanceGiverAddress, recieverAddress, amount, metadata).send({ from: recieverAddress })
}
//Ethers.js 6.12.1 Example
let metadata = hexlify(toUtf8Bytes(JSON.stringify({"Hello","World"}))
// Check if the user has enought to pay the Pluri tax + chosen application fee
const balance = await PluriContract.balanceOf(recieverAddress)
if(balance >= (100000000000n + amount)){
PluriContract.transferWithData(allowanceGiverAddress, recieverAddress, amount, metadata)
}
Last updated