-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirst_abi.go
36 lines (31 loc) · 889 Bytes
/
first_abi.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
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"math/big"
)
const (
MantleUrl = "https://explorer.testnet.mantle.xyz/"
myAddr = "0xF01Db8e37dE8C2F0c509721d4C63a5b5aa4D4021"
)
func main() {
cli, err := ethclient.Dial(MantleUrl)
if err != nil {
fmt.Printf("ethclient.Dial error: %s\n", err.Error())
}
chainid, err := cli.ChainID(context.Background())
if err != nil {
fmt.Printf("get cli.ChainID error: %s\n", err.Error())
}
fmt.Printf("get chainid %s", chainid)
addr := common.HexToAddress(myAddr)
blkNum := big.NewInt(24618854) // contract create
// get account's nonce at blkNum
nonce, err := cli.NonceAt(context.Background(), addr, blkNum)
if err != nil {
fmt.Printf("get nonce err: %s", err.Error())
}
fmt.Printf("get addr %s nonce %d at blknum %d", myAddr, nonce, blkNum)
}