brownie-token-tester
Helper objects for generating ERC20s while testing a Brownie project.
Dependencies
- python3 version 3.6 or greater, python3-dev
- brownie version 1.11.6 or greater
- ganache-cli version 6.11.0 or greater
Installation
via pipx
If you have installed Brownie using pipx, you need to add brownie-token-tester into the same virtual environment:
pipx inject eth-brownie brownie-token-tester
via pip
You can install the latest release via pip:
pip install brownie-token-tester
via setuptools
You can clone the repository and use setuptools for the most up-to-date version:
git clone https://github.com/iamdefinitelyahuman/brownie-token-tester.git
cd brownie-token-tester
python3 setup.py install
Quick Usage
Import the library from within a Brownie test, script or console:
from brownie_tokens import ERC20, MintableForkToken
You can then make use of the following functionality:
ERC20
Deploys a generic ERC20 contract for testing purposes.
def ERC20(
name: str = "Test Token",
symbol: str = "TST",
decimals: int = 18,
success: Union[bool, None] = True,
fail: Union[bool, str, None] = "revert",
) -> Contract:
- The
successkwarg is used to set the token's return value upon a successful call toapprove,transferortransferFrom. Valid values areTrue,False, andNone. - The
failkwarg sets the token's behaviour upon failed calls to the above methods. Use"revert"if the transaction should revert, orTrue,False, andNoneto return a value without reverting.
The resulting deployment adheres to the ERC20 Token Standard and additionally implements one non-standard method:
def _mint_for_testing(target: address, amount: uint256): nonpayable
This method increases the balance of target by amount. It may be called by any account.
MintableForkToken
MintableForkToken is used to standardize the process of minting tokens when working in a forked mainnet environment. The MintableForkToken class inherits from and may be used interchangeably with the Contract class. It exposes one additional method, _mint_for_testing, with the same API as given above.
For tokens where custom logic is implemented, this is an actual minting event. For most tokens, the "minting" process involves a query to the Ethplorer API to get a list of top token holders, and then transferring their balances to target. If you want to exclude some holders from this process use skip_holders(*addresses). If you have too many requests at a time set $ETHPLORER_API_KEY(see ethplorer.io) as environment variable.
Tokens for which custom logic is currently implemented:
- Aave tokens
- DAI
- EURS
- LinkUSD
- pBTC
- Synthetix synths
- renBTC
- renZEC
- rETH
- RSV
- USDC
- USDN
- USDT
- tBTC
- wBTC
- wZEC
Development
This project is still in early development and should be considered an alpha. Comments, questions, criticisms and pull requests are welcomed.
License
This project is licensed under the MIT license.
Metadata
Release files for brownie-token-tester 0.3.2
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 | |
|---|---|---|---|---|
| brownie-token-tester-0.3.2.tar.gz | 9.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| brownie_token_tester-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.3 kB
Release files / brownie-token-tester-0.3.2.tar.gz
| Download URL | brownie-token-tester-0.3.2.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3a131293f2ac2c230707c6d0f18e930eebdd27f05a40c05f230db7c2039bf0b
|
|
BLAKE2b-256 checksum How to use checksums |
ce7256557351f76a620bf118b8dccaa68c63e79055bdf6d72bb19ce4507bfbdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
|
Release files / brownie_token_tester-0.3.2-py3-none-any.whl
| Download URL | brownie_token_tester-0.3.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d741630c3561f4cdb60c6e779fc7f4888b0106841958b6aa2525c122f774bf8b
|
|
BLAKE2b-256 checksum How to use checksums |
97d82de2104e9a3d6eee300dca89213d87bbcb39bee995191e99909d5252035f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
|
Security for brownie-token-tester 0.3.2
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.