1

I am using a JSON RPC request and source code is as follows:

var options ={
    url: "http://127.0.0.1:8545",
    method: "POST",
    headers: {"Content-Type":"application/json"}   
};
var tx = {from: req.body.fromaddress,  to: req.body.toaddress,  value: web3.utils.toWei(req.body.amount, "ether")};
    options.body = JSON.stringify({"jsonrpc":"2.0", "method":"personal_sendTransaction", "params":[tx, req.body.password], "id":"curltest"});
    callback = (err, response, body) => {
        if (!err && response.statusCode == 200) {
            const data = JSON.parse(body);
            console.log(data);
            res.send(data);
        }
        if (err) {
            console.error(err);
            res.send(err);
        }
    };
    request(options, callback);
0

Your value field of tx must be pre-pended with 0x. If the value is 0, then tx.value must be 0x0..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.