Along the Beam

What if your life is rushing, moving along the way it was meant to be but you’ve only stood still in the stream, never flowing, not looking along the beam? The strain and flow of your life’s light is…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Why VyperLang?

The alternative Eth-lingo

VyperLang is known as the alternative Ethereum smart contract language and is by far the second most popular language for building smart contracts on the Ethereum network.

It is a statically typed, contract-oriented programming language, that targets the Ethereum Virtual Machine(EVM) and was built to resemble python.

With big tech companies like UniswapV1, CurveFi, and many more preferring to use it over Solidity for smart contracts.

Vyper promises a unique set of features. Such features include:

A consensus done in November 30th 2021 by DefiLlama, shows that at an All-Time High Solidity had secured over $186.57B of value locked in smart contracts which was up to 85% of the total value locked in smart contracts at the time, but behind solidity was Vyper with a total of $27.02B which made up 10%.

This is evidence that although VyperLang remains a sort of underground smart contract programming language, there are tech companies that are actively building with it and using its secured contracts for their daily transactional operations.

Although it’s highly regarded as the second most popular language on the Ethereum blockchain, it’s developers have announced in the past that it wasn’t built to compete with the more dominant Solidity.

This can be backed by the fact that although Vyper was made to improve smart contract creation in its own way, so it forbids the use of a few things, unfortunately some of those things make Solidity a great contract-oriented language.

Such as:

The onlyOwner modifier in solidity can be used to restrict user access to the function sendEth(), this way only the user (msg.sender) defined as owner can call the function.

Vyper is statically typed, like most object-oriented machine language, and with a little knowledge on Solidity and Python you can pick it up and be good at it in as little as a year of constant building.

There are tons of great resources to get you properly started listed at the end of this article, feel free to check them out and start your journey.

An example contract:

This is a minimalist Vyper smart contract that returns the greeter “Hello World” when you call the greet function.

Vyper supports a version pragma to ensure that a contract is only compiled to the expected version, or expected defined versions.

The HelloWorld.vy contract above is currently running on version 2.0.

Below the version statement is a note written with the hashtag ‘#’, which is the equivalent of the inline comment or slanted strokes used in Solidity ‘//’ to leave a comment or a note, either for detailing a function or explaining variables. Basically writing code you want to be ignored by the compiler.

State variables are values that are permanently stored in the contract. They are declared outside of any function like in Solidity and usually contain the default value for their type.

The string greet is a state variable with a visibility set to public, and declared to hold a maximum of 100 characters, although in this case only 10 of that available space is used.

This is an excellent example of ‘The Bounds Overflow Checking’ as the variable ‘greet’ will never be able to go over its intended bounds.

The state variables can then be accessed using the object self.

Lastly, Functions are executable units of code within a contract. This is nothing new as it holds for every object-oriented language.

In Vyper, Functions are assigned with @ external or @ internal according to their visibility and accessibility.

In Solidity the visibility of functions are more diverse, ranging from

In Vyper there are only two types of visibility for functions;

These functions can also accept arguments, and return variables in order to pass value within them.

The example contract above takes the visibility of external, so it can also be called from outside of the contract.

You can practice calling out the function from the Remix IDE, which is a very powerful and rapidly growing online code editor for smart contracts on the Ethereum blockchain.

The best way to install Vyper on your local code editor is to follow the guidelines from the official docs here.

These are some amazing documentations sites and repositories that will help you understand what its like to build smart contracts in Vyper and how to build them the right way with examples.

Add a comment

Related posts:

CPU football teams at the CERES Cup 2017

Three football teams from Central Philippine University joined in the 4th Ceres Cup in Negros Occidental on May 20 to 21. One of the CPU teams was composed of female Nursing and CBA students, and two…

The Habit of Good Moods

One of the things I am trying to conquer are bad moods. I keep remembering a story I heard years ago about the Buddha. He was lecturing to his students and whoever else wandered by and a heckler…

How to Methods

A design method is a repeatable way of doing things that can be further broken down into processes. All design methods include some version of research, ideation, prototyping, iteration, and…