Skip to content

Commit

Permalink
Add support for Wallet private keys without 0x prefix (ethers-io#3768).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo authored and Woodpile37 committed Jan 14, 2024
1 parent bad6548 commit 0820cc7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src.ts/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class Wallet extends BaseWallet {
* to %%provider%%.
*/
constructor(key: string | SigningKey, provider?: null | Provider) {
if (typeof(key) === "string" && !key.startsWith("0x")) {
key = "0x" + key;
}

let signingKey = (typeof(key) === "string") ? new SigningKey(key): key;
super(signingKey, provider);
}
Expand Down

0 comments on commit 0820cc7

Please sign in to comment.