Skip to main content

Web3Py Extender Tools

Project description

Web3Tools

Web3Tools is an extender for the web3py library

Upload PyPi package

Setup your PyPi credentials on ~/.pypirc

[pypi]
  username = __token__
  password = pypi-token

Accordingly with the setuptools on setup.py generate a new package for a given project and version. Two files (tar.gz and whl) will be added to dist/

python setup.py sdist bdist_wheel

Upload the packages within dist/ to PyPi

pip install twine
twine upload dist/*

Usage

Basic Tools

from web3tools import Utils

Create an ethereum account

address, private_key = Utils.create()
keystore = Utils.encrypt(private_key, "myPassword")

Get address

private_key = Utils.decrypt("myKeystore", "myPassword")
address = Utils.get_address(private_key)

Sign a message & Recover signer's address

signature = Utils.sign_message("myPrivateKey", "myMessage")
address = Utils.recover_message(signature, "myMessage")

Ewt

from web3tools import Ewt
ewt = Ewt()

Ewt Authentication, similar to jwt but using the ethereum encryption keys

ewt_token = ewt.generate("myPrivateKey")
is_valid = ewt.validate(ewt_token)

Blockchain Reader

from web3tools import Reader
reader = Reader(Providers.INFURA_MAINNET.value.format("myInfuraKey"))

Crawl blockchain

current_block_number = reader.get_current_block_number()
current_block_info = reader.get_block(current_block_number)
transaction = reader.get_transaction("myTxid")
receipt = reader.get_receipt("myTxid")
gas_price = reader.get_gas_price()

Get Wallet Info

balance = reader.get_balance("myWallet")
nonce = reader.get_nonce("myWallet")

Read Contracts

contract = reader.get_contract_instance("abiFilePath", "contractAddress")
value = reader.call_view(contract, "viewName", "viewArguments")
events = reader.find_events(contract, "eventName", from_block=0, to_block="latest")
events_on_transaction = reader.find_event_receipt(contract, "eventName", "myTxid")

Launch Transactions

from web3tools import Providers, Transactor
transactor = Transactor(Providers.INFURA_MAINNET.value.format("myInfuraKey"))

Send 1 Eth to receiverAddress

transactor.launch_transaction("myPrivateKey", "receiverAddress", transactor.to_wei(1))

Call a transfer function of a token contract to send 1 Token to receiverAddress

contract = transactor.get_contract_instance("abiFilePath", "contractAddress")
transactor.launch_function(contract, "myPrivateKey", "transfer",
                           "receiverAddress", transactor.to_wei(1))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web3tools-0.1.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

web3tools-0.1.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file web3tools-0.1.2.tar.gz.

File metadata

  • Download URL: web3tools-0.1.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for web3tools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a3d51e522d0e527fa27451f63363f01f18fda18dc229786de533e701a800217c
MD5 473026e2778bc78d568bb2f10a32ee2e
BLAKE2b-256 8f75e56f964c747a6150a4b545bcba172ea904876a2f131e5fd0ee565c2579f4

See more details on using hashes here.

File details

Details for the file web3tools-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: web3tools-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for web3tools-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a02c182e031f4acbdbb21a0f78cb78beceb3b4a1cc25d50bbc011da56f060f80
MD5 634ffa2f87438a47b3b243d727381c8c
BLAKE2b-256 a519499353cde3b7d0490c3b71bac0d5aab7ab7aee9ac2433564d5a0fb497de0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page