1use multiversx_sdk::{data::transaction::Transaction, wallet::Wallet};
2use multiversx_sdk_http::{DEVNET_GATEWAY, GatewayHttpProxy};
3
4#[tokio::main]
5async fn main() {
6 let wl = Wallet::from_private_key(
7 "1648ad209d6b157a289884933e3bb30f161ec7113221ec16f87c3578b05830b0",
8 )
9 .unwrap();
10 let addr = wl.to_address();
11 let blockchain = GatewayHttpProxy::new(DEVNET_GATEWAY.to_string());
12 let network_config = blockchain.get_network_config().await.unwrap();
13
14 let arg = blockchain
15 .get_default_transaction_arguments(&addr, &network_config)
16 .await
17 .unwrap();
18
19 let mut unsign_tx = Transaction {
20 nonce: arg.nonce,
21 value: "0".to_string(),
22 receiver: addr.to_bech32(&network_config.address_hrp),
23 sender: addr.to_bech32(&network_config.address_hrp),
24 gas_price: arg.gas_price,
25 gas_limit: arg.gas_limit,
26 data: arg.data,
27 signature: None,
28 chain_id: arg.chain_id,
29 version: arg.version,
30 options: arg.options,
31 };
32
33 let signature = wl.sign_tx(&unsign_tx);
34 unsign_tx.signature = Some(hex::encode(signature));
35 let tx_hash = blockchain.send_transaction(&unsign_tx).await.unwrap();
36
37 assert!(!tx_hash.is_empty());
38 println!("tx_hash {tx_hash}");
39}