Skip to main content
I went an put a full working example on the ethereum blockchain
Source Link

Here's how you would do it with the web3 api.

const Utils = require('web3-utils');
let txTransfer = {};
txTransfer.from = from.address;
txTransfer.to = to.address;
txTransfer.gas = GasLimit;
txTransfer.value = amount;
txTransfer.data = Utils.toHex('free text data');
web3.eth.sendTransaction(txTransfer);

I have a working example on the blockchain at this transaction 0x99f537b788c1e0c9513735c644921ffa423f8bd20ce45165403e8f12942aaca8. The ascii data in the transaction was the same JavaScript used to send the transaction.

Here's how you would do it with the web3 api.

const Utils = require('web3-utils');
let txTransfer = {};
txTransfer.from = from.address;
txTransfer.to = to.address;
txTransfer.gas = GasLimit;
txTransfer.value = amount;
txTransfer.data = Utils.toHex('free text data');
web3.eth.sendTransaction(txTransfer);

Here's how you would do it with the web3 api.

const Utils = require('web3-utils');
let txTransfer = {};
txTransfer.from = from.address;
txTransfer.to = to.address;
txTransfer.gas = GasLimit;
txTransfer.value = amount;
txTransfer.data = Utils.toHex('free text data');
web3.eth.sendTransaction(txTransfer);

I have a working example on the blockchain at this transaction 0x99f537b788c1e0c9513735c644921ffa423f8bd20ce45165403e8f12942aaca8. The ascii data in the transaction was the same JavaScript used to send the transaction.

Source Link

Here's how you would do it with the web3 api.

const Utils = require('web3-utils');
let txTransfer = {};
txTransfer.from = from.address;
txTransfer.to = to.address;
txTransfer.gas = GasLimit;
txTransfer.value = amount;
txTransfer.data = Utils.toHex('free text data');
web3.eth.sendTransaction(txTransfer);