Vyper is a contract-oriented, pythonic programming language that targets the Ethereum Virtual Machine (EVM) <https://ethereum.org/learn/#ethereum-basics>
_.
Because of this Vyper provides the following features:
Following the principles and goals, Vyper does not provide the following features:
function foo() mod1 { ... }
, where mod1
can be defined elsewhere in the code to include a check that is done before execution, a check that is done after execution, some state changes, or possibly other things. Vyper does not have this, because it makes it too easy to write misleading code. mod1
just looks too innocuous for something that could add arbitrary pre-conditions, post-conditions or state changes. Also, it encourages people to write code where the execution jumps around the file, harming auditability. The usual use case for a modifier is something that performs a single check before execution of a program; our recommendation is to simply inline these checks as asserts.X
is the one that’s actually used?”). Hence, it makes code too complicated to understand which negatively impacts auditability.foo("hello")
logs “hello” but foo("hello", "world")
steals your funds). Another problem with function overloading is that it makes the code much harder to search through as you have to keep track on which call refers to which function.+
could be overloaded so that it executes commands that are not visible at a first glance, such as sending funds the user did not want to send.10
= (0.001100110011…)\ :sub:2
, which needs to be truncated), leading to unintuitive results, e.g. in Python 0.3 + 0.3 + 0.3 + 0.1 != 1.Vyper does not strive to be a 100% replacement for everything that can be done in Solidity; it will deliberately forbid things or make things harder if it deems fit to do so for the goal of increasing security.
Take a deep breath, follow the instructions, and please
create an issue <https://github.com/vyperlang/vyper/issues>
_ if you encounter
any errors.
The easiest way to experiment with the language is to use the `Remix online compiler <https://remix.ethereum.org>`_.
Vyper can be downloaded as docker image from dockerhub:
docker pull vyperlang/vyper
To run the compiler use the docker run
command:
docker run -v $(pwd):/code vyperlang/vyper /code/<contract_file.vy>
Alternatively you can log into the docker image and execute vyper on the prompt.
docker run -v $(pwd):/code/ -it --entrypoint /bin/bash vyperlang/vyper
root@d35252d1fb1b:/code# vyper <contract_file.vy>
The normal paramaters are also supported, for example:
docker run -v $(pwd):/code vyperlang/vyper -f abi /code/<contract_file.vy>
[{'name': 'test1', 'outputs': [], 'inputs': [{'type': 'uint256', 'name': 'a'}, {'type': 'bytes', 'name': 'b'}], 'constant': False, 'payable': False, 'type': 'function', 'gas': 441}, {'name': 'test2', 'outputs': [], 'inputs': [{'type': 'uint256', 'name': 'a'}], 'constant': False, 'payable': False, 'type': 'function', 'gas': 316}]
If you would like to know how to install Docker, please follow their
documentation <https://docs.docker.com/get-docker/>
_.
Vyper can only be built using Python 3.6 and higher. If you need to know how to install the correct version of python,
follow the instructions from the official Python website <https://wiki.python.org/moin/BeginnersGuide/Download>
_.
It is strongly recommended to install Vyper in a virtual Python
environment, so that new packages installed and dependencies built are
strictly contained in your Vyper project and will not alter or affect your
other development environment set-up.
For easy virtualenv management, we recommend either pyenv <https://github.com/pyenv/pyenv>
_
or Poetry <https://github.com/python-poetry/poetry>
_.
To find out more about virtual environments, check out:
`virtualenv guide <https://docs.python.org/3/library/venv.html>`_.
Each tagged version of vyper is uploaded to pypi <https://pypi.org/project/vyper/>
_, and can be installed using pip
:
pip install vyper
To install a specific version use:
pip install vyper==0.1.0b17
Read more docs: https://vyper.readthedocs.io/en/stable/vyper-by-example.html
#vyper #python #blockchain