0

I start an Ethereum client at http://localhost:8545, and then execute the following script in NodeJS:

let fs = require("fs");
let Web3 = require("web3");

let web3 = new Web3("http://localhost:8545");

let abi = fs.readFileSync("Test.abi").toString();
let bin = fs.readFileSync("Test.bin").toString();

let contract = new web3.eth.Contract(JSON.parse(abi));
let transaction = contract.deploy({data: "0x" + bin});

let options = {
    to  : transaction._parent._address,
    data: transaction.encodeABI(),
    gas : await transaction.estimateGas()
};

let signedTransaction = await web3.eth.accounts.signTransaction(options, PRIVATE_KEY);
let receipt = await web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);

console.log("contract deployed at address", receipt.contractAddress);

When the Ethereum client is Parity, this script completes successfully.

When the Ethereum client is GETH, function sendSignedTransaction throws:

known transaction, which is followed by a 64-digit hexadecimal number string.

My GETH configuration is:

--networkid=100 
--port=60001    
--rpc           
--rpcport=8545  
--lightkdf      
--cache=16      
--datadir=./data

A similar question was posted here, but the answer doesn't seem to work for my case.

Can anybody shed some light on this?

Thank you!

UPDATE:

When I add --mine in the configuration, the problem is solved.

I would still be happy to know the reason, as I do not wish to start the node with mining enabled.

Your Answer

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

Browse other questions tagged or ask your own question.