web3-constant
Install
pip install web3-constant
Connect to Web3
from web3 import Web3
from web3constant.Fantom.Url import FTM_RPC
w3 = Web3(Web3.HTTPProvider(FTM_RPC))
if w3.isConnected():
print("Web3 is connected.")
Listen to a topic
from web3 import Web3
from web3constant.Fantom.Url import FTM_RPC
from web3constant.topics import PAIR_SYNC
w3 = Web3(Web3.HTTPProvider(FTM_RPC))
prev_block_num = w3.eth.get_block_number()
while(True):
current_block = w3.eth.get_block_number()
if (prev_block_num == current_block):
continue
topic_d = {
'fromBlock': prev_block_num,
'topics': [PAIR_SYNC]
}
logs = w3.eth.get_logs(topic_d)
for l in logs:
print(l)
Create contract
from web3 import Web3
from web3constant.Fantom.Url import FTM_RPC
from web3constant.Fantom.Dex import SPOOKY_SWAP_FACTORY_ADDRESS
from web3constant.abi.UniswapV2 import SPOOKY_SWAP_FACTORY_ABI, UNISWAP_V2_PAIR_ABI
w3 = Web3(Web3.HTTPProvider(FTM_RPC))
# create factory contract
spooky_swap_factory_contract = w3.eth.contract(
address=SPOOKY_SWAP_FACTORY_ADDRESS, abi=SPOOKY_SWAP_FACTORY_ABI
)
# get pair address for factory contract
pair_address = spooky_swap_factory_contract.functions.allPairs(0).call()
print("pair contract address:", pair_address)
# create pair contract
pair_contract = w3.eth.contract(address=pair_address, abi=UNISWAP_V2_PAIR_ABI)
# get token0, token1
token0 = pair_contract.functions.token0().call()
token1 = pair_contract.functions.token1().call()
# get reserves
r0, r1, timestamp = pair_contract.functions.getReserves().call()
# print
print("token0:", token0)
print("token0 reserves:", r0)
print("token1:", token1)
print("token1 reserves:", r1)
print("sync timestamp:", timestamp)
Metadata
Release files for web3-constant 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| web3-constant-0.0.6.tar.gz | 4.5 kB | Without provenance | Details for web3-constant-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| web3_constant-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for web3_constant-0.0.6-py3-none-any.whl |
Total release size: 10.3 kB
Release files / web3-constant-0.0.6.tar.gz
| Download URL | web3-constant-0.0.6.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63c4d78c2f399711a23c01d9dfc1f81706e2d4db9851bed1fe45a883bf597f95
|
|
BLAKE2b-256 checksum How to use checksums |
5e782c8dbc2dc63c97d81c208ef66613b6cc746adf7e4f93c40930b6473cd8cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.10
|
Release files / web3_constant-0.0.6-py3-none-any.whl
| Download URL | web3_constant-0.0.6-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3820273585eb26c6187b72e85e1018b74b4e735cd003ed01bc5139bad571275b
|
|
BLAKE2b-256 checksum How to use checksums |
3ab18cbdc812b89e569e558b262480e896ffcd8216296841c8d49e0b46468830
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.10
|
Security for web3-constant 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.