Hello there, I am new to Polygon/Solidity development so forgive me if this is the wrong forum to post on (please direct me to the correct one if so) but I’m having issues communicating with my smart contract.
When I call the contract I keep getting this error but I don’t have a clue where to look. I’ve been finicking around with the gas prices and gas limits and I’ve gotten some simple contract calls to go through in the past.
I’m getting the following error when trying to call my smart contract (I’m using Brownie to facility the web3 RPC calls):
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/initiate_contract.py", line 17, in main
MyContract.at(contract_address).myFunction({'from':deploy_account,'gas':"20000000 wei"})
File "brownie/network/contract.py", line 1864, in __call__
return self.transact(*args)
File "brownie/network/contract.py", line 1737, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 660, in transfer
receipt, exc = self._make_transaction(
File "brownie/network/account.py", line 783, in _make_transaction
exc = VirtualMachineError(e)
File "brownie/exceptions.py", line 93, in __init__
raise ValueError(str(exc)) from None
ValueError: Execution reverted during call: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, include `allow_revert:True` as a transaction parameter.
I’ve tried using dynamic gas pricing strategies, and setting the limits within the bounds of the previous block limit (all things that have worked on more simple functions like setting a greeting), but now that I am trying to call my smart contract that leverages the AAVE flash loan provider, the calls aren’t going through, saying “the transaction will likely revert.”
The script I am using to call this contract is this:
import os
from dotenv import load_dotenv
from brownie import Wei, accounts, MasterArbitrage
from brownie.network.gas.strategies import ExponentialScalingStrategy
from brownie.network import gas_price
load_dotenv()
def main():
deploy_account = accounts.add(os.environ['PRIVATE_KEY'])
# TODO: Hit a gas API and make the scaling dynamic
gas_strategy = ExponentialScalingStrategy("20000000 wei", "50000000 wei")
gas_price(gas_strategy)
MyContract.at(contract_address).myFunction({'from':deploy_account,'gas':"20000000 wei"})
My solidity contract:
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
import "./FlashLoan.sol";
contract MasterArbitrage {
address private contractOwner;
FlashLoan private flashLoan;
string someValue;
constructor (address _flashLoanProvider) public payable {
flashLoan = new FlashLoan(_flashLoanProvider);
contractOwner = msg.sender;
}
function doFlashloan() public {
require(msg.sender == contractOwner);
address receiver = address(this);
address[] memory assets = new address[](1);
assets[0] = address(0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747);
uint256[] memory amounts = new uint256[](1);
amounts[0] = uint256(1 ether);
flashLoan.flashLoan(receiver, assets, amounts);
}
function setSomeValue(string memory _someValue) public {
someValue = _someValue;
}
function getSomeValue() public view returns (string memory) {
return someValue;
}
}
The ‘getSomeValue’ and ‘setSomeValue’ I was able to hit with the correct gas values. Is my other call reverting because of gas or is this Solidity’s way of telling me the contract has a runtime error?
I’m wondering how I can debug this further, and if anyone has an idea as to why this would be happening? Is the solidity code causing it to revert? How can I view what is happening?
Any help would be much appreciated.
Thanks!