Building Starknet Smart Contracts

In the previous section, we gave an introductory example of a smart contract written in Cairo, describing the basic blocks to build smart contracts on Starknet. In this section, we'll be taking a deeper look at all the components of a smart contract, step by step.

When we discussed interfaces, we specified the difference between the two types of public functions, i.e., external functions and view functions, and we mentioned how to interact with the storage of a contract.

Pada titik ini, seharusnya Anda memiliki beberapa pertanyaan yang muncul dalam pikiran:

  • Bagaimana cara menyimpan tipe data yang lebih kompleks?
  • Bagaimana cara saya mendefinisikan fungsi internal atau privat?
  • Bagaimana cara saya mengeluarkan peristiwa (events)? Bagaimana cara saya membuat indeks pada peristiwa tersebut?
  • Apakah ada cara untuk mengurangi boilerplate (kode yang sering diulang)?

Luckily, we'll be answering all these questions in this chapter.