I'm trying to use NODE-RED (https://nodered.org/) on my RPi using web3 and geth to send simple transactions.

The code is the following:

var Web3 = global.get('web3');
var upc_abi = //contract abi
var upc_address = "0x15fC1a048C29C95605cbf906cC1f259573e49f4D";
var rpi_coinbase = "0x915c9fd51313cee6c94ae4f30d86edf2e79c8fe8";//accounts[0];
var rpi_1 = "0x0405468b70803989b7318d45d1a9c0bddffa6feb";

//web3.js, checking if node is running
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

if (!web3.isConnected()) {
    node.status({fill:"red",shape:"ring",text:"node not connected"});

} else {
    node.status({fill:"green",shape:"ring",text:"node connected"});

//fetching smart contract UPC
const Contract_upc = web3.eth.contract(upc_abi);
const Upc = Contract_upc.at(upc_address);

node.send({payload:"Sending payment..."});

Upc.transferFrom(rpi_coinbase, rpi_1, 110, {
    from: rpi_coinbase,
    gas: 300000


The function transferFrom that I use is taken from a token contract copied and pasted from the Ethereum website.

I tested the code using node.js and everything works fine, the tokens are correctly sent from one address to the other. However when I do it on NODE-RED the transaction is confirmed but the following error is returned:

Warning! Error encountered during contract execution [Bad instruction].

My guess is that is somehow related to how I unlock the account. I use:

> personal.unlockAccount('0x915c9fd51313cee6c94ae4f30d86edf2e79c8fe8',"password", 99999)

Do you think the issue is related to this? If yes, how to solve it? If not, what then?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.