I am trying to send a transaction to a Besu node that I have running locally. However, from the following code, when I run npx ts-node myFile.ts
, I get Error: Invalid JSON RPC response
:
const Web3 = require('web3');
let web3 = new Web3(new Web3.providers.HttpProvider('https://localhost:88888'));
const e2f = require("./build/contracts/ERC20Fixed.json");
const e2fBytecode = e2f.bytecode;
const e2fAbi = e2f.abi
const myAcct = web3.eth.accounts.create(web3.utils.randomHex(32));
const myAddr = myAcct.address;
const besuMinerCoinbase = <besuMinerCoinbaseAddress>;
web3.eth.sendTransaction({
from: besuMinerCoinbase,
to: myAddr,
data: e2fBytecode,
}).then('transactionHash', function(transactionHash){
console.log('Hash: ', transactionHash);
}).then('error', function(e){
console.log(e);
});
Here is the full error message:
Hash: Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/Users/asdf/node_modules/web3-core-helpers/src/errors.js:45:16)
at XMLHttpRequest.request.onreadystatechange (/Users/ahan/node_modules/web3-providers-http/src/index.js:107:32)
at XMLHttpRequestEventTarget.dispatchEvent (/Users/ahan/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (/Users/ahan/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpRequestError (/Users/ahan/node_modules/xhr2-cookies/xml-http-request.ts:379:8)
at ClientRequest.<anonymous> (/Users/ahan/node_modules/xhr2-cookies/xml-http-request.ts:266:37)
at ClientRequest.emit (events.js:315:20)
at ClientRequest.EventEmitter.emit (domain.js:482:12)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at TLSSocket.EventEmitter.emit (domain.js:482:12)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
I know that I am pinging is correct b/c when I CURL other endpoints, I get correct responses. Looking at the web3.js docs, I'm not sure what I am missing. How do I successfully send a transaction?