1

I've been trying to get a transaction to execute on Polygon but it's been failing with the following error:

  reason: 'processing response error',
  code: 'SERVER_ERROR',
  body: '{"jsonrpc":"2.0","id":89,"error":{"code":-32000,"message":"transaction underpriced"}}',

This error only occurs on Polygon and it only occurs when using the Gnosis SDK. I've tested it using the Gnosis UI and it executes successfully. I've also tested it using the Gnosis SDK on rinkeby and that works as well.

Here is the code that fails:

const infuraProvider = new ethers.providers.JsonRpcProvider(RPC_PROVIDER);

const wallet = new ethers.Wallet(`0x${PRIVATE_KEY}`, infuraProvider);
const owner1 = wallet.connect(infuraProvider);

const ethAdapterOwner1 = new EthersAdapter({ ethers, signer: owner1 });

const safeSdkInstance = await Safe.create({
    ethAdapter: ethAdapterOwner1,
    safeAddress: GNOSIS_SAFE_ADDR,
});

const contract = new ethers.Contract(contractJson.address, contractJson.abi, owner1);

const tx = {
    to: contract.address,
    value: '0',
    data: contract.interface.encodeFunctionData('mint', ['[wallet address here]', '[token id here]']),
};
const safeTransaction = await safeSdkInstance.createTransaction(tx);

const executeTxResponse = await safeSdkInstance.executeTransaction(safeTransaction);

Other things I've tried:

  • Adding a gasPrice - making that gas price incredibly large
  • Adding a gasLimit
  • Changing RPC_PROVIDER from an infura provider to a public one
  • Calling a different function - I tried calling my contracts burn function and it came back with the exact same error

I did notice that even when providing a gasPrice the error I get back says that the transaction provided had a gasPrice of null. But when logging the safeTransaction object it shows a gasPrice is generated by the createTransaction function. So something must be going wrong in the executeTransaction function

1 Answer 1

2

I was able to solve this with the following code:

const executeTxResponse = await safeSdkInstance.executeTransaction(safeTransaction, {
    value: ethers.utils.parseEther('0'),
    gasPrice: ethers.utils.parseUnits('50', 'gwei'),
});

I had to pass in some more options to the executeTransaction function. Previously I passed in no options to this but adding a value and gasPrice seems to solve it.

1
  • Hello. Please explain what options you needed to ad. Your code snippet is a bit too big for readers to be able to identify the elements easely. Jun 2, 2022 at 5:58

Your Answer

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

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