Vyper theorytheory 0/50 · 0%
Types · easy

3. Value types

bool, int128/uint256, address, bytes32, decimal and their ranges.

Vyper's core value types are `bool`, signed and unsigned integers (`int128`, `int256`, `uint8`...`uint256`), `address`, `bytes32`, and the fixed-point `decimal` type. There is no implicit widening between integer sizes — every conversion must go through `convert()`.

`decimal` gives you a fixed-point number with 10 digits after the point, useful for ratios without floating-point error, but it is not a substitute for careful unit handling.

is_active: public(bool)
supply: public(uint256)
rate: public(decimal)
admin: public(address)
root: public(bytes32)

Every arithmetic operation on integers reverts on overflow or underflow automatically — you never need a SafeMath-style library in Vyper.

Check your understanding

  1. 1. What happens on integer overflow in Vyper?

  2. 2. How do you convert between integer types in Vyper?

  3. 3. What is `decimal` used for?