A function declaration in Vyper looks like the following:
@external
def exampleFunction(name: String[64], age: uint256):
pass
This is a function named exampleFunction
that takes 2 parameters: a String[64]
(name
) and a uint256
(age
).
Note that we're specifying the function visibility as external using the function decorator @external
.
All functions must include one visibility decorator (@external
or @internal
). We will learn more about function visibility and decorators in the coming chapters.
You can define an empty function body using pass
keyword. When it is executed, nothing happens.
In our app, we're going to create some Pokemons. Let's create a function for that.
- Create an
external
function namedcreatePokemon
. It should take three parameter:
name
(aString[32]
)dna
(auint256
)HP
(auint256
)
- Use the
pass
keyword to define an empty function body.