I have met a problem when I am developing a Metamask installed Dapp.

I am using web3.personal.sign()to get the signature of accounts. However, I could not get the returned signature string from this function. I want to put the signature into another variable, but this variable is always undefined and cannot be printed.

At the meantime, the resultant signature can be printed when I using console.log()as a callback function, but it still cannot return a string.

The sample code is like web3.personal.sign(nonce,web3.eth.coinbase,console.log). In this way, the signature can be printed otherwise the result is always undefined.

I have checked all the web3 API documentations, saing the function will return a tring, but I just cannot get it.

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.