Here is an example;
Note that ETH is not a contract so there is no balanceOf() method to be called.
This is how it's done.
uint balance = address(this).balance;
address(this) is your contract address.
This is done inside you contract with solidity so the balance will be available inside your contract.
You can also get it from the cli
Check out these methods....
Truffle and Ganache generates different seed phrases.
In order to have the same addresses from truffle develop into ganache gui, you need to copy and paste the seed phrase com truffle develop and paste it into the ganache accounts tab, when creating a new workspace
Check your compiled contract abi JSON representation.
Most probably getAgentDetails() is missing in the abi.
Remove any default network in your environment and set the test net address properly and compile again.
It should work.
Iv run into similar issues.
In your truffle configuration file, make sure you enable optimization i. The compiler settings. Setting to 200 is fine. Essentially the fact that the contract code isn't optimized, you end up running out of gas
Hope this helps,
Ganache UI under Windows is not the same as Ganache-cli under WSL
The Ganache UI on Windows is listening to Windows Port.
The WSL2 instance have it's own set of ports.
So Even if they are set to the same port they are not
What you should do is use Ganache-cli in WSL2.
This will fix your issue. Since they will both be on the same system.
okay. I found the solution. I can add a local network in my network list with :
brownie networks add Ethereum ganache-local host=http://127.0.0.1:7545 chainid=5777
where ganache-local is a name i choose and where host + chainid is from the running Ganache-desktop version.
After running that command you can see a Success message:
SUCCESS: A new network '...
You are able to use Blockscout as a block explorer for ganache-cli.
To do a local trial run I recommend using Blockscout via Docker:
Start a local chain via ganache-cli
Clone Blockscout and change to docker
Run (assuming you are on macOS)
I figured out the answer to this error. Turns out I was deploying using a specific MockV3Aggregator Address and then I had another script to interact with the contract, but used a different MockV3Aggregator address, hence giving me that error. Specifically in my deploy.py function,
account = get_account()
# pass the price feed address to our fundme ...