我正试图在Uniswap上为我的智能合约添加流动性,但每当我尝试添加流动性时,我都可以批准交易,但点击应用程序无济于事。Javascript控制台显示一个错误:无法预测气体gee。TransferFrom也有问题。
function transfer(address to, uint value) public returns(bool) {
require(balanceOf(msg.sender) >= value, 'balance too low');
//burn&tax
burn(msg.sender,burnTaxFee(value));
sendDev(msg.sender,devTaxFee(value));
balances[to] += value; //send the value - burnt tokens to reciever
balances[msg.sender] -= value ; //subtract value sent from sender.
emit Transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) public returns(bool) {
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
//burn&tax
burn(msg.sender,burnTaxFee(value));
sendDev(msg.sender,devTaxFee(value));
balances[to] += value; //send the value - burnt tokens to reciever
balances[from] -= value; //subtract value sent from sender.
emit Transfer(from, to, value);
return true;
}
我想这可能和我的智能合约有关?对于每次转账,我还进行两次单独的转账,分别放入两个单独的钱包。正常传输功能触发的多次传输是否会导致uniswap出现问题?
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"code":-32603,"message":"execution reverted: TransferHelper: TRANSFER_FROM_FAILED","data":{"originalError":{"code":3,"data":"0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000245472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c454400000000000000000000000000000000000000000000000000000000","message":"execution reverted: TransferHelper: TRANSFER_FROM_FAILED"}}}, method="estimateGas", transaction={"from":"0xA6486944b1119CDAB743694873e28ad8eF3f89e2","to":"0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D","value":{"type":"BigNumber","hex":"0x1717b72f0a4000"},"data":"0xf305d71900000000000000000000000054620e1c1c39d689fc73214bb1de16f743214dce0000000000000000000000000000000000000000000113d788ba2b887b6c80000000000000000000000000000000000000000000000113d788ba2b887b6c8000000000000000000000000000000000000000000000000000001717b72f0a4000000000000000000000000000a6486944b1119cdab743694873e28ad8ef3f89e20000000000000000000000000000000000000000000000000000000060c1817e","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.2.0)
我的另一个想法是,我没有使用SafeMath库,非安全数学方程会导致Uniswap出现问题吗?
由于您部署自己的代币时要么收费,要么烧录,因此uniswap路由器可能没有将您的代币视为收费代币。uniswap路由器具有特定的单独功能,用于在代币有费用或在传输时烧钱时进行交换。uniswap的ui可能不知道调用这些函数,因为您自己部署了这个令牌。
因此,您可以制作自己的UI,以支持通过对路由器的正确函数调用来交换您的代币,或者想办法将您的代币与费用集成到uniswap中。我不完全确定该怎么做,但我希望这至少能帮助你找出问题的根源。