Skip to content
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

Add an ERC20 balance check example to the docs #951

Closed
carver opened this issue Jul 9, 2018 · 2 comments · Fixed by #995
Closed

Add an ERC20 balance check example to the docs #951

carver opened this issue Jul 9, 2018 · 2 comments · Fixed by #995

Comments

@carver
Copy link
Collaborator

carver commented Jul 9, 2018

What was wrong?

ERC20 is one of the most common use cases, and there are no explicit examples for interacting with them.

How can it be fixed?

Add a section to the Examples section of the docs that shows how to check the balance of a given token. The new section can be added at the end of this source: https://github.com/ethereum/web3.py/blob/master/docs/examples.rst

This section should show someone how to check their Unicorn token balance.

Rough approach:

  1. Show how to create a python contract object bound to the ERC20 Unicorn token (you can use the ABI from ethtoken linked below)
  2. Retrieve the token balance for an address 0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb appears to be the first address to have received a unicorn, so could be a good candidate.
  3. Show how to retrieve the decimals(), and how to adjust the token balance to get the token count: dividing by 10^decimals plus a brief explainer of the difference between the token balance and token count (token balance is always an integer, token count may be a fraction)

This repository has some example code that might be helpful if you're not sure how to connect to an ERC20 token: https://github.com/carver/ethtoken.py (You can footnote the repo if you want, but it's best to copy in anything that the reader might need).

ERC20 probably deserves its own whole page with different use case examples, but that is out of scope.

@carver
Copy link
Collaborator Author

carver commented Jul 9, 2018

@Karla-Isabel-Sandoval here is an idea for something that would help improve our docs.

@pipermerriam
Copy link
Member

cc @njgheorghita as there should eventually be examples of how to do this with the ethpm tooling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants