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

Unable to sign messages using EthereumPrivateKeyProvider #783

Open
sudeepkotari opened this issue Oct 27, 2022 · 0 comments
Open

Unable to sign messages using EthereumPrivateKeyProvider #783

sudeepkotari opened this issue Oct 27, 2022 · 0 comments

Comments

@sudeepkotari
Copy link

Unable to sign messages using EthereumPrivateKeyProvider.

I'm trying to get Provider (which can sign and send transaction) from private key using @web3auth/ethereum-provider package, but I'm able to get provider but getting error while signing the message using that private key.

To Reproduce

`import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import type { SafeEventEmitterProvider } from "@web3auth/base";
const signEthMessage = async (provider: SafeEventEmitterProvider): Promise => {
const web3 = new Web3(provider as any);
const accounts = await web3.eth.getAccounts();
// hex message
const message = "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad";
const signature = await web3.eth.sign(message, accounts[0]);
return signature;
};

(async () => {
const provider = await EthereumPrivateKeyProvider.getProviderInstance({
chainConfig: {
rpcTarget: "https://polygon-rpc.com",
chainId: "0x89", // hex chain id
networkName: "matic",
ticker: "matic",
tickerName: "matic",
},
privKey: "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318",
});
const signedMessage = await signEthMessage(provider);
})();`

Steps to reproduce the behavior:

  1. Run above code to sign message using private key.

Expected behavior

it should sign message using private key.

Screenshots

If applicable, add screenshots to help explain your problem.
Screenshots of console logs are welcome

Device Info (please complete the following information):

  • Device: Xiomi notebook pro 2021
  • OS: Ubuntu 22.04
  • Browser chrome
  • Version [e.g. 22]
  • Web3Auth Version 3.0

Additional context

Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant