-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (53 loc) · 1.43 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
55
56
57
58
59
60
61
package main
import (
"context"
"fmt"
"math/big"
"os"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
mc "github.com/radchukd/multicall-go/src"
)
func main() {
calls := []mc.Call{
{
Address: common.HexToAddress("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"),
Name: "ownerOf(uint256)",
Params: []abi.Type{mc.Uint256},
Values: []any{big.NewInt(6834)},
Output: mc.Address,
},
{
Address: common.HexToAddress("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"),
Name: "name()",
Output: mc.String,
},
{
Address: common.HexToAddress("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"),
Name: "totalSupply()",
Output: mc.Uint256,
},
{
Address: common.HexToAddress("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"),
Name: "balanceOf(address)",
Params: []abi.Type{mc.Address},
Values: []any{common.HexToAddress("0xf4893542E4ec7C33356579F91bF22E8FA7CD06dc")},
Output: mc.Uint256,
},
}
ctx := context.Background()
rpcURL := os.Getenv("RPC_URL")
client, _ := ethclient.DialContext(ctx, rpcURL)
mcAddressMainnet := "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696"
mc.Init(ctx, client, mcAddressMainnet)
blockNumber, err := mc.MultiCall(&calls)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Results for block #%s:\n", blockNumber.String())
for _, call := range calls {
fmt.Println(call)
}
}