pub fn promise_batch_create(account_id: &AccountId) -> PromiseIndex
Expand description
ยงExamples
use near_sdk::env;
use near_sdk::AccountId;
use std::str::FromStr;
let promise = env::promise_batch_create(
&"receiver.near".parse().unwrap()
);
Create a NEAR promise which will have multiple promise actions inside.
Example:
use near_sdk::{env, NearToken, Gas, AccountId};
let promise_index = env::promise_batch_create(
&"example.near".parse().unwrap()
);
// Adding actions to the promise
env::promise_batch_action_transfer(promise_index, NearToken::from_near(10u128)); // Transfer 10 NEAR
env::promise_batch_action_function_call(
promise_index,
"method_name", // Target method
b"{}", // Arguments
NearToken::from_near(0), // Attached deposit
Gas::from_tgas(5) // Gas for execution
);
All actions in a batch are executed in the order they were added.
Batched actions act as a unit: they execute in the same receipt, and if any fails, then they all get reverted.
More information about batching actions can be found in NEAR documentation
More low-level info here: near_vm_runner::logic::VMLogic::promise_batch_create
See example of usage here