-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (44 loc) · 1.47 KB
/
main.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"log"
"time"
)
func main() {
ctx, cancelCtx := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancelCtx()
{
bscClient, err := ethclient.Dial("https://bsc-dataseed.binance.org")
panicOnError(err, "could not dial bsc node")
bscTxHash := common.HexToHash("0xb72a06e15ccf3af1283d71f66abff02cdc4c023f673203f2c319538d96bdf50c")
bscTx, isPending, err := bscClient.TransactionByHash(ctx, bscTxHash)
panicOnError(err, "could not get bsc tx")
assert(!isPending, "bsc tx is pending")
log.Print("BSC:")
log.Printf("original tx hash: %s", bscTxHash.String())
log.Printf("tx hash from node: %s", bscTx.Hash().String())
}
{
meterClient, err := ethclient.Dial("https://rpc.meter.io")
panicOnError(err, "could not dial meter node")
meterTxHash := common.HexToHash("0x37656fc5eb232510cb47b2db7b90fe0763d6ebbc2ef0578409a6aac3ae24dcf5")
meterTx, isPending, err := meterClient.TransactionByHash(ctx, meterTxHash)
panicOnError(err, "could not get meter tx")
assert(!isPending, "meter tx is pending")
log.Print("Meter:")
log.Printf("original tx hash: %s", meterTxHash.String())
log.Printf("tx hash from node: %s", meterTx.Hash().String())
}
}
func panicOnError(err error, msg string) {
if err != nil {
log.Fatalf("%s: %+v", msg, err)
}
}
func assert(cond bool, msg string) {
if !cond {
log.Fatalf("assertion failed: %s", msg)
}
}