-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account balance access problems with Moccasin and Web3 #201
Comments
Hey @scwall! Thanks for your message and the appreciation on Patrick's and Cyfrin's work! Regarding your issue, from my understanding, Moccasin is using Titanoboa under the hood. And asking for the balance of your account depends on the token you will request. If you are asking for ETH, Titanoboa has built in method under their env namespace Doc ref (wip) import boa
account_eth_balance = boa.env.get_balance(mox_account.address)
# You can also use boa.env.eoa if you want to run some test and also use it prank too The Titanoboa doc is still under in its building phase, so some functionalities are not in the doc. But they do exist if we check their code base If you are asking for a specific token balance, other than ETH, then you'll have to ask for their proper method to get the balance. I think it is
If you want to check: Youtube, or directly on CyfrinUpdraft platform. And the GitHub repo. Hope my solution is adapted to your issue 👼 |
I was gonna write this long comment out, and then I just said F it and added it. Good feature request. (I also fixed some issues with the zksync tests. I musta skipped running them before... oops) |
Hello, Super thanks for your answers :) Have a nice evening |
Hello,
First of all, thank you for your work! I’ve learned a lot from your online courses and the various products you provide. I really appreciate the quality of your content.
I have a question regarding Moccasin, specifically about how it handles account data. In the documentation ([link to Moccasin docs](https://cyfrin.github.io/moccasin/core_concepts/networks/forked_networks.html)), it is mentioned that Moccasin uses lazy loading, meaning it only fetches blockchain data when needed.
For example, if I want to get the balance of an account, Moccasin should only download that specific balance when my script requests it. However, I couldn't find any built-in function like
account.get_balance()
that allows me to do this directly.Instead, I have to retrieve the information manually using Web3, which confuses me. Am I missing something, or is this the expected behavior? Is there a recommended way to handle account interactions more efficiently within Moccasin?
Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: