TypeScript Runtime

TypeScript

Smart contracts are written in TypeScript. Here is the API reference for the runtime. Note that it's in active development, so please add an issue on Github if this is out of date and we'll fix it right away!

near-runtime-ts > "near"

External module: "near"

Index

Modules

Classes

Type aliases

  • DataTypeIndex

Variables

  • DATA_TYPE_CURRENT_ACCOUNT_ID

  • DATA_TYPE_INPUT

  • DATA_TYPE_ORIGINATOR_ACCOUNT_ID

  • DATA_TYPE_RESULT

  • DATA_TYPE_STORAGE

  • DATA_TYPE_STORAGE_ITER

  • DEFAULT_SCRATCH_BUFFER_SIZE

  • context

  • storage

Functions

  • data_read

  • promise_and

  • promise_create

  • promise_then

  • result_count

  • result_is_ok

  • return_promise

  • return_value

  • storage_has_key

  • storage_iter

  • storage_iter_next

  • storage_remove

  • storage_write

Type aliases

DataTypeIndex

Ƭ DataTypeIndex: u32

Defined in near.ts:3

Variables

<Const> DATA_TYPE_CURRENT_ACCOUNT_ID

● DATA_TYPE_CURRENT_ACCOUNT_ID: DataTypeIndex = 2

Defined in near.ts:6

<Const> DATA_TYPE_INPUT

● DATA_TYPE_INPUT: DataTypeIndex = 4

Defined in near.ts:8

<Const> DATA_TYPE_ORIGINATOR_ACCOUNT_ID

● DATA_TYPE_ORIGINATOR_ACCOUNT_ID: DataTypeIndex = 1

Defined in near.ts:5

<Const> DATA_TYPE_RESULT

● DATA_TYPE_RESULT: DataTypeIndex = 5

Defined in near.ts:9

<Const> DATA_TYPE_STORAGE

● DATA_TYPE_STORAGE: DataTypeIndex = 3

Defined in near.ts:7

<Const> DATA_TYPE_STORAGE_ITER

● DATA_TYPE_STORAGE_ITER: DataTypeIndex = 6

Defined in near.ts:10

<Const> DEFAULT_SCRATCH_BUFFER_SIZE

● DEFAULT_SCRATCH_BUFFER_SIZE: usize = 1 << 16

Defined in near.ts:1

<Let> context

● context: Context = new Context()

Defined in near.ts:789

<Let> storage

● storage: Storage = new Storage()

Defined in near.ts:220

An instance of a Storage class that is used for working with contract storage on the blockchain.

Functions

data_read

data_read(type_index: u32, key_len: usize, key: usize, max_buf_len: usize, buf_ptr: usize): usize

Defined in near.ts:992

Parameters:

Name

Type

type_index

u32

key_len

usize

key

usize

max_buf_len

usize

buf_ptr

usize

Returns: usize

promise_and

promise_and(promise_index1: u32, promise_index2: u32): u32

Defined in near.ts:1010

Parameters:

Name

Type

promise_index1

u32

promise_index2

u32

Returns: u32

promise_create

promise_create(account_id_len: usize, account_id_ptr: usize, method_name_len: usize, method_name_ptr: usize, args_len: usize, args_ptr: usize, mana: u32, amount: u64): u32

Defined in near.ts:995

Parameters:

Name

Type

account_id_len

usize

account_id_ptr

usize

method_name_len

usize

method_name_ptr

usize

args_len

usize

args_ptr

usize

mana

u32

amount

u64

Returns: u32

promise_then

promise_then(promise_index: u32, method_name_len: usize, method_name_ptr: usize, args_len: usize, args_ptr: usize, mana: u32): u32

Defined in near.ts:1003

Parameters:

Name

Type

promise_index

u32

method_name_len

usize

method_name_ptr

usize

args_len

usize

args_ptr

usize

mana

u32

Returns: u32

result_count

result_count(): u32

Defined in near.ts:982

Returns: u32

result_is_ok

result_is_ok(index: u32): bool

Defined in near.ts:984

Parameters:

Name

Type

index

u32

Returns: bool

return_promise

return_promise(promise_index: u32): void

Defined in near.ts:989

Parameters:

Name

Type

promise_index

u32

Returns: void

return_value

return_value(value_len: usize, value_ptr: usize): void

Defined in near.ts:987

Parameters:

Name

Type

value_len

usize

value_ptr

usize

Returns: void

storage_has_key

storage_has_key(key_len: usize, key_ptr: usize): bool

Defined in near.ts:975

Parameters:

Name

Type

key_len

usize

key_ptr

usize

Returns: bool

storage_iter

storage_iter(prefix_len: usize, prefix_ptr: usize): u32

Defined in near.ts:977

Parameters:

Name

Type

prefix_len

usize

prefix_ptr

usize

Returns: u32

storage_iter_next

storage_iter_next(id: u32): u32

Defined in near.ts:979

Parameters:

Name

Type

id

u32

Returns: u32

storage_remove

storage_remove(key_len: usize, key_ptr: usize): void

Defined in near.ts:973

Parameters:

Name

Type

key_len

usize

key_ptr

usize

Returns: void

storage_write

storage_write(key_len: usize, key_ptr: usize, value_len: usize, value_ptr: usize): void

Defined in near.ts:971

Parameters:

Name

Type

key_len

usize

key_ptr

usize

value_len

usize

value_ptr

usize

Returns: void