1

Trying to send a transaction with Alchemy-sdk, but I keep getting invalid sender. What am I doing wrong or missing, code below:

My provider is created using ethers.providers.JSONRPCProvider(alchemyurlincludingAPIKEY)

const PRIVATE_KEY = 'priv_key'
const config = {
  apiKey: 'api_string',
  network: Network.Polygon
}
const wallet2 = new Wallet(PRIVATE_KEY)
const alchemy = new Alchemy(config);

const customContract = new ethers.Contract(
      signature.relay_address,
      customABI,
      provider
    );

    try {
      let tx:any = await customContract.populateTransaction.function(
        msg.from,
        .,
        .
        {
          type: 2,
          maxFeePerGas: Utils.parseUnits("200", "gwei"),
          maxPriorityFeePerGas: Utils.parseUnits("200", "gwei")

        }
      );
      tx.chainId = 137
      const signedTransaction = await wallet2.signTransaction(tx);
      const response = await alchemy.transact.sendTransaction(tx);
      new Promise(async (resolve) => {
        try {
          await alchemy.transact.waitForTransaction((response as Transaction).hash!.valueOf(), 2, 
      60000);

Response is this :

{
jsonrpc:"2.0",
id:43,
error:{
code:-32000,
message:"invalid sender"
}
}

1 Answer 1

0

Problem was this:

const config = { apiKey: 'api_string', network: Network.MATIC_MAINNET }

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.