Skip to content

Instantly share code, notes, and snippets.

@jonathunne
Created January 9, 2020 05:47
Show Gist options
  • Select an option

  • Save jonathunne/a43ad6a78c09bdf1eb98e77fd2ee3a81 to your computer and use it in GitHub Desktop.

Select an option

Save jonathunne/a43ad6a78c09bdf1eb98e77fd2ee3a81 to your computer and use it in GitHub Desktop.
Send Eth Function - Node Red ethersjs
// paste into the "function" node in node-red
ethers = global.get('ethers');
let provider = ethers.getDefaultProvider(flow.get("network"));
const deployerPK = flow.get("deployer_pk");
let wallet = new ethers.Wallet(deployerPK, provider);
let amount = ethers.utils.parseEther('0.001');
let to = msg.payload.user.fields.Address;
async function transfer() {
let tx = {
to: to,
// ... or supports ENS names
// to: \"ricmoo.firefly.eth\",
value: amount
};
let result = await wallet.sendTransaction(tx);
sendPromise.then((tx) => {
console.log(tx);
{
// All transaction fields will be present
"nonce", "gasLimit", "gasPrice", "to", "value", "data",
"from", "has", "r", "s", "v"
}
});
msg.payload = result;
node.send(msg);
node.done();
}
transfer();
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment