rocklabs-io / ic-web3

Ethereum RPC client for canisters on the IC
MIT License
41 stars 14 forks source link

I need an example of doing USDT transaction? #32

Open aliscie opened 1 year ago

aliscie commented 1 year ago

I need an example of doing USDT transaction?

ccyanxyz commented 1 year ago

Can you clarify? Send USDT using t-ECDSA to EVM chains or send USDT from EVM chains to IC?

aliscie commented 1 year ago

here instead of send_eth I want send_usdt

I want to send USDT from EVM chains to IC. and I want to send USDT from IC to EVM.

Or instead, maybe I just can use the Stoic wallet instead of ic-web3, not sure yet about the cons and pros of each option.

for example, can I do this

use ic_web3::types::{TransactionRequest, Value};
use ic_web3::Web3;
use std::str::FromStr;

#[tokio::main]
async fn main() {
    // Connect to the Internet Computer network
    let web3 = Web3::new("https://ic0.app").await.unwrap();

    // Set the sender and recipient addresses
    let sender = "YOUR_SENDER_ADDRESS";
    let recipient = "YOUR_RECIPIENT_ADDRESS";

    // Set the amount of ICP to transfer
    let amount: u64 = 1000000000; // 1 ICP = 1,000,000,000 e8

    // Build the transaction request
    let transaction_request = TransactionRequest {
        from: Some(sender.parse().unwrap()),
        to: Some(recipient.parse().unwrap()),
        value: Some(Value::from(amount)),
        ..Default::default()
    };

    // Send the transaction
    let tx_hash = web3.eth_send_transaction(transaction_request).await.unwrap();

    // Print the transaction hash
    println!("Transaction sent. Hash: {}", tx_hash);
}

this is a psycho code, so my question here, what is the actually code should be.