0

I am using AlchemyProvider with ether.js to deploy a smart contract using frontend data But I am not able to sign the provider i.e AlchemyProvider.

Code

const provider = new ethers.providers.AlchemyProvider("maticmum","apikey");
const signer = provider.getSigner()

Error

Error: API provider does not support signing (operation="getSigner", code=UNSUPPORTED_OPERATION, version=providers/5.7.2)

1 Answer 1

0
AlchemyProvider extends UrlJsonRpcProvider

and UrlJsonRpcProvider implements getSigner as follows:

getSigner(address?: string): JsonRpcSigner {
    return logger.throwError(
        "API provider does not support signing",
        Logger.errors.UNSUPPORTED_OPERATION,
        { operation: "getSigner" }
    );
}

If you need a signer for deployment - create wallet and pass the alchemy provider to it:

const signer = new ethers.Wallet("PRIVATE_KEY", ALCHEMY_PROVIDER)
1
  • Thanks @Konsantin its working now. Mar 8, 2023 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.