From 4665fb4c6886c8b344dee316ba9f4fde57ce7557 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sat, 18 Feb 2023 13:36:23 -0500 Subject: [PATCH] Add support for Wallet private keys without 0x prefix (#3768). --- src.ts/wallet/wallet.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src.ts/wallet/wallet.ts b/src.ts/wallet/wallet.ts index 355f51e9d..23a932ea6 100644 --- a/src.ts/wallet/wallet.ts +++ b/src.ts/wallet/wallet.ts @@ -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); }