3

I'm getting an error using web3.eth.personal.sign, with it complaining that the call "Expected 0 arguments, but got 3". I call it in an Angular/Typescript/javascript environment:

this.bottleSig=this.web3.eth.personal.sign(this.bottleDataToSign, this.addressProd, this.passwordProd);

I'm using a recent version of the npm web3 package: 1.0.0-beta.33. I'm following the documentation at http://web3js.readthedocs.io/en/1.0/web3-eth-personal.html. I poked around under .../node_modules and looked at various web3* directories, but nothing obvious looked wrong, at least to me. Under node_modules/web3-eth-personal/src/index.js, it looks like it should be expecting 3 args:

new Method({
        name: 'sign',
        call: 'personal_sign',
        params: 3,
        inputFormatter: [formatters.inputSignFormatter, formatters.inputAddressFormatter, null]
    }),

Any searching returns very few results, which don't seem to be applicable here. Any thoughts on what's wrong? How to fix/workaround? Since beta, just need to wait till "fixed"? Thanks.

Update:

Also, in node_modules/web3/types.d.ts, I see:

export declare class Eth . . . personal: Personal

export declare class Personal . . . sign()

Is this where the expectation of 0 arguments is gotten from?

Update2:

This link seems to offer some solutions, but a little too deep into directives and controllers for me!

http://danlec.com/st4k#questions/46692046

  • I think I had this problem before. And it was because I ahd to stringfy. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… – Luiz Soares Mar 21 '18 at 18:09
  • Does that really apply here? I'm just passing it a constructed string, with no usage of json, although it might have an embedded "0x" since part of it was from a web3.utils.sha3 call. – gkd720 Mar 21 '18 at 18:16
  • You are right. Probably not applying to it. It was just a quick tip to try to help. I had this problem before and I was quite sure it was related to stringfy. I will try to remember the exact scenario so I can be more helpful – Luiz Soares Mar 21 '18 at 18:23
0

Looks like that types.d.ts is incomplete. If you're using Angular, my guess is the TS compilation is what's complaining. (If you were able to just run it, it would work because you're using it correctly.)

You can test this theory by changing that types.d.ts file (looks like line 465 in class Personal) to:

sign(dataToSign: string, address: string, password: string, cb?: Callback<string>): Promise<string>

If that works, the theory is correct and the file/package just needs to be completed.

  • Excellent! That cleared up the reported Typescript error. Looks like a few more methods will need that treatment, also having empty argument specs, and I suspect that these specs are primarily (only?) for type checking. Thanks for looking into this. I clicked on the up-vote, but apparently I'm net yet reputable enough (13 < 15)! – gkd720 Mar 25 '18 at 16:24
  • That's great news! (You should be able to click the green check to mark this as the answer. That should even give you points for getting a question answered.) – Jamie Hale Mar 25 '18 at 16:47

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.