-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
33 lines (28 loc) · 803 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func GetContractAddress(client *ethclient.Client, txid common.Hash) string {
receipt_tx, err := client.TransactionReceipt(context.Background(), txid)
if err != nil {
return ""
}
return receipt_tx.ContractAddress.Hex()
}
func GetRealGasUsed(client *ethclient.Client, txid common.Hash) uint64 {
receipt_tx, err := client.TransactionReceipt(context.Background(), txid)
if err != nil {
return 0
}
return receipt_tx.GasUsed
}
func GetRealGasPrice(baseFee uint64, maxFeeCap uint64, maxTipCap uint64) *big.Int {
if baseFee+maxTipCap > maxFeeCap {
return new(big.Int).SetUint64(maxFeeCap)
} else {
return new(big.Int).SetUint64(baseFee + maxTipCap)
}
}