[Solved] eth.sign() never returns also does not call back

Opcode Asks: eth.sign() never returns also does not call back
(This is using local ganache, metamask set up to localhost which is working otherwise)

I am trying to establish how to sign, here is my code:

        async function sign()
            console.log("sign func");

            let accounts = await web3.eth.getAccounts();
            console.log("account:", accounts[0]);
            let msg = "Some data";
            console.log("in data message:", msg);
            let prefix = "x19Ethereum Signed Message:n" + msg.length;
            let msgHash1 = web3.utils.sha3(prefix+msg);
            console.log("using hash:", msgHash1);

            let sig1 = await web3.eth.sign(msg, accounts[0]);
            console.log("signing...", sig1);

            //web3.eth.sign(msg, accounts[0]).then(console.log);

            let whoSigned1 = await web3.eth.accounts.recover(msg, sig1);
            console.log("WHO SIGNED", whoSigned1);

(code is triggered via a button, works fine functionally aka it gets called)

All console logs until eth.sign happen just normal, correct account as well. Then metamask asks to confirm the signature, just like I would expect.


I click sign and thats it, nothing ever happens. The function does not return, no further code is ever called. Meaning it never calls back, it awaits forever. I also used then() syntax, same thing, never calls back.

If I do another transaction, while waiting, like minting an NFT, no problem goes through.

I switched metamask to rinkeby, same behavior. Switched it’s mainnet, same. So I guess it’s my code?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.