GithubHelp home page GithubHelp logo

toythereum's Introduction

Toythereum

A simple python implementation useful for checking a crypto wallet's ether balance on the mainnet. This tutorial leverages the Web3.py library.

Getting Started

Ensure your development environment is running Python3. For best results I recommend running a python virtual machine (see instructions below).

Step 1: Clone this repo

Clone the toythereum git repo:

# for https:
git clone https://github.com/anthonyrka/toythereum.git
cd toythereum

Step 2: Setup Virtual Environment & Install dependencies

Set up your virtual environment:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements

Step 3: Access the Ethereum mainnet

There are many ways to access the Ethereum mainnet. One way would be to install geth to run as a local ethereum node on your local development machine. However, if you choose this option you should consider the time it will take to download the full blockchain, not to mention the IO, disk space and bandwidth requirements. See https://geth.ethereum.org/docs/install-and-build/installing-geth.

This tutorial wastes no time and leverages an API provider called Infura.io. Visit infura.io to setup a free account. Once signed up (it currently takes 30 seconds), Infura will provide you Endpoints and a ProjectID.

Once you have your PROJECTID and ENDPOINT, set these as local environment variables:

export INFURA_PROJECT_ID=<YOUR-PROJECT-ID>
export INFURA_MAINNET_URI=https://mainnet.infura.io/v3

โ†‘ be sure not to add the trailing / to this URL

Note: at the time of this writing, the Infura mainnet can be accessed over HTTP with the above URI. However, you'll want to double-check this is what is provided in your project's account.

Step 4: Check your wallet's balance of Ether

export CRYPTO_WALLET=0x7829e7bDc86dEc3f00403f7E6b58aa8d42d86cF7
python get_address_balance.py $INFURA_PROJECT_ID $CRYPTO_WALLET $INFURA_MAINNET_URI

Crypto Address: 0x7829e7bDc86dEc3f00403f7E6b58aa8d42d86cF7
Balance: 0.01179221 ether

Common Issues

If you expect to find a balance in your wallet and you find a 0 result. There are at least 2 issues to consider:

  1. If your wallet is on an exchange such as Coinbase, you will likely not find it on the blockchain. Validate this by searching for your wallet on etherscan.io.
  2. If you have decided to implement your own geth client locally, the local client is likely still syncing the blockchain. This will take a significant amount of time (maybe multiple days). An informative read.

Future

Creating a wallet:

https://ethereum.stackexchange.com/questions/32940/how-can-i-generate-a-wallet-in-python/33123

toythereum's People

Contributors

anthonyrka avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.