Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendSignedTransaction is not working #1134

Closed
NicholasJarr opened this issue Oct 22, 2017 · 9 comments
Closed

sendSignedTransaction is not working #1134

NicholasJarr opened this issue Oct 22, 2017 · 9 comments
Assignees
Labels
Bug Addressing a bug In Progress Currently being worked on

Comments

@NicholasJarr
Copy link

NicholasJarr commented Oct 22, 2017

When I call sendSignedTransaction it throws: invalid argument 0: json: cannot unmarshal hex string of odd length into Go value of type hexutil.Bytes. I'm using geth with a private chain (with the -dev flag). The web3.js was installed with npm and the version is: ^1.0.0-beta.24.
I get the private key from the decrypt method and using the JSON from the keystore. start is the contract function that I'm calling. It has one argument (an int) and it is not payable. I think there might something wrong with the rawTransaction that is returned with the signTransaction method.

var admin = "0x2694fC48505267C8159850aC7Df2c280a17d2C46";
var contract_address = "0x19496da364962A5Ac96139775F8d50d5d31605f9";
var tx = {
    from: admin,
    to: contract_address,
    gas: 184000,
    data: start.encodeABI(),
    chainId: "1337"
};
web3.eth.accounts.signTransaction(tx, private_key).then((hash) =>{
    web3.eth.sendSignedTransaction(hash.rawTransaction).then((receipt) =>{
        resolve();
    }, (error) =>{
        console.log(error);
        reject(500);
    });
}, (error) =>{
    reject(500);
});
hash.rawTransaction == "0xf986.84d808302cec09419496da364962a5ac96139775f8d50d5d31605f980a495805dad000000000000000000000000000000000000000000000000000000000000001481.8a95a00f9daa90306d103f908f6c8064a5ce005e7608ea14ddf469a73943e2a2ea54b5a012de7959ceee8d3d685d6622d77949a879b364165bcfd6f9fea88c4d1ea51aa3"
@NicholasJarr
Copy link
Author

NicholasJarr commented Oct 22, 2017

I have found a temporary solution. I unlock the account, do the transaction and then I lock it again.

web3.eth.personal.unlockAccount(admin, "p").then((suc) =>{
    start.send(tx).then((receipt) =>{
        console.log(receipt);
        web3.eth.personal.lockAccount(admin, "p").then((suc) => {
            resolve();
        });
    }, (error) =>{
        console.log(error);
        web3.eth.personal.lockAccount(admin, "p").then((suc) =>{
            reject(500);
        });
    });
}, (error) =>{
    reject(500);
});

@idrabenia
Copy link

idrabenia commented Nov 4, 2017

I have the same error!

@Wullee
Copy link

Wullee commented Nov 4, 2017

You must sign the directives, you may need to visit the wiki.

@idrabenia
Copy link

Hello @Wullee ,

What does it mean "sign the directives"? Transaction is signed in code under - as you may see.
What is "directive"? I see only javascript objects and properties.

@NicholasJarr
Copy link
Author

I'm using the documentation from ReadTheDocs

@daragao
Copy link

daragao commented Nov 22, 2017

Anyone found a solution for this?

If i use testrpc and add chainId to the transaction object it signs well, but with geth it does not :(
Any ideas?

@zaro
Copy link

zaro commented Jan 30, 2018

Can confirm the same, I made a private chain with puppeth, and if I change the chain_id to 3 for example, it works fine. If I try to use chain_id 1337 it fails.

Edit: Just tested 88 it also works, so this has something to do with how big the chain_id is.

@nivida nivida self-assigned this Aug 9, 2018
@nivida nivida added the Bug Addressing a bug label Aug 9, 2018
@nivida nivida added the In Progress Currently being worked on label Aug 20, 2018
@imhari213
Copy link

web3.eth.sendSignedTransaction is not a function getting this error can anyone help me on this please....

@roqueorts
Copy link

Good morning,
Is there any solution? Still not working with ropsten blockchain, when it works using Ganache.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug In Progress Currently being worked on
Projects
None yet
Development

No branches or pull requests

8 participants