Giter VIP home page Giter VIP logo

web3querycontractpython's Introduction

Web3QueryContractPython

Example of how to dynamically query read/write functions for a given Smart Contract using just the contract address (no ABI necessary) using Web3 in Python. Will dynamically retrieve the contract's ABI through etherscan's API.

  1. Create Python virtual environment (optional)
    python -m venv venv
    source venv/bin/activate

  2. Install web3.py
    pip install web3

  3. Add your Ethereum endpoint URL using Infura or equivalent
    This is required to query the Ethereum blockchain
    infura_url = "https://mainnet.infura.io/v3/00000000000000000000000"

  4. Add the address of the Smart Contract you want to query
    You can get this from etherscan.io
    address = web3.toChecksumAddress("0x00000000000000000000000")

  5. run web3QueryContract.py
    python3 web3QueryContract.py

Output should be similar to this:

READ CONTRACT FUNCTIONS:
contractURI: https://nft.syn.city/meta/SYNP/
maxTokenId: 888
name: Syn City Genesis Passes
nextTokenId: 409
owner: 0x41BDD852d3618Dc5D6338279F373Bf7935dc0242
symbol: SYNP
tokenURIHasBeenFrozen: False
validator: 0xc626be886d4b7D09898152c61959A9a898a78D6f

WRITE CONTRACT FUNCTIONS
approve
claimFreeToken
encodeForSignature
freezeBaseTokenURI
giveawayToken
renounceOwnership
revokeOperator
safeTransferFrom
safeTransferFrom
setApprovalForAll
setOperators
setValidator
transferFrom
transferOwnership
updateBaseTokenURI

There are also some examples of how to call individual functions directly using Web3's call() function (commented out by default).

Questions?
[email protected]

web3querycontractpython's People

Contributors

benwhut 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.