所以我有这样的代码:
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
import { ConnectWallet, useAddress } from "@thirdweb-dev/react";
export default function DonationPage() {
let address = useAddress()
async function sendCoins() {
try {
let random = ethers.Wallet.createRandom();
// get a signer from somewhere (createRandom is being used purely for example purposes)
// get an instance of the SDK with the signer already setup
const sdk = ThirdwebSDK.fromSigner(signer || random, "mainnet");
try {
if (selectedCoin == 'eth') {
await sdk.wallet.transfer(CORPORATE_WALLET || "0x", donationAmount);
} else {
// const decimals = await contract.erc20..call()
// const amount = new BigNumber(donationAmount * (10 ** decimals))
const contract = await sdk.getContract(crypto.find((coin) => coin.id == selectedCoin)?.contract_address || '0x');
let balance = await contract.erc20.balance()
let allowance = await contract.erc20.allowance(address || '0x')
// console.log('balance', balance.value)
// console.log('allowance', allowance.value)
if(donationAmount + Number(balance.displayValue) > Number(allowance.displayValue)) {
await contract.erc20.setAllowance(address || '0x', donationAmount + Number(balance.displayValue))
}
await contract.erc20.transferFrom(address || '0x',CORPORATE_WALLET || '0x', donationAmount);
}
} catch (error: any) {
alert(error.message)
}
}
return (<>...</>)
}
因此,我使用ConnectWallet按钮来获取地址,并为此使用TrustWallet,并尝试将令牌从“地址”转移到企业钱包,并指定捐赠金额。
然而,我收到这个错误“交易没有在50个区块内挖掘,请确保您的交易被正确发送。请注意,它可能仍然被挖掘”。
网上似乎没有关于这个问题的文档,ChatGPT也帮不上忙。有人知道如何解决这个问题吗?
1条答案
按热度按时间xqkwcwgp1#