Getting total supply / volumes with Golang

Hey every one! I’m newbie with infura/blockchain etc.
Reading the docs Make requests - Infura Docs and trying to make requests and everything is ok but i have issues.

I know how to make request with golang, know how to get token totalSupply with web3 but… how i can get token totalSupply with golang? Is it possible?


const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider(''));

const tokenContract = "0xdac17f958d2ee523a2206206994597c13d831ec7"
const contract = new web3.eth.Contract(balanceOfABI, tokenContract)

async function getTokenBalance() {
    const result = await contract.methods.totalSupply().call();
    const formattedResult = web3.utils.fromWei(result, "ether");
    console.log(formattedResult, result);


Golang fail (Cannot get the totalSupply: The method totalSupply does not exist/is not available):

package main

import (


type Block struct {
	Number string

func main() {
	client, err := rpc.Dial("")
	if err != nil {
		log.Fatalf("Could not connect to Infura: %v", err)

	var lastBlock Block
	err = client.Call(&lastBlock, "totalSupply", "0xdac17f958d2ee523a2206206994597c13d831ec7", true)
	if err != nil {
		fmt.Println("Cannot get the totalSupply:", err)

	fmt.Printf("totalSupply: %v\n", lastBlock.Number)

So, how i can do it with golang and next question - can i get toke volume for UNISWAP i.e.?


Hey, this would be simply performing a JSON-RPC call, eg sending the totalSupply method to the API / node. You’ll need to call the contract, something similar to this example:

1 Like