NearPromise
Last updated
Last updated
• Docs
/ / NearPromise
A high level class to construct and work with NEAR promises.
new NearPromise(
subtype
,shouldReturn
):
Parameters
• subtype: PromiseSubtype
The subtype of the promise.
• shouldReturn: boolean
Whether the promise should return.
Returns
Defined in
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
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
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
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
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
Sets the shouldReturn field to true.
Returns
Defined in
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
Recursively goes through the current promise to get the promise index.
Returns
Defined in
Creates a create account promise action and adds it to the current promise.
Returns
Defined in
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
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
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
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
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
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
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():
void
Called by NearBindgen, when return object is a NearPromise instance.
Returns
void
Defined in
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
Adds a callback to the current promise.
Parameters
The promise to be executed as the promise.
Returns
Defined in
Creates a transfer promise action and adds it to the current promise.
Parameters
• amount: bigint
The amount of NEAR to transfer.
Returns
Defined in
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
):