I am creating a wallet app and trying to sign and send raw transactions using eth-lightwallet.

function functionCallWallet(){
        var fromAddr = document.getElementById('functionCaller').value
        var contractAddr = document.getElementById('contractAddr').value
        console.log("Contract Address:"+contractAddr);
        var abi = JSON.parse(document.getElementById('contractAbi').value)
        console.log(typeof abi);
        var contract = web3.eth.contract(abi).at(contractAddr);
        var functionName = document.getElementById('functionName').value;
        var args = document.getElementById('functionArgs').value.split(",");
        var gasPrice = 50000000000
        var gas = 3141592
        txOptions = {
            gasPrice: gasPrice,
            gasLimit: gas,
            value: 10000000,
        txOptions.to = contractAddr;
        var functionCallTx = txutils.functionTx(abi,functionName,args,txOptions);
        var password = prompt('Enter password ', 'Password');
        lightwallet.keystore.deriveKeyFromPassword(password, function(err, pwDerivedKey) {
        var signedFunctionTx = signing.signTx(global_keystore,pwDerivedKey,functionCallTx,fromAddr);
        console.log("Signed function transaction:"+signedFunctionTx);
        web3.eth.sendRawTransaction('0x'+signedFunctionTx, function(err, hash) {

I am able to sign the transaction correctly. But when it comes to sending the raw transaction on the network I am unsuccessful. In the web3 api they use https://github.com/ethereum/wiki/wiki/JavaScript-API#example-45 they use the ethereumjs-accounts library to serialize the raw transaction to hex. Does eth-lightwallet also have a serialize to hex function so that it could be used and then data is in format used by the web3 sendRawTransaction function or do have to use the ethereumjs-accounts library mentioned in web3 docs ?

I am getting this error, obviously I am not serializing it the correct way but I will put the error anyway

Error: rlp: input string too long for uint64, decoding into (types.Transaction)(types.txdata).AccountNonce
    at Object.module.exports.InvalidResponse 

I think the decoding error is on the nounce value (nonce:2.0e20) inside txOptions. It should be an integer value, let's say something like nonce: 31 (or nonce:'0x1F' if you prefer the hex form).

| improve this answer | |
  • Thanks for your reply, but according to their example usage, does not seem to be the case. github.com/ConsenSys/eth-lightwallet/blob/master/example/…. I feel a decimal nonce might do. – codestruggle Aug 9 '16 at 10:31
  • 1
    It's an integer also in their example. Nonce value is first set to 2, and then it is increased by 1 each time. – Giuseppe Bertone Aug 9 '16 at 10:34
  • I was testing on morden hence nonce values start from 2^ 20 which is 1048576 in decimal. When I put 1048576 for the nonce my problem was solved. @Guiseppe Bertone you can edit your answer actually. – codestruggle Aug 9 '16 at 10:47
  • Done. Nonce needs to be an integer. – Giuseppe Bertone Aug 9 '16 at 12:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.