Cohorts
  • Discover
  • About Us
  • Blog
  • Patika.dev
  • Web3

NEAR Developer Course

NEAR Certified Developer Final Project
What Does a Successful Project Look Like?
The Course Outline
NEAR CLI (Command Line Interface)
NEAR Explorer

What is Assembly Script?
Contract
File Structure
Imports
Practice I

Assert
Models
Context
Storage
Practice II

Collections
Arrays
Iteration
Classes

Introduction
Keys
Identity
Money

Smart Contract Overview
Account Model
View & Change Methods
Serde
NEAR Wallet
Practice: NEAR Academy-Meme Museum

Previous successful projects
Example: Thanks
Example: Guest Book
Example: Sample Lottery
Example: CRUD dApp
Develop project ideas
Submit and build your project plan

Loom video
Documentation and explanations
How to submit

Storage

The Storage class represents the only data store on the blockchain. All blockchain data uses this one interface. Without storage, your actions cannot be saved in the blockchain system. The storage needs two variables, Key and Value.

Contracts can import a reference to storage from near-sdk-as.

import { storage } from "near-sdk-as";
// contract code below this line can now make use of the storage object

The complete interface for the Storage class is provided by the snippet below with inline comments.

// REFERENCE ONLY
// this is the interface provided by the storage object

class Storage {
  // read and write text to storage
  setString(key: string, value: string): void;
  getString(key: string): string | null;

  // read and write an array of bytes to storage
  setBytes(key: string, value: Uint8Array): void;
  getBytes(key: string): Uint8Array | null;

  // check whether a key exists
  contains(key: string): bool;
  hasKey(key: string): bool; // alias for contains()

  // delete a key from storage
  delete(key: string): void;

  // get string and data objects defined in model.ts
  // return defaultValue if key not found
  // (prefer getPrimitive<T> for bool or integer and getSome<T> if key is known to exist)
  set<T>(key: string, value: T): void;
  get<T>(key: string, defaultValue: T | null = null): T | null;

  // get bool or integer value stored under the key
  // return defaultValue if key not found
  // throw if any other type (use get<T>)
  // (prefer get<T> for string or data objects defined in model.ts and getSome<T> if key is known to exist)
  getPrimitive<T>(key: string, defaultValue: T): T;

  // get bool, integer, string and data objects defined in model.ts
  // throw if key not found
  // (prefer get<T> for string or data objects defined in model.ts and getPrimitive<T> for bool or integer)
  getSome<T>(key: string): T;
}

Quiz

Answer the questions to check your understanding.

This lesson includes a short quiz.

Previous
Next

Lesson discussion

Swap insights and ask questions about “NEAR Developer Course”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
Cohorts
WebsiteDiscoverBlogPatika.devRise In
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://cohorts.patika.dev is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://cohorts.patika.dev disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Cohorts, All rights reserved