I have the variable w1_temp, which i need to send to contract I have the following code:
var W1Temp = require('w1temp')
var Web3 = require('web3')
var web3 = new Web3()
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8042'))
var contractAddress = '0x414c49c9552c4bd41401ff0a67ff84431a900c66'
var ABI = JSON.parse(
'[ { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": false, "inputs": [
{ "name": "_sensorData", "type": "int256" } ], "name": "setSensorData", "outputs": [], "payable": false, "stateMutability":
"nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "getSensorData", "outputs": [ { "name": "",
"type": "int256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" } ] ')
var StoreIntegerValue = web3.eth.contract(ABI).at(contractAddress)
W1Temp.setGpioData(7)
W1Temp.getSensor('28-0316612396ff').then(function (sensor) {
var _sensorData = sensor.getTemperature();
});
eth.sendTransaction({
from: 'a57f7e5347bd04076dd02c02212c0221522289ff38940e',
to: '0x414c49c9552c4bd41401ff0a67ff84431a900c66',
value: web3.toWei(100,'finney'),
data: web3.toHex('_sensorData')
})
But I’m almost sure that it is not correct Please help to make it work