pub struct SendToBuilder {
from: AccountId,
receiver_id: AccountId,
}Fields§
§from: AccountId§receiver_id: AccountIdImplementations§
Source§impl SendToBuilder
impl SendToBuilder
Sourcepub fn near(self, amount: NearToken) -> ConstructTransaction
pub fn near(self, amount: NearToken) -> ConstructTransaction
Prepares a new transaction for sending NEAR tokens to another account.
Sourcepub fn ft(
self,
ft_contract: AccountId,
amount: FTBalance,
) -> Result<TransactionWithSign<FTTransactionable>, BuilderError>
pub fn ft( self, ft_contract: AccountId, amount: FTBalance, ) -> Result<TransactionWithSign<FTTransactionable>, BuilderError>
Prepares a new transaction contract call (ft_transfer, ft_metadata, storage_balance_of, storage_deposit) for sending FT tokens to another account.
Please note that if the receiver does not have enough storage, we will automatically deposit 100 milliNEAR for storage from the sender.
The provided function depends that the contract implements NEP-141
For transferring tokens and calling a receiver contract method in a single transaction, see ft_call.
Sourcepub fn nft(
self,
nft_contract: AccountId,
token_id: String,
) -> Result<ConstructTransaction, BuilderError>
pub fn nft( self, nft_contract: AccountId, token_id: String, ) -> Result<ConstructTransaction, BuilderError>
Sourcepub fn ft_call(
self,
ft_contract: AccountId,
amount: FTBalance,
msg: String,
) -> Result<TransactionWithSign<FTTransactionable>, BuilderError>
pub fn ft_call( self, ft_contract: AccountId, amount: FTBalance, msg: String, ) -> Result<TransactionWithSign<FTTransactionable>, BuilderError>
Prepares a new transaction contract call (ft_transfer_call, ft_metadata, storage_balance_of, storage_deposit) for transferring FT tokens and calling a receiver contract method.
This method enables transferring tokens and invoking a receiver contract method in a single transaction.
The receiver contract must implement ft_on_transfer according to NEP-141.
Please note that if the receiver does not have enough storage, we will automatically deposit 100 milliNEAR for storage from the sender.
The provided function depends that the contract implements NEP-141
§Example
use near_api::*;
let alice_tokens = Tokens::account("alice.near".parse()?);
let result = alice_tokens.send_to("contract.near".parse()?)
.ft_call(
"usdt.tether-token.near".parse()?,
USDT_BALANCE.with_whole_amount(100),
"deposit".to_string(),
)?
.with_signer(Signer::new(Signer::from_ledger())?)
.send_to_mainnet()
.await?;Sourcepub fn nft_call(
self,
nft_contract: AccountId,
token_id: String,
msg: String,
) -> Result<ConstructTransaction, BuilderError>
pub fn nft_call( self, nft_contract: AccountId, token_id: String, msg: String, ) -> Result<ConstructTransaction, BuilderError>
Prepares a new transaction contract call (nft_transfer_call) for transferring an NFT and calling a receiver contract method.
This method enables “transfer and call” functionality, allowing a user to attach an NFT to a function call
on a separate contract in a single transaction. The receiver contract must implement nft_on_transfer according to NEP-171.
The provided function depends that the contract implements NEP-171
§Example
use near_api::*;
let alice_tokens = Tokens::account("alice.near".parse()?);
let result = alice_tokens.send_to("marketplace.near".parse()?)
.nft_call(
"nft-contract.testnet".parse()?,
"token-123".to_string(),
"list_for_sale".to_string(),
)?
.with_signer(Signer::new(Signer::from_ledger())?)
.send_to_testnet()
.await?;Trait Implementations§
Source§impl Clone for SendToBuilder
impl Clone for SendToBuilder
Source§fn clone(&self) -> SendToBuilder
fn clone(&self) -> SendToBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more