TransferWithData
Transfer Pluri tokens to an address, sending metadata alongside the transaction.
Method: PluriContract.transferWithData(type 1, type 2, type 3)
Types
String - Address of recipient to send Pluri to. Can be a wallet address or a smart contract address. Example: "0X959FD7Ef9089B7142B6B908Dc3A8af7Aa8ff0FA1"
BigInt - The amount of Pluri to send. Example: 4n
Hex string - Convert the desired data to send as metadata from utf8 to bytes, then convert the bytes to a hex string. Example: "0X7b2248656c6c6f223a22576f726c64227d" originates from hexlify(toUtf8Bytes(JSON.stringify({"Hello","World"}))
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.transferWithData(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.transferWithData(targetAddress, amount, metadata)
}
Last updated