Skip to main content

CallBuilder

Struct CallBuilder 

Source
pub struct CallBuilder { /* private fields */ }
Expand description

Builder for configuring a function call within a transaction.

Created via TransactionBuilder::call. Allows setting args, gas, and deposit before continuing to chain more actions or sending.

Implementations§

Source§

impl CallBuilder

Source

pub fn args<A: Serialize>(self, args: A) -> Self

Set JSON arguments.

Source

pub fn args_raw(self, args: Vec<u8>) -> Self

Set raw byte arguments.

Source

pub fn args_borsh<A: BorshSerialize>(self, args: A) -> Self

Set Borsh-encoded arguments.

Source

pub fn gas(self, gas: impl IntoGas) -> Self

Set gas limit.

§Example
near.transaction("contract.testnet")
    .call("method")
        .gas(Gas::tgas(50))
    .send()
    .await?;
§Panics

Panics if the gas string cannot be parsed. Use Gas’s FromStr impl for fallible parsing of user input.

Source

pub fn deposit(self, amount: impl IntoNearToken) -> Self

Set attached deposit.

§Example
near.transaction("contract.testnet")
    .call("method")
        .deposit(NearToken::near(1))
    .send()
    .await?;
§Panics

Panics if the amount string cannot be parsed. Use NearToken’s FromStr impl for fallible parsing of user input.

Source

pub fn call(self, method: &str) -> CallBuilder

Add another function call.

Source

pub fn create_account(self) -> TransactionBuilder

Add a create account action.

Source

pub fn transfer(self, amount: impl IntoNearToken) -> TransactionBuilder

Add a transfer action.

Source

pub fn deploy(self, code: impl Into<Vec<u8>>) -> TransactionBuilder

Add a deploy contract action.

Source

pub fn add_full_access_key(self, public_key: PublicKey) -> TransactionBuilder

Add a full access key.

Source

pub fn add_function_call_key( self, public_key: PublicKey, receiver_id: impl AsRef<str>, method_names: Vec<String>, allowance: Option<NearToken>, ) -> TransactionBuilder

Add a function call access key.

Source

pub fn delete_key(self, public_key: PublicKey) -> TransactionBuilder

Delete an access key.

Source

pub fn delete_account( self, beneficiary_id: impl AsRef<str>, ) -> TransactionBuilder

Delete the account.

Source

pub fn stake( self, amount: impl IntoNearToken, public_key: PublicKey, ) -> TransactionBuilder

Add a stake action.

Source

pub fn publish_contract( self, code: impl Into<Vec<u8>>, by_hash: bool, ) -> TransactionBuilder

Publish a contract to the global registry.

Source

pub fn deploy_from_hash(self, code_hash: CryptoHash) -> TransactionBuilder

Deploy a contract from the global registry by code hash.

Source

pub fn deploy_from_publisher( self, publisher_id: impl AsRef<str>, ) -> TransactionBuilder

Deploy a contract from the global registry by publisher account.

Source

pub fn state_init_by_hash( self, code_hash: CryptoHash, data: BTreeMap<Vec<u8>, Vec<u8>>, deposit: impl IntoNearToken, ) -> TransactionBuilder

Create a NEP-616 deterministic state init action with code hash reference.

Source

pub fn state_init_by_publisher( self, publisher_id: impl AsRef<str>, data: BTreeMap<Vec<u8>, Vec<u8>>, deposit: impl IntoNearToken, ) -> TransactionBuilder

Create a NEP-616 deterministic state init action with publisher account reference.

Source

pub fn sign_with(self, signer: impl Signer + 'static) -> TransactionBuilder

Override the signer.

Source

pub fn wait_until(self, status: TxExecutionStatus) -> TransactionBuilder

Set the execution wait level.

Source

pub async fn delegate( self, options: DelegateOptions, ) -> Result<DelegateResult, Error>

Build and sign a delegate action for meta-transactions (NEP-366).

This finishes the current function call and then creates a delegate action.

Source

pub async fn sign_offline( self, block_hash: CryptoHash, nonce: u64, ) -> Result<SignedTransaction, Error>

Sign the transaction offline without network access.

See TransactionBuilder::sign_offline for details.

Source

pub async fn sign(self) -> Result<SignedTransaction, Error>

Sign the transaction without sending it.

See TransactionBuilder::sign for details.

Source

pub fn send(self) -> TransactionSend

Send the transaction.

Trait Implementations§

Source§

impl IntoFuture for CallBuilder

Source§

type Output = Result<FinalExecutionOutcome, Error>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <CallBuilder as IntoFuture>::Output> + Send>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more