Matic Remix Warning! Error encountered during contract execution [execution reverted]

1.5k Views Asked by At

I forked a contract, it is a Baked Beans fork on MATIC, I deployed the contract through Remix, now when I try to deposit through my website script, Metamask says

We were not able to estimate gas. There might be an error in the contract and this transaction may fail.

Setting gas manually also fails. Tried sending MATIC directly to the contract address, but then it fails with

Warning! Error encountered during contract execution [execution reverted]

Yet when I try sending MATIC to the exact same contract that I copied, it works fine, even when I replace the contract address on my website script with any other fork contract that has the same code, works well, but not with mine.

I tried to deploy the contract from Remix aswell as Hardhat, same result.

Here is the contract: [https://polygonscan.com/address/0x3ff5aa997f9599a24599ef517b8eb7be804562e7#code][1]

Also here is the errors my websites console shows

    Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0x397e1b4cc7b4de7f320c0f473f6a9b80199cdec0ad5809fc6f55cb7f5c9877f1",
  "blockNumber": 27956016,
  "contractAddress": null,
  "cumulativeGasUsed": 13409979,
  "effectiveGasPrice": "0x117b5b01ec",
  "from": "0x793192a51285d446c8f6f16db9333466a98fda85",
  "gasUsed": 23620,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000080000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000000000000000000000080000000000000000000000010000000000000000000000000000000000000000000000000000000201000000000000000000000000000000000000000000000020000000000004000000000000000000001000000000000000000000400000000100000000000000000000000000000000000000000000000000000000000008000000000100000",
  "status": false,
  "to": "0x3ff5aa997f9599a24599ef517b8eb7be804562e7",
  "transactionHash": "0xcf66ea0cbf00069e5074034de3e57930c48f2a37e440cae74c9f028f072e70db",
  "transactionIndex": 70,
  "type": "0x2",
  "events": {
    "0": {
      "address": "0x0000000000000000000000000000000000001010",
      "blockHash": "0x397e1b4cc7b4de7f320c0f473f6a9b80199cdec0ad5809fc6f55cb7f5c9877f1",
      "blockNumber": 27956016,
      "logIndex": 352,
      "removed": false,
      "transactionHash": "0xcf66ea0cbf00069e5074034de3e57930c48f2a37e440cae74c9f028f072e70db",
      "transactionIndex": 70,
      "id": "log_ac0824b2",
      "returnValues": {},
      "signature": null,
      "raw": {
        "data": "0x00000000000000000000000000000000000000000000000000035b4a6462400000000000000000000000000000000000000000000000000050923d2836055dd1000000000000000000000000000000000000000000000d8767e614b7af8391f8000000000000000000000000000000000000000000000000508ee1ddd1a31dd1000000000000000000000000000000000000000000000d8767e9700213e5d1f8",
        "topics": [
          "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63",
          "0x0000000000000000000000000000000000000000000000000000000000001010",
          "0x000000000000000000000000793192a51285d446c8f6f16db9333466a98fda85",
          "0x000000000000000000000000c6869257205e20c2a43cb31345db534aecb49f6e"
        ]
      }
    }
  }
}
    at Object.TransactionError (errors.js:87:21)
    at Object.TransactionRevertedWithoutReasonError (errors.js:98:21)
    at index.js:393:57
    at s (runtime.js:63:40)
    at Generator._invoke (runtime.js:293:22)
    at Generator.next (runtime.js:118:21)
    at r (asyncToGenerator.js:3:20)
    at o (asyncToGenerator.js:25:9)
    at asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
(anonymous) @ BakeCard.js:128
s @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
n @ asyncToGenerator.js:3
f @ asyncToGenerator.js:29
Promise.then (async)
n @ asyncToGenerator.js:13
o @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
(anonymous) @ BakeCard.js:146
Qe @ react-dom.production.min.js:52
Ke @ react-dom.production.min.js:52
(anonymous) @ react-dom.production.min.js:53
Sn @ react-dom.production.min.js:100
En @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
Be @ react-dom.production.min.js:292
(anonymous) @ react-dom.production.min.js:50
Nn @ react-dom.production.min.js:105
$t @ react-dom.production.min.js:75
Xt @ react-dom.production.min.js:74
t.unstable_runWithPriority @ scheduler.production.min.js:18
Qa @ react-dom.production.min.js:122
Pe @ react-dom.production.min.js:292
Vt @ react-dom.production.min.js:73



















MetaMask - RPC Error: Internal JSON-RPC error. {code: -32603, message: 'Internal JSON-RPC error.', data: {…}}
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:17
_runReturnHandlers @ inpage.js:17
_processRequest @ inpage.js:17
await in _processRequest (async)
_handle @ inpage.js:17
handle @ inpage.js:17
_rpcRequest @ inpage.js:1
(anonymous) @ inpage.js:1
request @ inpage.js:1
bound bound request @ util.js:693
f.send @ index.js:155
u @ index.js:615
n @ index.js:647
b._executeMethod @ index.js:768
(anonymous) @ BakeCard.js:90
s @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
n @ asyncToGenerator.js:3
o @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
(anonymous) @ BakeCard.js:109
(anonymous) @ BakeCard.js:128
s @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
n @ asyncToGenerator.js:3
f @ asyncToGenerator.js:29
Promise.then (async)
n @ asyncToGenerator.js:13
o @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
(anonymous) @ BakeCard.js:146
Qe @ react-dom.production.min.js:52
Ke @ react-dom.production.min.js:52
(anonymous) @ react-dom.production.min.js:53
Sn @ react-dom.production.min.js:100
En @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
Be @ react-dom.production.min.js:292
(anonymous) @ react-dom.production.min.js:50
Nn @ react-dom.production.min.js:105
$t @ react-dom.production.min.js:75
Xt @ react-dom.production.min.js:74
t.unstable_runWithPriority @ scheduler.production.min.js:18
Qa @ react-dom.production.min.js:122
Pe @ react-dom.production.min.js:292
Vt @ react-dom.production.min.js:73

















beanrewards Error: Internal JSON-RPC error.
{
  "code": 3,
  "message": "execution reverted",
  "data": "0x4e487b710000000000000000000000000000000000000000000000000000000000000012"
}
    at Object._fireError (index.js:49:17)
    at c (index.js:539:30)
    at c (util.js:689:22)
    at C (util.js:666:10)
    at h.run (browser.js:153:14)
    at l (browser.js:123:42)
(anonymous) @ BakeCard.js:66
Promise.catch (async)
(anonymous) @ BakeCard.js:90
s @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
n @ asyncToGenerator.js:3
o @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
(anonymous) @ BakeCard.js:109
(anonymous) @ BakeCard.js:128
s @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
n @ asyncToGenerator.js:3
f @ asyncToGenerator.js:29
Promise.then (async)
n @ asyncToGenerator.js:13
o @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
(anonymous) @ BakeCard.js:146
Qe @ react-dom.production.min.js:52
Ke @ react-dom.production.min.js:52
(anonymous) @ react-dom.production.min.js:53
Sn @ react-dom.production.min.js:100
En @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
Be @ react-dom.production.min.js:292
(anonymous) @ react-dom.production.min.js:50
Nn @ react-dom.production.min.js:105
$t @ react-dom.production.min.js:75
Xt @ react-dom.production.min.js:74
t.unstable_runWithPriority @ scheduler.production.min.js:18
Qa @ react-dom.production.min.js:122
Pe @ react-dom.production.min.js:292
Vt @ react-dom.production.min.js:73

And if I run queries in Remix:

call to BakedOnions.beanRewards errored: Internal JSON-RPC error.
{
  "code": 3,
  "message": "execution reverted",
  "data": "0x4e487b710000000000000000000000000000000000000000000000000000000000000012"
}

Update:

Running buyEggs from within Polygonscan:

Original Contract (Success) : https://polygonscan.com/tx/0x9965ab550f47aa4de294cc489ee06fe8638ed35af64edd19e6dfc7ded5efd804

My Contract copy (Fail) : https://polygonscan.com/tx/0x2bde1de9913ab1cb4fe30872221dafc838128a38b8dc4ad8f03969fa6893c993

What's the difference? The contracts are the same, why does mine fail? Also on mine it fails to estimate gas fee, so I have to set it manually

2

There are 2 best solutions below

2
On

You can't send MATIC to the contract because it doesn't have a receive function.

1
On

The solution was as simple as clicking the seedMarket in Remix, then it all initialized and started working.