multicall-client

module
v0.0.0-...-d770b7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2023 License: MIT

README

multicall-client

A wrapper for Multicall that allows you to make batched calls to the blockchain.

Usage
// Create a new multicall client
client, err := multicall.New(multicall.CronosMainnet, multicall.V1, ethClient)
if err != nil {
	panic(err)
}

calls := []*multicall.MethodCall{
    // dead address balance of token
    multicall.NewMethodCall("0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23", ERC20Abi.Methods["balanceOf"], "0x000000000000000000000000000000000000dead"),
	// name of token
    multicall.NewMethodCall("0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23", ERC20Abi.Methods["name"]),
}

blockNumber, results, err := client.Aggregate(nil, calls)
if err != nil {
	panic(err)
}

balance := results[0].(*big.Int)
name := results[1].(string)
fmt.Printf("Balance of %s in dead address: %s\n", name, balance.String())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL