near-sdk-js
  • README
  • packages
  • api
    • functions
      • accountBalance
      • accountLockedBalance
      • altBn128G1Multiexp
      • altBn128G1Sum
      • altBn128PairingCheck
      • attachedDeposit
      • blockHeight
      • blockIndex
      • blockTimestamp
      • currentAccountId
      • ecrecover
      • epochHeight
      • input
      • inputRaw
      • keccak256
      • keccak512
      • log
      • logUtf16
      • logUtf8
      • panicUtf8
      • predecessorAccountId
      • prepaidGas
      • promiseAnd
      • promiseBatchActionAddKeyWithFullAccess
      • promiseBatchActionAddKeyWithFunctionCall
      • promiseBatchActionCreateAccount
      • promiseBatchActionDeleteAccount
      • promiseBatchActionDeleteKey
      • promiseBatchActionDeployContract
      • promiseBatchActionFunctionCall
      • promiseBatchActionFunctionCallRaw
      • promiseBatchActionFunctionCallWeight
      • promiseBatchActionFunctionCallWeightRaw
      • promiseBatchActionStake
      • promiseBatchActionTransfer
      • promiseBatchCreate
      • promiseBatchThen
      • promiseCreate
      • promiseCreateRaw
      • promiseResult
      • promiseResultRaw
      • promiseResultsCount
      • promiseReturn
      • promiseThen
      • promiseThenRaw
      • randomSeed
      • ripemd160
      • sha256
      • signerAccountId
      • signerAccountPk
      • storageByteCost
      • storageGetEvicted
      • storageGetEvictedRaw
      • storageHasKey
      • storageHasKeyRaw
      • storageRead
      • storageReadRaw
      • storageRemove
      • storageRemoveRaw
      • storageUsage
      • storageWrite
      • storageWriteRaw
      • usedGas
      • validatorStake
      • validatorTotalStake
      • valueReturn
      • valueReturnRaw
  • collections
    • lookup-map
      • classes
        • LookupMap
    • lookup-set
      • classes
        • LookupSet
    • subtype
      • classes
        • SubType
    • unordered-map
      • classes
        • UnorderedMap
    • unordered-set
      • classes
        • UnorderedSet
    • vector
      • classes
        • Vector
        • VectorIterator
  • index
    • functions
      • includeBytes
  • near-bindgen
    • functions
      • NearBindgen
      • call
      • initialize
      • middleware
      • migrate
      • view
  • promise
    • classes
      • AddAccessKey
      • AddFullAccessKey
      • CreateAccount
      • DeleteAccount
      • DeleteKey
      • DeployContract
      • FunctionCall
      • FunctionCallRaw
      • FunctionCallWeight
      • FunctionCallWeightRaw
      • NearPromise
      • PromiseAction
      • PromiseJoint
      • Stake
      • Transfer
    • type-aliases
      • PromiseOrValue
  • types
    • account_id
      • type-aliases
        • AccountId
    • collections
      • interfaces
        • GetOptions
    • gas
      • type-aliases
        • Gas
      • variables
        • ONE_TERA_GAS
    • primitives
      • type-aliases
        • Balance
        • BlockHeight
        • EpochHeight
        • GasWeight
        • Nonce
        • StorageUsage
      • variables
        • ONE_NEAR
        • ONE_YOCTO
    • public_key
      • classes
        • Base58Error
        • InvalidLengthError
        • ParsePublicKeyError
        • PublicKey
        • UnknownCurve
      • enumerations
        • CurveType
      • functions
        • curveTypeFromStr
    • vm_types
      • enumerations
        • PromiseError
        • PromiseResult
      • type-aliases
        • IteratorIndex
        • ReceiptIndex
  • utils
    • classes
      • TextDecoder
      • TextEncoder
    • functions
      • assert
      • bytes
      • concat
      • decode
      • decodeObj2class
      • deserialize
      • encode
      • getValueWithOptions
      • serialize
      • serializeValueWithOptions
      • str
      • validateAccountId
    • interfaces
      • Env
      • IntoStorageKey
    • type-aliases
      • Mutable
      • NearAmount
      • PromiseIndex
      • Register
    • variables
      • ERR_INCONSISTENT_STATE
      • ERR_INDEX_OUT_OF_BOUNDS
  • version
    • variables
      • LIB_VERSION
  • cli
    • abi
      • functions
        • runAbiCompilerPlugin
    • cli
      • functions
        • buildCom
        • checkTypescriptCom
        • createJsFileWithRollupCom
        • generateAbi
        • transpileJsAndBuildWasmCom
        • validateCom
    • post-install
    • utils
      • functions
        • download
        • executeCommand
        • validateContract
    • build-tools
      • include-bytes
        • functions
          • default
      • near-bindgen-exporter
        • functions
          • default
Powered by GitBook
On this page
  • Class: NearPromise
  • Constructors
  • Methods
  1. promise
  2. classes

NearPromise

PreviousFunctionCallWeightRawNextPromiseAction

Last updated 7 months ago

• Docs


/ / NearPromise

Class: NearPromise

A high level class to construct and work with NEAR promises.

Constructors

new NearPromise()

new NearPromise(subtype, shouldReturn):

Parameters

• subtype: PromiseSubtype

The subtype of the promise.

• shouldReturn: boolean

Whether the promise should return.

Returns

Defined in

Methods

addAccessKey()

Creates a add access key promise action and adds it to the current promise. Uses 0n as the nonce.

Parameters

The public key to add as a access key.

• allowance: bigint

The allowance for the key in yoctoNEAR.

• receiverId: string

The account ID of the receiver.

• functionNames: string

The names of functions to authorize.

Returns

Defined in


addAccessKeyWithNonce()

Creates a add access key promise action and adds it to the current promise. Allows you to specify the nonce.

Parameters

The public key to add as a access key.

• allowance: bigint

The allowance for the key in yoctoNEAR.

• receiverId: string

The account ID of the receiver.

• functionNames: string

The names of functions to authorize.

• nonce: bigint

The nonce to use.

Returns

Defined in


addFullAccessKey()

Creates a add full access key promise action and adds it to the current promise. Uses 0n as the nonce.

Parameters

The public key to add as a full access key.

Returns

Defined in


addFullAccessKeyWithNonce()

Creates a add full access key promise action and adds it to the current promise. Allows you to specify the nonce.

Parameters

The public key to add as a full access key.

• nonce: bigint

The nonce to use.

Returns

Defined in


and()

Joins the provided promise with the current promise, making the current promise a joint promise subtype.

Parameters

The promise to join with the current promise.

Returns

Defined in


asReturn()

Sets the shouldReturn field to true.

Returns

Defined in


build()

Attach the promise to transaction but does not return it. The promise will be executed, but whether it success or not will not affect the transaction result. If you want the promise fail also makes the transaction fail, you can simply return the promise from a

Returns

Call

method.

Defined in


constructRecursively()

Recursively goes through the current promise to get the promise index.

Returns

Defined in


createAccount()

Creates a create account promise action and adds it to the current promise.

Returns

Defined in


deleteAccount()

Creates a delete account promise action and adds it to the current promise.

Parameters

• beneficiaryId: string

The beneficiary of the account deletion - the account to receive all of the remaining funds of the deleted account.

Returns

Defined in


deleteKey()

Creates a delete key promise action and adds it to the current promise.

Parameters

The public key to delete from the account.

Returns

Defined in


deployContract()

Creates a deploy contract promise action and adds it to the current promise.

Parameters

• code: Uint8Array

The code of the contract to be deployed.

Returns

Defined in


functionCall()

Creates a function call promise action and adds it to the current promise.

Parameters

• functionName: string

The name of the function to be called.

• args: string

The utf-8 string arguments to be passed to the function.

• amount: bigint

The amount of NEAR to attach to the call.

• gas: bigint

The amount of Gas to attach to the call.

Returns

Defined in


functionCallRaw()

Creates a function call raw promise action and adds it to the current promise.

Parameters

• functionName: string

The name of the function to be called.

• args: Uint8Array

The arguments to be passed to the function.

• amount: bigint

The amount of NEAR to attach to the call.

• gas: bigint

The amount of Gas to attach to the call.

Returns

Defined in


functionCallWeight()

Creates a function call weight promise action and adds it to the current promise.

Parameters

• functionName: string

The name of the function to be called.

• args: string

The utf-8 string arguments to be passed to the function.

• amount: bigint

The amount of NEAR to attach to the call.

• gas: bigint

The amount of Gas to attach to the call.

• weight: bigint

The weight of unused Gas to use.

Returns

Defined in


functionCallWeightRaw()

Creates a function call weight raw promise action and adds it to the current promise.

Parameters

• functionName: string

The name of the function to be called.

• args: Uint8Array

The arguments to be passed to the function.

• amount: bigint

The amount of NEAR to attach to the call.

• gas: bigint

The amount of Gas to attach to the call.

• weight: bigint

The weight of unused Gas to use.

Returns

Defined in


onReturn()

onReturn(): void

Called by NearBindgen, when return object is a NearPromise instance.

Returns

void

Defined in


stake()

Creates a stake promise action and adds it to the current promise.

Parameters

• amount: bigint

The amount of NEAR to transfer.

The public key to use for staking.

Returns

Defined in


then()

Adds a callback to the current promise.

Parameters

The promise to be executed as the promise.

Returns

Defined in


transfer()

Creates a transfer promise action and adds it to the current promise.

Parameters

• amount: bigint

The amount of NEAR to transfer.

Returns

Defined in


new()

Creates a new promise to the provided account ID.

Parameters

• accountId: string

The account ID on which to call the promise.

Returns

Defined in

addAccessKey(publicKey, allowance, receiverId, functionNames):

• publicKey:

addAccessKeyWithNonce(publicKey, allowance, receiverId, functionNames, nonce):

• publicKey:

addFullAccessKey(publicKey):

• publicKey:

addFullAccessKeyWithNonce(publicKey, nonce):

• publicKey:

and(other):

• other:

asReturn():

build():

constructRecursively():

createAccount():

deleteAccount(beneficiaryId):

deleteKey(publicKey):

• publicKey:

deployContract(code):

functionCall(functionName, args, amount, gas):

functionCallRaw(functionName, args, amount, gas):

functionCallWeight(functionName, args, amount, gas, weight):

functionCallWeightRaw(functionName, args, amount, gas, weight):

stake(amount, publicKey):

• publicKey:

then(other):

• other:

transfer(amount):

static new(accountId):

promise
near-sdk-js v2.0.0
promise
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:372
NearPromise
PublicKey
NearPromise
packages/near-sdk-js/src/promise.ts:535
NearPromise
PublicKey
NearPromise
packages/near-sdk-js/src/promise.ts:560
NearPromise
PublicKey
NearPromise
packages/near-sdk-js/src/promise.ts:511
NearPromise
PublicKey
NearPromise
packages/near-sdk-js/src/promise.ts:522
NearPromise
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:595
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:624
PromiseIndex
PromiseIndex
packages/near-sdk-js/src/promise.ts:654
PromiseIndex
PromiseIndex
packages/near-sdk-js/src/promise.ts:632
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:397
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:586
NearPromise
PublicKey
NearPromise
packages/near-sdk-js/src/promise.ts:577
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:406
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:418
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:435
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:453
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:474
packages/near-sdk-js/src/promise.ts:645
NearPromise
PublicKey
NearPromise
packages/near-sdk-js/src/promise.ts:501
NearPromise
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:605
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:491
NearPromise
NearPromise
packages/near-sdk-js/src/promise.ts:379