first commit

This commit is contained in:
jack
2025-11-12 16:47:21 +08:00
commit 266ba871a4
43 changed files with 3747 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import { ethers } from 'ethers';
// 替换为您的节点URL
const providerUrl = 'https://testnet-rpc.monad.xyz';
const provider = new ethers.JsonRpcProvider(providerUrl);
// 替换为您的钱包私钥(发送方钱包)
const privateKey = '0x3991542110242368f4770716be904b0ca6d44a8dbe4501771833b1a3642198d1'; // 私钥
const wallet = new ethers.Wallet(privateKey, provider);
// 接收方钱包地址
const recipientAddress = '0x70D5EE1DfddD3726f0D71F4CD5a8ef43aC651a75';
// 发送代币的函数
async function sendToken() {
try {
const amountToSend = ethers.parseEther('0.0000000000001'); // 发送数量
// 构造交易对象
const tx = {
to: recipientAddress,
value: amountToSend
};
// 发送交易
const txResponse = await wallet.sendTransaction(tx);
console.log('Transaction hash:', txResponse.hash);
// 等待交易确认
const receipt = await txResponse.wait();
console.log('Transaction receipt:', receipt);
} catch (error) {
console.error('Error sending Token:', error);
}
}
// 调用发送Token的函数
sendToken();
+39
View File
@@ -0,0 +1,39 @@
// import { ethers } from 'ethers';
import { ethers } from "https://cdn-cors.ethers.io/lib/ethers-5.6.9.esm.min.js";
// 设置 RPC URL
const providerUrl = 'https://dream-rpc.somnia.network';
const provider = new ethers.JsonRpcProvider(providerUrl);
// 替换为您的钱包私钥(发送方钱包)
const privateKey = '0x3991542110242368f4770716be904b0ca6d44a8dbe4501771833b1a3642198d1'; // 私钥
const wallet = new ethers.Wallet(privateKey, provider);
// 接收方钱包地址
const recipientAddress = '0x70D5EE1DfddD3726f0D71F4CD5a8ef43aC651a75';
// 发送代币的函数
async function sendToken() {
try {
const amountToSend = ethers.parseEther('0.0000000000001'); // 发送数量
// 构造交易对象
const tx = {
to: recipientAddress,
value: amountToSend
};
// 发送交易
const txResponse = await wallet.sendTransaction(tx);
console.log('Transaction hash:', txResponse.hash);
// 等待交易确认
const receipt = await txResponse.wait();
console.log('Transaction receipt:', receipt);
} catch (error) {
console.error('Error sending Token:', error);
}
}
// 调用发送Token的函数
sendToken();