I have a contract function that I cannot call from the front-end using ethers.js
for some reason. I cannot even debug this call because it doesnt produce any errors. I tried to break the call by changing gas price or passed arguments, then I get errors. When I get no errors, metamask doesnt popup to ask for confirmation as i'm 100% sure there is gas price for this transaction.
Here is how i call the function:
const provider = new ethers.providers.JsonRpcProvider("https://rpc-...", 80001); ///rpc url
const signer = new ethers.Wallet("0x....", provider); ///private key
const administrativeSidechainContract = new ethers.Contract(ContractAddress, abi, signer)
async function updateUI() {
//const gasPrice = await provider.getGasPrice() //gets the gas price but doesnt fire transaction
const addingAllWinnings = await administrativeSidechainContract.addAllPotentialWinnings(
props.eventNumber,
props.winningsList,
props.loopedOverChainsList,
props.winnersList
, { gasPrice: ethers.utils.parseUnits('100', 'gwei'), gasLimit: ethers.utils.parseUnits('10000000', 'wei') })
}
updateUI()
I have written all the unit tests with hardhat
+ ethers.js
and they all pass.
Here is the contract function:
function addAllPotentialWinnings(
uint256 _eventNumber,
uint256[][] memory _potentialWinnings,
uint256[] memory _chainsList,
address[] memory _winnersList
) public onlyOwner {
winnersList[_eventNumber] = _winnersList;
updateChains(_eventNumber, _chainsList);
for (uint i = 0; i < _winnersList.length; i++) {
updatePotentialWinnings(
_eventNumber,
_winnersList[i],
_potentialWinnings[i]);}}
Please note that i cannot call all the other functions that are state-changing due to the similar reasons. However all the view
functions work just fine.
What am I missing about calling state changing functions with ethers.js
?