我尝试在dapp中设置一个函数,要求用户将X B美元发送到钱包中。问题是,我不知道如何让它要求BUSD而不是ETH。
try {
if (!window.ethereum)
throw new Error('No ethereum provider found');
await window.ethereum.request({method: "eth_requestAccounts"});
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = await provider.getSigner();
ethers.utils.getAddress(address);
const tx = await signer.sendTransaction({
to: address,
value: ethers.utils.parseEther("0.1"),
});
console.log(tx);
} catch (e) {
console.log(e.message);
}这是我的代码,但我想发送BUSD,而不是ETH。
发布于 2022-01-15 19:02:04
令牌传输的工作方式非常不同。
要传输X个令牌Y,您必须调用Y的令牌契约的传输功能。因此,您将事务发送给令牌契约,而不是令牌的接收方。然后,事务数据决定谁是令牌的接收方,以及有多少令牌。
你应该研究令牌转移更多,有很多教程可以在线。
https://ethereum.stackexchange.com/questions/119010
复制相似问题