Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 29, 2024
1 parent 31cd0fa commit c6bb6b9
Show file tree
Hide file tree
Showing 184 changed files with 8,890 additions and 0 deletions.
Empty file added docs/.nojekyll
Empty file.
81 changes: 81 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
**near-sdk-js v2.0.0**[**Docs**](packages.md)

***

# NEAR JavaScript SDK

<p>
<a href="https://docs.near.org/tools/sdk" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-JS/TS-brightgreen.svg" />
</a>
<a href="https://www.npmjs.com/package/near-sdk-js" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/near-sdk-js.svg">
</a>
<img src="https://img.shields.io/badge/node-%3E%3D14%20%3C16.6.0%20%7C%7C%20%3E16.6.0-blue.svg" />
<a href="https://github.com/near/near-sdk-js/blob/develop/LICENSE" target="_blank">
<img alt="License: LICENSE" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
<a href="https://github.com/near/near-sdk-js/blob/develop/LICENSE-APACHE" target="_blank">
<img alt="License: LICENSE" src="https://img.shields.io/badge/License-Apache-yellow.svg" />
</a>
</p>

A JavaScript library for writing NEAR smart contracts.

```typescript
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](https://docs.near.org/build/smart-contracts/anatomy/).

## Documentation

- [Learn by example with AgorApp](https://agorapp.dev/catalog/all?difficulty=&chains=near)
- [Learn by example with NEAR Docs](https://docs.near.org/build/smart-contracts/quickstart)
- Check our [detailed examples and tutorials](https://docs.near.org/tutorials/welcome)
- Find [source code examples](https://github.com/near/near-sdk-js/tree/develop/examples) with common use cases
- Lookup available features in [API reference](https://near.github.io/near-sdk-js/)
- 🏠 Learn more about NEAR on our [Documentation website](https://docs.near.org/)
- Breaking features diff from [SDK 2.0.0 to 1.0.0](https://github.com/near/near-sdk-js/tree/develop/[email protected])

## Prerequisites

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

## Quick Start

Use [`create-near-app`](https://github.com/near/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](https://github.com/near/near-sdk-js/tree/develop/CONTRIBUTING.md).

- [Report issues you encounter](https://github.com/near/near-sdk-js/issues) 🐞
- [Provide suggestions or feedback](https://github.com/near/near-sdk-js/discussions) 💡
- [Show us what you've built!](https://github.com/near/near-sdk-js/discussions/categories/show-and-tell) 💪

## License

This repository is distributed under the terms of both the [MIT license](https://github.com/near/near-sdk-js/blob/develop/LICENSE) and the [Apache License](https://github.com/near/near-sdk-js/blob/develop/LICENSE-APACHE) (Version 2.0).
See [LICENSE](https://github.com/near/near-sdk-js/tree/develop/LICENSE) and [LICENSE-APACHE](https://github.com/near/near-sdk-js/tree/develop/LICENSE-APACHE) for details.
79 changes: 79 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
**api****Docs**

***

[near-sdk-js v2.0.0](../packages.md) / api

# api

## Index

### Functions

- [accountBalance](functions/accountBalance.md)
- [accountLockedBalance](functions/accountLockedBalance.md)
- [altBn128G1Multiexp](functions/altBn128G1Multiexp.md)
- [altBn128G1Sum](functions/altBn128G1Sum.md)
- [altBn128PairingCheck](functions/altBn128PairingCheck.md)
- [attachedDeposit](functions/attachedDeposit.md)
- [blockHeight](functions/blockHeight.md)
- [blockIndex](functions/blockIndex.md)
- [blockTimestamp](functions/blockTimestamp.md)
- [currentAccountId](functions/currentAccountId.md)
- [ecrecover](functions/ecrecover.md)
- [epochHeight](functions/epochHeight.md)
- [input](functions/input.md)
- [inputRaw](functions/inputRaw.md)
- [keccak256](functions/keccak256.md)
- [keccak512](functions/keccak512.md)
- [log](functions/log.md)
- [logUtf16](functions/logUtf16.md)
- [logUtf8](functions/logUtf8.md)
- [panicUtf8](functions/panicUtf8.md)
- [predecessorAccountId](functions/predecessorAccountId.md)
- [prepaidGas](functions/prepaidGas.md)
- [promiseAnd](functions/promiseAnd.md)
- [promiseBatchActionAddKeyWithFullAccess](functions/promiseBatchActionAddKeyWithFullAccess.md)
- [promiseBatchActionAddKeyWithFunctionCall](functions/promiseBatchActionAddKeyWithFunctionCall.md)
- [promiseBatchActionCreateAccount](functions/promiseBatchActionCreateAccount.md)
- [promiseBatchActionDeleteAccount](functions/promiseBatchActionDeleteAccount.md)
- [promiseBatchActionDeleteKey](functions/promiseBatchActionDeleteKey.md)
- [promiseBatchActionDeployContract](functions/promiseBatchActionDeployContract.md)
- [promiseBatchActionFunctionCall](functions/promiseBatchActionFunctionCall.md)
- [promiseBatchActionFunctionCallRaw](functions/promiseBatchActionFunctionCallRaw.md)
- [promiseBatchActionFunctionCallWeight](functions/promiseBatchActionFunctionCallWeight.md)
- [promiseBatchActionFunctionCallWeightRaw](functions/promiseBatchActionFunctionCallWeightRaw.md)
- [promiseBatchActionStake](functions/promiseBatchActionStake.md)
- [promiseBatchActionTransfer](functions/promiseBatchActionTransfer.md)
- [promiseBatchCreate](functions/promiseBatchCreate.md)
- [promiseBatchThen](functions/promiseBatchThen.md)
- [promiseCreate](functions/promiseCreate.md)
- [promiseCreateRaw](functions/promiseCreateRaw.md)
- [promiseResult](functions/promiseResult.md)
- [promiseResultRaw](functions/promiseResultRaw.md)
- [promiseResultsCount](functions/promiseResultsCount.md)
- [promiseReturn](functions/promiseReturn.md)
- [promiseThen](functions/promiseThen.md)
- [promiseThenRaw](functions/promiseThenRaw.md)
- [randomSeed](functions/randomSeed.md)
- [ripemd160](functions/ripemd160.md)
- [sha256](functions/sha256.md)
- [signerAccountId](functions/signerAccountId.md)
- [signerAccountPk](functions/signerAccountPk.md)
- [storageByteCost](functions/storageByteCost.md)
- [storageGetEvicted](functions/storageGetEvicted.md)
- [storageGetEvictedRaw](functions/storageGetEvictedRaw.md)
- [storageHasKey](functions/storageHasKey.md)
- [storageHasKeyRaw](functions/storageHasKeyRaw.md)
- [storageRead](functions/storageRead.md)
- [storageReadRaw](functions/storageReadRaw.md)
- [storageRemove](functions/storageRemove.md)
- [storageRemoveRaw](functions/storageRemoveRaw.md)
- [storageUsage](functions/storageUsage.md)
- [storageWrite](functions/storageWrite.md)
- [storageWriteRaw](functions/storageWriteRaw.md)
- [usedGas](functions/usedGas.md)
- [validatorStake](functions/validatorStake.md)
- [validatorTotalStake](functions/validatorTotalStake.md)
- [valueReturn](functions/valueReturn.md)
- [valueReturnRaw](functions/valueReturnRaw.md)
19 changes: 19 additions & 0 deletions docs/api/functions/accountBalance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / accountBalance

# Function: accountBalance()

> **accountBalance**(): `bigint`
Returns the current account's account balance.

## Returns

`bigint`

## Defined in

[packages/near-sdk-js/src/api.ts:266](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L266)
19 changes: 19 additions & 0 deletions docs/api/functions/accountLockedBalance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / accountLockedBalance

# Function: accountLockedBalance()

> **accountLockedBalance**(): `bigint`
Returns the current account's locked balance.

## Returns

`bigint`

## Defined in

[packages/near-sdk-js/src/api.ts:273](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L273)
32 changes: 32 additions & 0 deletions docs/api/functions/altBn128G1Multiexp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / altBn128G1Multiexp

# Function: altBn128G1Multiexp()

> **altBn128G1Multiexp**(`value`): `Uint8Array`
Computes multiexp on alt_bn128 curve using Pippenger's algorithm \sum_i
mul_i g_{1 i} should be equal result.

## Parameters

**value**: `Uint8Array`

equence of (g1:G1, fr:Fr), where
G1 is point (x:Fq, y:Fq) on alt_bn128,
alt_bn128 is Y^2 = X^3 + 3 curve over Fq.
`value` is encoded as packed, little-endian
`[((u256, u256), u256)]` slice.

## Returns

`Uint8Array`

multi exp sum

## Defined in

[packages/near-sdk-js/src/api.ts:978](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L978)
32 changes: 32 additions & 0 deletions docs/api/functions/altBn128G1Sum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / altBn128G1Sum

# Function: altBn128G1Sum()

> **altBn128G1Sum**(`value`): `Uint8Array`
Computes sum for signed g1 group elements on alt_bn128 curve \sum_i
(-1)^{sign_i} g_{1 i} should be equal result.

## Parameters

**value**: `Uint8Array`

sequence of (sign:bool, g1:G1), where
G1 is point (x:Fq, y:Fq) on alt_bn128,
alt_bn128 is Y^2 = X^3 + 3 curve over Fq.
value` is encoded a as packed, little-endian
`[((u256, u256), ((u256, u256), (u256, u256)))]` slice.

## Returns

`Uint8Array`

sum over Fq.

## Defined in

[packages/near-sdk-js/src/api.ts:995](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L995)
35 changes: 35 additions & 0 deletions docs/api/functions/altBn128PairingCheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / altBn128PairingCheck

# Function: altBn128PairingCheck()

> **altBn128PairingCheck**(`value`): `boolean`
Computes pairing check on alt_bn128 curve.
\sum_i e(g_{1 i}, g_{2 i}) should be equal one (in additive notation), e(g1, g2) is Ate pairing

## Parameters

**value**: `Uint8Array`

sequence of (g1:G1, g2:G2), where
G2 is Fr-ordered subgroup point (x:Fq2, y:Fq2) on alt_bn128 twist,
alt_bn128 twist is Y^2 = X^3 + 3/(i+9) curve over Fq2
Fq2 is complex field element (re: Fq, im: Fq)
G1 is point (x:Fq, y:Fq) on alt_bn128,
alt_bn128 is Y^2 = X^3 + 3 curve over Fq
`value` is encoded a as packed, little-endian
`[((u256, u256), ((u256, u256), (u256, u256)))]` slice.

## Returns

`boolean`

whether pairing check pass

## Defined in

[packages/near-sdk-js/src/api.ts:1015](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L1015)
20 changes: 20 additions & 0 deletions docs/api/functions/attachedDeposit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / attachedDeposit

# Function: attachedDeposit()

> **attachedDeposit**(): `bigint`
Returns the amount of NEAR attached to this function call.
Can only be called in payable functions.

## Returns

`bigint`

## Defined in

[packages/near-sdk-js/src/api.ts:245](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L245)
19 changes: 19 additions & 0 deletions docs/api/functions/blockHeight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / blockHeight

# Function: blockHeight()

> **blockHeight**(): `bigint`
Returns the current block height.

## Returns

`bigint`

## Defined in

[packages/near-sdk-js/src/api.ts:223](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L223)
19 changes: 19 additions & 0 deletions docs/api/functions/blockIndex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / blockIndex

# Function: blockIndex()

> **blockIndex**(): `bigint`
Returns the current block index.

## Returns

`bigint`

## Defined in

[packages/near-sdk-js/src/api.ts:216](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L216)
19 changes: 19 additions & 0 deletions docs/api/functions/blockTimestamp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**api**](../README.md)**Docs**

***

[near-sdk-js v2.0.0](../../packages.md) / [api](../README.md) / blockTimestamp

# Function: blockTimestamp()

> **blockTimestamp**(): `bigint`
Returns the current block timestamp.

## Returns

`bigint`

## Defined in

[packages/near-sdk-js/src/api.ts:230](https://github.com/dim-daskalov/near-sdk-js/blob/4125d093afc79de35e86ff5ca881ac51eabb2cb3/packages/near-sdk-js/src/api.ts#L230)
Loading

0 comments on commit c6bb6b9

Please sign in to comment.