ApproveWithData
Give a Pluri allowance to another address (this means that address can withdraw up to the amount you specified), sending metadata alongside the transaction.
let targetAddress = '0x959FD7Ef9089B7142B6B908Dc3A8af7Aa8ff0FA1'
let senderAddress = '0x4E90a36B45879F5baE71B57Ad525e817aFA54890'
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(senderAddress).call();
if(balance >= (100000000000n + amount)){
PluriContract.methods.approveWithData(targetAddress, amount, metadata).send({ from: senderAddress })
}
//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(senderAddress)
if(balance >= (100000000000n + amount)){
PluriContract.approveWithData(targetAddress, amount, metadata)
}
Last updated