Odak modu

NEAR Developer Course

Example: Guest Book

Example: Guest Book

Let's explore the successful NEAR project Guestbook together! See below the elements of the project.

There are 2 main folders in the project:

  • assembly contains the smart contract and tests
  • src contains the application’s UX and tests

There is another folder to be aware of:

  • neardev contains contract account details

Note: We will not focus on the “src folder” which is the frontend of this dApp.

figures figures figures

Contract Data Model: assembly/model.ts

figures

PostedMessage is a serializable class with three attributes: 

  • premium to flag messages with attached NEAR tokens
  • sender to track the signer of the guest book message
  • text to hold the guest book message

Messages is a collection of guest book messages stored as a PersistentVector of PostedMessage objects.

Note: @nearBindgen marks the class as serializable.


Contract Behavior: assembly/main.ts

figures


MESSAGE_LIMIT is used to avoid unbounded calls (ie. potentially expensive) to retrieve guest book messages from storage.

Two public functions are exposed on the contract: 

  • addMessage()
  • getMessages()
Background Pattern
Birlikte öğrenelim

Sektörde en çok aranan yazılım becerilerini kazan

Yapay zeka desteği, birebir mentörlük saatleri, canlı dersler ve senin için özel hazırlanmış içeriklerle eksiklerini tamamla, düzenli geri bildirimler al ve öğrenme sürecini en verimli hale getir.

Yunus Emre Kabakcı

Patika+ mezunu

Patika+ Fullstack Web Development Bootcamp mezunumuz Yunus Emre,

3 ay içinde Katar’dan aldığı teklif ile, global bir şirket olan Pavo Group’da işe başladı!


“İçerik zenginliği, mentor desteği, ileriye dönük bir network sağlaması ve dünyada en çok tercih edilen frameworkler üzerinden bir eğitim veriyor olması Patika+’ı tercih etmemin temel sebepleri oldu!“

Yorumlar

Yorum yapabilmek için derse kayıt olmalısın!