转账 ETH
本教程使用 buildbear 测试平台提供的配置信息进行测试,如果没有请先注册。
配置 RPC 远程调用和配置钱包
私钥获取方法:打开 MetaMask
钱包,点击右上角 :
-> 账号详情 -> 详情
import { ethers } from "ethers";
// 配置提供者(例如 buildbear、Infura、Alchemy 或本地节点)
const provider = new ethers.JsonRpcProvider(
// 填写你的 RPC 节点,请不要使用下面
"https://rpc.buildbear.io/outstanding-juggernaut-05cd9cc5"
);
// 配置钱包
const privateKey = "..."; // 替换为你的私钥
const wallet = new ethers.Wallet(privateKey, provider);