I run ganache, truffle and metmask. If I run the code below I get an error on the this.web3.eth.sendSignedTransaction() function:
EDIT: changed my code to the following.. Error remained the same though.
const encoded_tx = this.contract.methods.createCountry("NL", 100, 100, 100000000, this.account).encodeABI();
const nonce = await this.web3.eth.getBlockTransactionCount(this.account);
const rawTx = {
nonce: this.utils.toHex(nonce),
gasLimit: this.utils.toHex(3000000),
gasPrice: this.utils.toHex(this.utils.toWei('20', 'gwei')),
data: encoded_tx,
from: this.account,
to: this.contractAddress
};
let tx = new Tx(rawTx);
tx.sign(this.pvtKey);
let serializedTx = tx.serialize();
this.web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);
The error is the following:
index.js:2178 Error: Returned error: {"id":6,"jsonrpc":"2.0","error":{"code":-32603}}
at Object.ErrorResponse (errors.js:29)
I have absolutely no idea where to look anymore and feel like I've tried everything, might it have anything to do with the fact that I'm connected to metamask? When I try to send this transaction through metamask with eth.method.send() the transaction does not give an error and behaves as expected.
-32603
(or more precisely, the hexadecimal representation of2^32 - 32603
).