Article cover

24.05.2022

3

Beğenme

7

Görüntülenme

How and for What Purpose I created My First NEAR Project

I attended a NEAR Protocol class from Patika.dev website. It’s completely free to attend the class and it’s English. Visit the link below to go to the course:


Patika - Teknoloji Kariyerine En Etkili Yol

Hayal ettiğin yazılım kariyerini yakalaman için ihtiyaç duyduğun her şey

app.patika.dev


(Patika also has courses that range from data science courses to game development courses that you can only access as an enrollment)


Let’s Get Started


Firstly, I want to explain the application superficially. My project is a new generation Web3 Decentralized Advertising Application. The main purpose of this project is giving a chance to everyone for sharing their ads with the people all around the world, and it also provides the other people to access other ads via the app.


Cloning the Project


Before we start, if you want to try my project by yourself, you need clone the project from project’s GitHub address (Also if you want and you liked the project, you can give star 😃 ⭐️). You can use the link below for cloning the project.


GitHub - keremOzerdem/NearAdvertising-New_Face_of_Advertising-Smart_Contract: The New Face Of…

A new generation web3 Advertising application. You can share your advertisings to the people all around the world. And…

github.com


After cloning the project, please run

yarn

in order to install all of the necessary packages for the project to run correctly.


Building and Deploying the Contract


The contract is located in under the assembly folder, after editing the contract you can run


yarn build:release

in order to build the contract and get the .wasm file , if you want to build and deploy the contract at the same time, you can run

yarn dev

This will create a test account and deploy the contract into it.

After the contract is deployed, it is necessary to run the following command in the terminal in order to be able to run the contract

export CONTRACT=ACCOUNT_ID

where the ACCOUNT_ID will be returned after the contract deployment.


Project Details


Now I want to explain the project with the details!


In this project, the functions that whose names are

  • healthCheck,
  • publishAdvertising,
  • bringAdvertising,
  • readAdvertising,
  • deleteAdvertising,
  • sendGratitude

were used. Probably you can feel the functions’ tasks based on their names, but I will explain these functions basically.


Functions

* healthCheck


  • Take req(string), rep(string) as parameters
  • returns a string

Example call:

near call $CONTRACT healthCheck '{"req":"$TYPE_ANYTHING", "rep":"$TYPE_ANYTHING"}' --accountId $NEAR_ACCOUNT


* publishAdvertising

  • Take text as a parameter
  • returns Advertising

Example call:

near call $CONTRACT publishAdvertising '{"text":"$TYPE_ANYTHING"}' --accountId $NEAR_ACCOUNT


* bringAdvertising

  • Take id(u32) as a parameter
  • return advertising

Example call:

near call $CONTRACT bringAdvertising '{"id":$TYPE_ADVERTISING_ID}' --accountId $NEAR_ACCOUNT


* readAdvertising

  • No parameter
  • return advertising array

Example call:

near call $CONTRACT readAdvertising --accountId $NEAR_ACCOUNT


* deleteAdvertising

  • Takes id as a parameter
  • Can call if you are the creator of this saying.
  • Returns string ${id} is successfully deleted or if it's not your saying ${id} is not your saying.Can not delete.

Example call:

near call $CONTRACT deleteAdvertising '{"id": $TYPE_ADVERTISING_ID}' --accountId $NEAR_ACCOUNT


* sendGratitude

  • Takes advertisingman(accountId) as a parameter
  • no return(void function)

Example call:

near call $CONTRACT sendGratitude '{"advertisingman": "$NEAR_ACCOUNT"}' --accountId $NEAR_ACCOUNT


That is all. Thank you for taking the time for me. See you in the next article.

Don’t forget to follow me on Github, LinkedIn, and Medium.🙋‍♂️

Web3 Fundamentals and NEAR

Yorumlar

Kullanıcı yorumlarını görüntüleyebilmek için kayıt olmalısınız!

Kerem R. Özerdem

Konum

İstanbul, TR

Eğitim

Fizik Mühendisliği - İstanbul Teknik Üniversitesi

© 2021 Patika Dev

facebook
twitter
instagram
youtube
linkedin