All Projects → iamdefinitelyahuman → brownie-token-tester

iamdefinitelyahuman / brownie-token-tester

Licence: MIT License
Helper objects for generating ERC20s while testing a Brownie project.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to brownie-token-tester

ape
The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
Stars: ✭ 339 (+1256%)
Mutual labels:  vyper, brownie
nftoken
A non-fungible implementation of the ERC20 standard, allowing scalable NFT transfers with fixed gas costs.
Stars: ✭ 59 (+136%)
Mutual labels:  brownie
brownie simple storage
No description or website provided.
Stars: ✭ 22 (-12%)
Mutual labels:  brownie
ape-safe
gnosis safe tx builder
Stars: ✭ 211 (+744%)
Mutual labels:  brownie
SublimeEthereum
Ethereum Solidity, Vyper, Yul and StarkNet Cairo language syntaxes
Stars: ✭ 102 (+308%)
Mutual labels:  vyper
ens.py
Ethereum Name Service, made easy in Python
Stars: ✭ 36 (+44%)
Mutual labels:  web3py
universalmutator
Regexp based tool for mutating generic source code across numerous languages
Stars: ✭ 105 (+320%)
Mutual labels:  vyper
v1-contracts
🐍Uniswap V1 smart contracts
Stars: ✭ 430 (+1620%)
Mutual labels:  vyper
vyper
Python configuration with (more) fangs
Stars: ✭ 121 (+384%)
Mutual labels:  vyper
react-mix
Everything you need to use React with Brownie!
Stars: ✭ 58 (+132%)
Mutual labels:  brownie
eth-event
Tools for Ethereum event decoding and topic generation.
Stars: ✭ 54 (+116%)
Mutual labels:  web3py
ethtoken.py
Ethereum ERC20 Token Interface, in Python
Stars: ✭ 40 (+60%)
Mutual labels:  web3py
chainlink-mix
Working with smart contracts with eth-brownie, python, and Chainlink.
Stars: ✭ 447 (+1688%)
Mutual labels:  brownie
resources
A living collection of resources for participants (and anyone who's interested) in Truffle University's courses 📚
Stars: ✭ 27 (+8%)
Mutual labels:  vyper
pancakeswap-lottery
🥞 A Python client for accessing PancakeSwap Lottery smart contract information through Web3.py
Stars: ✭ 30 (+20%)
Mutual labels:  web3py
Remix Ide
Documentation for Remix IDE
Stars: ✭ 1,768 (+6972%)
Mutual labels:  vyper
Vyper
Pythonic Smart Contract Language for the EVM
Stars: ✭ 3,460 (+13740%)
Mutual labels:  vyper

brownie-token-tester

Helper objects for generating ERC20s while testing a Brownie project.

Dependencies

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 success kwarg is used to set the token's return value upon a successful call to approve, transfer or transferFrom. Valid values are True, False, and None.
  • The fail kwarg sets the token's behaviour upon failed calls to the above methods. Use "revert" if the transaction should revert, or True, False, and None to 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].