pub struct CallFunctionBuilder {
contract: AccountId,
method_name: String,
args: Vec<u8>,
}Fields§
§contract: AccountId§method_name: String§args: Vec<u8>Implementations§
Source§impl CallFunctionBuilder
impl CallFunctionBuilder
Sourcepub fn read_only<Response: Send + Sync + DeserializeOwned>(
self,
) -> RequestBuilder<CallResultHandler<Response>>
pub fn read_only<Response: Send + Sync + DeserializeOwned>( self, ) -> RequestBuilder<CallResultHandler<Response>>
Prepares a read-only query that doesn’t require a signing transaction.
§Example
use near_api::*;
let balance: Data<u64> = Contract("some_contract.testnet".parse()?).call_function("get_balance", ())?.read_only().fetch_from_testnet().await?;
println!("Balance: {:?}", balance);
let balance_at_block: Data<u64> = Contract("some_contract.testnet".parse()?).call_function("get_balance", ())?.read_only().at(Reference::AtBlock(1000000)).fetch_from_testnet().await?;
println!("Balance at block 1000000: {:?}", balance_at_block);Sourcepub fn read_only_borsh<Response: Send + Sync + BorshDeserialize>(
self,
) -> RequestBuilder<CallResultBorshHandler<Response>>
pub fn read_only_borsh<Response: Send + Sync + BorshDeserialize>( self, ) -> RequestBuilder<CallResultBorshHandler<Response>>
Prepares a read-only query that deserializes the response using Borsh instead of JSON.
This method is useful when the contract returns Borsh-encoded data instead of JSON.
§Example
use near_api::*;
let value: Data<u64> = Contract("some_contract.testnet".parse()?)
.call_function("get_number", ())?
.read_only_borsh()
.fetch_from_testnet()
.await?;
println!("Value: {:?}", value);Sourcepub fn transaction(self) -> ContractTransactBuilder
pub fn transaction(self) -> ContractTransactBuilder
Prepares a transaction that will call a contract function leading to a state change.
This will require a signer to be provided and gas to be paid.
Trait Implementations§
Source§impl Clone for CallFunctionBuilder
impl Clone for CallFunctionBuilder
Source§fn clone(&self) -> CallFunctionBuilder
fn clone(&self) -> CallFunctionBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CallFunctionBuilder
impl RefUnwindSafe for CallFunctionBuilder
impl Send for CallFunctionBuilder
impl Sync for CallFunctionBuilder
impl Unpin for CallFunctionBuilder
impl UnwindSafe for CallFunctionBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more