1、调整gas费浮动比例为90%

This commit is contained in:
2025-05-17 09:10:14 +08:00
parent 38a5acface
commit 8113868cc0
19 changed files with 397 additions and 23 deletions

View File

@ -28,7 +28,7 @@ func TransferErc20(
tokenAmount decimal.Decimal,
tokenDecimals uint8) (*types.Transaction, error) {
switch tokenAddress {
case "":
case "0":
return TransferEth(client, fromPrivateKey, toAddress, tokenAmount)
default:
return TransferErc20Token(client, fromPrivateKey, tokenAddress, toAddress, tokenAmount, tokenDecimals)
@ -81,7 +81,7 @@ func TransferEth(client *ethclient.Client, fromPrivateKey string, toAddress stri
}
// 9. (预估gas+基础费用)*1.1 作为 GasLimit
gasLimit = (gasLimit + 21000) * 12 / 10 // 增加 20%
gasLimit = (gasLimit + 21000) * 19 / 10 // 增加 90%
if gasLimit < 23000 {
gasLimit = 23000 // 最小 Gas 限制
}
@ -182,7 +182,7 @@ func TransferErc20Token(
}
// 9. (预估gas+基础费用)*1.1 作为 GasLimit
gasLimit = (gasLimit + 21000) * 12 / 10 // 增加 20%
gasLimit = (gasLimit + 21000) * 19 / 10 // 增加 90%
if gasLimit < 23000 {
gasLimit = 23000 // 最小 Gas 限制
}
@ -274,5 +274,5 @@ func IsValidAddress(address string) bool {
}
checksumAddress := common.HexToAddress(address).String()
return address == checksumAddress
return strings.EqualFold(address, checksumAddress)
}