Open elsvv opened 3 months ago
Phoeb
@elsvv, I am getting the same error So I changed like this:
use std::sync::Arc;
async fn create_simple_transfer() -> anyhow::Result<()> {
...
let transfer_arc: Vec<Arc<Cell>> = vec![transfer].into_iter().map(Arc::new).collect();
let body = wallet.create_external_body(now + 60, seqno, transfer_arc)?;
....
}
@elsvv, I am getting the same error So I changed like this:
use std::sync::Arc; async fn create_simple_transfer() -> anyhow::Result<()> { ... let transfer_arc: Vec<Arc<Cell>> = vec![transfer].into_iter().map(Arc::new).collect(); let body = wallet.create_external_body(now + 60, seqno, transfer_arc)?; .... }
But getting this result:
@elsvv, I've finally found the solution:
use anyhow::Result;
use num_bigint::BigUint;
use tonlib::client::TonClientInterface;
use std::time::SystemTime;
use std::sync::Arc;
use tonlib::address::TonAddress;
use tonlib::cell::Cell;
use tonlib::cell::BagOfCells;
use tonlib::message::TransferMessage;
use tonlib::config::TESTNET_CONFIG;
use tonlib::client::TonClient;
use tonlib::client::TonClientBuilder;
use tonlib::client::TonConnectionParams;
use tonlib::contract::TonContractFactory;
use tonlib::mnemonic::Mnemonic;
use tonlib::mnemonic::KeyPair;
use tonlib::wallet::{TonWallet, WalletVersion};
use tonlib::contract::{TonWalletContract};
async fn create_simple_transfer() -> Result<()> {
let client = create_client().await?;
let contract_factory = TonContractFactory::builder(&client).build().await?;
let key_pair = create_key_pair().await?;
let wallet = TonWallet::derive_default(WalletVersion::V3R2, &key_pair)?;
let wallet_contract = contract_factory.get_contract(&wallet.address);
let seqno = wallet_contract.seqno().await?;
let dest: TonAddress = "....".parse()?;
let value = BigUint::from(10000000u64); // 0.01 TON
let transfer = TransferMessage::new(&dest, &value).build()?;
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)?
.as_secs() as u32;
let msg_arc: Vec<Arc<Cell>> = vec![transfer].into_iter().map(Arc::new).collect();
let msg_cell = wallet.create_external_message(now + 60, seqno, msg_arc, false)?;
let boc = BagOfCells::from_root(msg_cell);
let tx = boc.serialize(true)?;
let hash = client.send_raw_message_return_hash(tx.as_slice()).await?;
Ok(())
}
README create simple transfer example does not compile.
Code:
Error:
Rust version:
Cargo.toml: