pub fn promise_then(
promise_idx: PromiseIndex,
account_id: AccountId,
function_name: &str,
arguments: &[u8],
amount: NearToken,
gas: Gas,
) -> PromiseIndex
Expand description
Attaches the callback (which is a near_primitives::action::FunctionCallAction
) that is executed after promise pointed by promise_idx
is complete.
ยงExamples
use near_sdk::env::{promise_create, promise_then};
use near_sdk::serde_json;
use near_sdk::{AccountId, NearToken, Gas};
use std::str::FromStr;
let promise = 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 chained_promise = promise_then(
promise,
"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)
);
More low-level info here: near_vm_runner::logic::VMLogic::promise_then
Example usages of this low-level api are https://github.com/near/near-sdk-rs/tree/master/examples/factory-contract/low-level/src/lib.rs and https://github.com/near/near-sdk-rs/blob/master/examples/cross-contract-calls/low-level/src/lib.rs