Documentation
¶
Index ¶
- func AllNormalTxByAddress(client *etherscan.Client, endBlock *int, address common.Address) (txs []etherscan.NormalTx, err error)
- func AllNormalTxFromAddress(client *etherscan.Client, endBlock *int, address common.Address) (txs []etherscan.NormalTx, err error)
- func AllNormalTxToAddress(client *etherscan.Client, endBlock *int, address common.Address) (txs []etherscan.NormalTx, err error)
- func SumGasFees(txs []etherscan.NormalTx) (sum *big.Int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllNormalTxByAddress ¶
func AllNormalTxByAddress(client *etherscan.Client, endBlock *int, address common.Address) (txs []etherscan.NormalTx, err error)
AllNormalTxByAddress 获取指定地址的所有普通交易(Normal Transactions)。
该函数通过分页调用 Etherscan 的 NormalTxByAddress 接口,遍历从区块 0 到指定的 endBlock(如果为 nil 则默认为 latest)的交易记录, 自动处理分页并累计结果,返回所有与该地址相关的正常交易(仅包含该地址发出的交易记录)。
注意事项:
- 每次请求最多获取 offset 条交易,默认设置为 1000;
- 函数使用 tx.BlockNumber 控制分页进度;
- 如果请求返回的交易数量少于 offset,说明已到达末尾,终止循环。
参数:
- client: 已初始化的 Etherscan 客户端对象
- endBlock: 指定查询的结束区块号(若为 nil 则查询至最新区块)
- address: 需要查询的以太坊地址(建议使用 EIP-55 格式)
返回值:
- txs: 包含所有查询结果的 NormalTx 列表
- err: 查询过程中发生的错误
文档地址:
func AllNormalTxFromAddress ¶
func AllNormalTxToAddress ¶
func SumGasFees ¶
SumGasFees 计算一组以太坊交易的总 Gas 费用(总手续费)。
对于每一笔交易,费用按公式:GasPrice × GasUsed 计算, 所有交易费用将累加为最终总费用,单位为 Wei(以太坊最小单位)。
参数:
txs - etherscan.NormalTx 类型的交易列表,每笔交易应包含有效的 GasPrice 和 GasUsed 值。
返回值:
sum - 所有交易总费用之和,类型为 *big.Int,单位为 Wei。
注意:此函数使用 big.Int 处理任意精度运算,避免了整数溢出。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.