pub fn promise_batch_action_add_key_allowance_with_function_call(
promise_index: PromiseIndex,
public_key: &PublicKey,
nonce: u64,
allowance: Allowance,
receiver_id: &AccountId,
function_names: &str,
)
Expand description
Attach promise action that adds a key with function call with specifi allowance to the NEAR promise index with the provided promise index.
More info about batching here
ยงExamples
Unlimited allowance
use near_sdk::env::{promise_batch_action_add_key_allowance_with_function_call, promise_batch_create};
use near_sdk::{PublicKey, AccountId, Allowance};
use std::str::FromStr;
let promise = promise_batch_create(
&AccountId::from_str("receiver.near").unwrap()
);
let pk: PublicKey = "secp256k1:qMoRgcoXai4mBPsdbHi1wfyxF9TdbPCF4qSDQTRP3TfescSRoUdSx6nmeQoN3aiwGzwMyGXAb1gUjBTv5AY8DXj".parse().unwrap();
let nonce = 55;
promise_batch_action_add_key_allowance_with_function_call(
promise,
&pk,
nonce,
Allowance::unlimited(),
&AccountId::from_str("counter.near").unwrap(),
"increase,decrease"
);
Limited allowance (1 NEAR)
use near_sdk::env::{promise_batch_action_add_key_allowance_with_function_call, promise_batch_create};
use near_sdk::{PublicKey, AccountId, Allowance, NearToken};
use std::str::FromStr;
let promise = promise_batch_create(
&AccountId::from_str("receiver.near").unwrap()
);
let pk: PublicKey = "secp256k1:qMoRgcoXai4mBPsdbHi1wfyxF9TdbPCF4qSDQTRP3TfescSRoUdSx6nmeQoN3aiwGzwMyGXAb1gUjBTv5AY8DXj".parse().unwrap();
let nonce = 55;
promise_batch_action_add_key_allowance_with_function_call(
promise,
&pk,
nonce,
Allowance::limited(NearToken::from_near(1)).unwrap(),
&AccountId::from_str("counter.near").unwrap(),
"increase,decrease"
);