Skip to content

near/near-sdk-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

NEAR JavaScript SDK

Documentation Version License: LICENSE License: LICENSE

A JavaScript library for writing NEAR smart contracts.

import { NearBindgen, near, call, view } from 'near-sdk-js';

@NearBindgen({})
class HelloNear {
  greeting: string = 'Hello';

  @view({}) // This method is read-only and can be called for free
  get_greeting(): string {
    return this.greeting;
  }

  @call({}) // This method changes the state, for which it cost gas
  set_greeting({ greeting }: { greeting: string }): void {
    near.log(`Saving greeting ${greeting}`);
    this.greeting = greeting;
  }
}

See more in the Anatomy of a Contract.

Documentation

Prerequisites

  • node >=14 <16.6.0 || >16.6.0
  • pnpm >=7

Quick Start

Use create-near-app to quickly get started writing smart contracts in JavaScript on NEAR.

npx create-near-app

This will scaffold a basic template for you ๐Ÿ˜Ž

Contributing

If you are interested in contributing, please look at the contributing guidelines.

License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE and LICENSE-APACHE for details.