When implementing smart contracts, I’ve used Solidity and OpenZeppelin.
I knew about Vyper, so I wanted to use it someday.
And now is the time.
- Python3.6 and higher
Before installing Brownie, we need ganache-cli or we should face an error when running test.
npm i -g ganache-cli
Then, install it with pipx.
python3 -m pip install pipx
After that, you should see that some directories such as contracts/, tests/ are created in the sample/ directory.
Next, we need to prepare a Python virtual environment in sample directory to install Vyper.
# in sample/
Make sure you are in a virtual environment, then do the following:
pip install vyper
Create a new file named SampleToken.vy in contracts/ directory.
Then implement a smart contract while referring to the Vyper ERC20 example.
# @version ^0.3.0
Create a new file named test_sampletoken.py in tests/ directory.
The filename prefix/postfix must be “test_*.py” or “*_test.py”.
In addition, please note that this is a .py file, not .vy.
Finally, you can test it.
If there are no errors, this ERC20 token is fine. Maybe.