const web3 = new Web3('https://ropsten.infura.io/v3/3c52917848e945229c0d33d632b10490');
const account1 = '0x0982081d5a2bba0a9da9fe722c92edc0cb0e9b6a'
const account2 = '0xabc46ddc17a0c37ef70e8a153d4724f199705e8b'
const ac1_pvtkey =Buffer.from('XXXX9F79B587B1DE553E2ADCA3DC8D49BE3E2840083D970C41D83F7FD471XXXX', 'hex');
const ac2_pvtkey =Buffer.from('XXXXC15FBDB4634400B7F8FA17C9491B2E346AEC1BC86A493B18F5759042XXXX', 'hex');
`web3.eth.getTransactionCount(account2, (err, txCount) => {
//build transaction here ---------------------------
const txObject = {
nonce: web3.utils.toHex(txCount),
to: account2,
value: web3.utils.toHex(web3.utils.toWei('0.2','ether')),
gaslimit: web3.utils.toHex(2100),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))
}
console.log(txObject)
//signing transaction here ---------------------------
const tx = new Tx(txObject);
tx.sign(ac2_pvtkey); //using account2 private key
------------------------------------------ERROR GIVING -------------------------------------------------- :
var sig = secp256k1.sign(msgHash, privateKey);
^
RangeError: private key length is invalid `
Hey @VishalDalve, did you happen to find a solution to this yet? I am running into the exact same thing.
Hi, I got solution, I'll share it soon.
On Fri 24 Aug, 2018, 7:13 PM Natalie Chin, notifications@github.com wrote:
Hey @VishalDalve https://github.com/VishalDalve, did you happen to find
a solution to this yet? I am running into the exact same thing.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ethereum/web3.js/issues/1869#issuecomment-415762539,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ASfNkxW7vUfeCSHAf7Qc1uU4yvzNnbbpks5uUALqgaJpZM4V6I1c
.
@VishalDalve What is the solution? Faced with same issue.
Facing same issue, anyone with the solution?
@nanom1t @gabrielvenegas I found a solution to this problem, albeit not using web3. This error was causing our tests to invariably fail inconsistently. After talking to a few other devs in the community, I ended switching our framework to use ethers.js instead. If you're still running into issues with this, and it's not too difficult to switch to another tool, I'd recommend using ethers.js. In addition to the amazing documentation, it's consistently works.
@VishalDalve any solution?
The solution: use the private key without the "0x" prefix in the environment..
then it works..
@VishalDalve any solution?
The solution: use the private key without the "0x" prefix in the environment.. then it works..
Facing same issue, anyone with the solution?
The solution: use the private key without the "0x" prefix in the environment..
then it works..
The creator of this issue found a solution please ask him for further details. It looks like it isn't an issue on the side of Web3.js. Please open a new issue if this error still occurs on the latest version of Web3. (beta.50)
I have changed my private keys afterwards and now it is working. So I think your private keys are not accurate or not supported
Guys guys you know what?
The solution: use the private key without the "0x" prefix in the environment..
then it works..
Most helpful comment
The solution: use the private key without the "0x" prefix in the environment..
then it works..