Function promise_and

Source
pub fn promise_and(promise_indices: &[PromiseIndex]) -> PromiseIndex
Expand description

Creates a new promise which completes when time all promises passed as arguments complete.

ยงExamples

use near_sdk::env::{promise_create, promise_and};
use near_sdk::serde_json;
use near_sdk::{AccountId, NearToken, Gas};
use std::str::FromStr;

let promise1 = promise_create(
    "counter.near".parse().unwrap(),
    "increment",
    serde_json::json!({
        "value": 5        
    }).to_string().into_bytes().as_slice(),
    NearToken::from_yoctonear(0),
    Gas::from_tgas(30)
);

let promise2 = promise_create(
    "greetings.near".parse().unwrap(),
    "set_greeting",
    serde_json::json!({
        "text": "Hello World"
    }).to_string().into_bytes().as_slice(),
    NearToken::from_yoctonear(4000000000000),
    Gas::from_tgas(30)
);

let chained_promise = promise_and(&[promise1, promise2]);

More low-level info here: near_vm_runner::logic::VMLogic::promise_and