Getting error "The execution failed due to an exception." in sokol RPC call - eth_estimateGas


#1

I am making an RPC call to https://sokol.poa.network URL for eth_estimateGas. The request json is below:

{
    "method": "eth_estimateGas",
    "params": [
        {
            "gasPrice": "0x3b9aca00",
            "from": "0x29D02699195632360D743Eb568fa71B8c8f744dc",
            "to": "0xa6Dc5E5B21D32929b4545126ec95670032c0c178",
            "data": "0x7b97008d000000000000000000000000000000000000000000000000016345785d8a0000"
        }
    ],
    "id": 42,
    "jsonrpc": "2.0"
}

I am getting this response:

{
    "jsonrpc": "2.0",
    "error": {
        "code": -32016,
        "message": "The execution failed due to an exception."
    },
    "id": 42
}

But the same RPC call gives response in mainet


Contract call always fails for my contract on sokol
#2

Hi,
a. to estimate gas price the ethereum node needs to have transactions on the network.
There are not many transactions on the Sokol network.
Thus, you get the error.

b. the gasPrice is fixed on Sokol and validators will accept valid transactions with 1 Gwei gas.


#3

Thanks for your reply

I have set the gasPrice to 1 Gwei and gasLimit to 8000,000 wei but still it does not work. i am using ether.js to connect with poa and make some contract calls

code snippet:

purchaseTokens(ethers.utils.parseEther(amount),{gasLimit:8000000,gasPrice:1000000000})

Logs:

{ Error: Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce.
    at getResult (/home/ajit-soman/git/test-backend/node_modules/ethers/providers/json-rpc-provider.js:40:21)
    at exports.XMLHttpRequest.request.onreadystatechange (/home/ajit-soman/git/test-backend/node_modules/ethers/utils/web.js:111:30)
    at exports.XMLHttpRequest.dispatchEvent (/home/ajit-soman/git/test-backend/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/home/ajit-soman/git/test-backend/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (/home/ajit-soman/git/test-backend/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  code: -32010,
  data: undefined,
  url: 'https://sokol.poa.network',
  body: '{"method":"eth_sendRawTransaction","params":["0xf8891f843b9aca00837a120094a6dc5e5b21d32929b4545126ec95670032c0c17880a47b97008d000000000000000000000000000000000000000000000000016345785d8a000081bda0a11e20c0157f42d8182769ceb5caf804e34a7bcff095c58746356967ee653e34a013791ae11ef16993edfbc32cf585c0119f6c988c714f75f79d07f58f6eb5d3db"],"id":42,"jsonrpc":"2.0"}',
  responseText: '{"jsonrpc":"2.0","error":{"code":-32010,"message":"Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."},"id":42}\n',
  transaction: 
   { nonce: 31,
     gasPrice: BigNumber { _hex: '0x3b9aca00' },
     gasLimit: BigNumber { _hex: '0x7a1200' },
     to: '0xa6Dc5E5B21D32929b4545126ec95670032c0c178',
     value: BigNumber { _hex: '0x00' },
     data: '0x7b97008d000000000000000000000000000000000000000000000000016345785d8a0000',
     chainId: 77,
     v: 189,
     r: '0xa11e20c0157f42d8182769ceb5caf804e34a7bcff095c58746356967ee653e34',
     s: '0x13791ae11ef16993edfbc32cf585c0119f6c988c714f75f79d07f58f6eb5d3db',
     from: '0x29D02699195632360D743Eb568fa71B8c8f744dc',
     hash: '0xf65b934ca0655d1c4de607335bbf280828c2038fde0650c52c7d50e8f7dba39b' },
  transactionHash: '0xf65b934ca0655d1c4de607335bbf280828c2038fde0650c52c7d50e8f7dba39b' }

If i increase the gas limit then i am getting this error:

Transaction cost exceeds current gas limit. Limit: 8000000, got: 9000000. Try decreasing supplied gas.