Wrapper and Web3 class to interact with and create Anvil chains
Project description
anvil-web3
Easily interact with and create anvil chains from python
Install
anvil-web3
assumes anvil is already installed, click here if you don't have anvil installed
python3 -m pip install anvil-web3
Usage
This example shows how to programatically create an Anvil chain and how to inject the anvil rpc methods to a
web3.py Web3
object:
from web3 import Web3, HTTPProvider
from anvil_web3 import anvil, AnvilWeb3, AnvilInstance
# create an anvil chain
instance = AnvilInstance(
chain_id=42
)
# use the injection function
w3 = Web3(HTTPProvider(instance.http_url))
anvil(w3)
# or contruct a Web3 object from the AnvilWeb3 class (recommended for better autocompletion support)
w3 = AnvilWeb3(HTTPProvider(instance.http_url))
test_account = w3.eth.account.from_key(w3.keccak(text="42"))
# call an anvil method
w3.anvil.set_balance(test_account.address, 42424242)
assert w3.eth.get_balance(test_account.address) == 42424242 and w3.eth.chain_id == 42
instance.kill()
More complex demos in /examples
Tests
WIP
Current API Support
- anvil_impersonateAccount
- anvil_stopImpersonatingAccount
- anvil_autoImpersonateAccount
- anvil_getAutomine
- anvil_mine
- anvil_dropTransaction
- anvil_reset
- anvil_setRpcUrl
- anvil_setBalance
- anvil_setCode
- anvil_setNonce
- anvil_setStorageAt
- anvil_setCoinbase
- anvil_setLoggingEnabled
- anvil_setMinGasPrice
- anvil_setNextBlockBaseFeePerGas
- anvil_setChainId
- anvil_dumpState
- anvil_loadState
- anvil_nodeInfo
- evm_setAutomine
- evm_setIntervalMining
- evm_snapshot
- evm_revert
- evm_increaseTime
- evm_setNextBlockTimestamp
- anvil_setBlockTimestampInterval
- evm_setBlockGasLimit
- anvil_removeBlockTimestampInterval
- evm_mine
- anvil_enableTraces
- eth_sendUnsignedTransaction
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
anvil_web3-0.0.4.tar.gz
(9.4 kB
view details)
Built Distribution
File details
Details for the file anvil_web3-0.0.4.tar.gz
.
File metadata
- Download URL: anvil_web3-0.0.4.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b30039a4df183203778b0e50f2b661fe2ecb25ce944febec9f0947b34c5fbb31 |
|
MD5 | a576bf96e57387174693dc861c61967a |
|
BLAKE2b-256 | 37ddd6f341ff384b504aa3a8ed220f7272ff71055e9a5ca0724e92c9dfebb695 |
File details
Details for the file anvil_web3-0.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: anvil_web3-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33d495fec2ba8d6c9f09ebcc2d9ac0011a1a2bc541190e0747ed033934cdafe6 |
|
MD5 | 2e7399b38fe54ffdca5e6105b8a0ff65 |
|
BLAKE2b-256 | c415d5a5f11198f29437a6b198940b5e52a0046b3e8eda2f753bdc5f7f0b549c |