Learn about reference data types available in Vyper

Learn about reference data types available in Vyper

Learn about reference data types available in Vyper. These are list, mappings and structs. #Vyper #DataTypes #ReferenceTypes #SmartContract Code: https://git...

Reference types do not fit into 32 bytes. Because of this, copying their value is not as feasible as with value types. Therefore only the location, i.e. the reference, of the data is passed.

Fixed-size Lists

Fixed-size lists hold a finite number of elements which belong to a specified type.

Lists can be declared with _name: _ValueType[_Integer]. Multidimensional lists are also possible.

# Defining a list
exampleList: int128[3]

# Setting values
exampleList = [10, 11, 12]
exampleList[2] = 42

# Returning a value
return exampleList[0]


Structs are custom defined types that can group several variables.

Struct types can be used inside mappings and arrays. Structs can contain arrays and other structs, but not mappings.

Struct members can be accessed via struct.argname.


Mappings are hash tables that are virtually initialized such that every possible key exists and is mapped to a value whose byte-representation is all zeros: a type’s default value.

The key data is not stored in a mapping, instead its keccak256 hash used to look up a value. For this reason mappings do not have a length or a concept of a key or value being “set”.

Mapping types are declared as HashMap[_KeyType, _ValueType].

KeyType can be any base or bytes type. Mappings, interfaces or structs are not support as key types. ValueType can actually be any type, including mappings.

# Defining a mapping
exampleMapping: HashMap[int128, decimal]

# Accessing a value
exampleMapping[0] = 10.1

Docs: https://vyper.readthedocs.io/en/stable/types.html#reference-types

vyper smartcontracts blockchain

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Blockchain Certification | Blockchain Training Course | Blockchain Council

In all the market sectors, Blockchain technology has contributed to the redesign. The improvements that were once impossible have been pushed forward. Blockchain is one of the leading innovations with the ability to influence the various sectors...

Certified Blockchain Expert™ | Blockchain Certification | Blockchain Council

A Certified Blockchain Expert is a professional who understands Blockchain technology profoundly and can build Blockchain-based applications for businesses. This blockchain certification aims to impart in-depth practical knowledge in Blockchain technology.

5 Blockchain Applications That Have Transformed the World of Technology

The blockchain is the decentralized database of the blocks of information, which gets recorded in the chain format and linked in a secured crypto graphical manner. This technology ensures proper safety of the data due to its secure nature, and it totally changes how people carry out transactions. It also brings about a faster and secure process of validating information needed to establish reliability.

Blockchain Certification | Blockchain Training Course | Blockchain Council

Training courses for blockchains have become very popular. The software is evolving to become part of the mainstream scheme. The growing need for a safe and secure system is one of the main reasons for this. It also contributed to one of the...

Certified Blockchain Expert™ | Blockchain Certification | Blockchain Council

The entire business has been revolutionised by Blockchain. A technology that once began as the underlying Bitcoin trading platform has now become a core technology that has changed the way companies function. The media and journalism field is no...