I have deployed a smart contract to the Polygon Mumbai Testnet (it shouldn't really matter where I deployed it).
When sending a transaction to call a function on this contract, the transaction fails, and after looking through the instructions trace, it seems a REVERT opcode was triggered.
There are no requires, asserts or anything in my code that would make me believe that a revert opcode would occur.
The only possibility I could think of is some error such as running out of stack space (if that's even a thing), although I would have presumed any such errors would be picked up at compile-time.
How do I fix this?
Here is my code:
pragma solidity ^0.8.0;
contract Predictions {
mapping (address => PredictionCollection) predictions;
struct PredictionCollection {
Prediction[] predictions;
uint length;
}
struct Prediction {
bytes32[8] text;
}
struct PredictionInfo {
bytes32[8] text;
}
function open(PredictionInfo calldata prediction) public returns (uint) {
uint id = predictions[msg.sender].length;
predictions[msg.sender].predictions[id] = Prediction({
text: prediction.text
});
return id;
}
}
Here is a link to the deployed contract.
Here is the code for my failed transaction (using web3js), in case this helps determine why my transaction has failed:
async function submitTransaction() {
let text = [];
for (let i = 0; i < 8; i++) {
text.push(web3.utils.asciiToHex("Hello, World! :)\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"));
}
await predictionsContract.methods.open({
text,
}).send({
from: wallet,
});
}
Here is a link to the mined transaction which includes the relevant input data.
Edit: This is the raw input data:
0x82715e9948656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a290000000000000000000000000000000048656c6c6f2c20576f726c6421203a2900000000000000000000000000000000