0

I have a code block for sending transaction

let address_from = '0x0b2af884cc5a98816ba186ca6f7e839a7dd36053';
let address_to = req.params.address;

let nonce = web3.eth.getTransactionCount(address_from);
let private_key = coddyger.key_from_file(address_from);
let gasPrice = "2";//or get with web3.eth.gasPrice
let gasLimit = 3000000;
let amount = web3.toWei(parseFloat(2), 'ether');

let rawTransaction = {
    from: address_from,
    nonce: web3.toHex(nonce),
    gasPrice: web3.toHex(gasPrice * 1e9),
    gasLimit: web3.toHex(gasLimit),
    to: address_to,
    value: web3.toHex(amount)
};
let tx = new Tx(rawTransaction);
tx.sign(private_key);
let serializedTx = tx.serialize();
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
    if (!err) {
        console.log({tx_hash: hash});
        res.send({
            status: 1,
            message: [],
            tx_hash: hash
        });
    } else {
        console.error(err);
        res.send({
            status: 0,
            message: 'Error occurred while sending transaction.',
            tx_hash: null
        });
    }
});

That worked yesterday now I get that error

TypeError: Cannot read property 'Crypto' of undefined
at Object.recover (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\keythereum\index.js:423:33)
at Object.key_from_file (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\cdg_system\coddyger.js:12:36)
at D:\x21host\xData\public_html\xUD\ethxplore\web3_server\cdg_routes\account.js:83:32
at Layer.handle [as handle_request] (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\layer.js:95:5)
at next (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\layer.js:95:5)
at D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\index.js:281:22
at param (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\index.js:354:14)
at param (D:\x21host\xData\public_html\xUD\ethxplore\web3_server\node_modules\express\lib\router\index.js:365:14)

I need your help please

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.