Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] #5

Closed
growupinv opened this issue Jun 20, 2022 · 6 comments
Closed

[question] #5

growupinv opened this issue Jun 20, 2022 · 6 comments

Comments

@growupinv
Copy link

growupinv commented Jun 20, 2022

hi, I'm trying to run the example,
I want to get the price of the token from the address, returns map[ts:[0]]

var TestAddresses = map[Chain]string{
	//Arbitrum:  "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
	//Aurora:    "0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79",
	//Avalanche: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
	//Bsc:       "0x7d99eda556388Ad7743A1B658b9C4FC67D7A9d74", 
	Ethereum: "0xB8c77482e45F1F44dE1745F52C74426C631bDD52", // for example need this one
	//Fantom:    "0xe1146b9AC456fCbB60644c36Fd3F868A9072fc6E",
	//Moonbeam:  "0xeFAeeE334F0Fd1712f9a8cc375f427D9Cdd40d73",
	//Moonriver: "0xE3F5a90F9cb311505cd691a46596599aA1A0AD7D",
}

func main() {
	fmt.Println("Hello")
	for chain, address := range TestAddresses {
		caller := NewContractBuilder().
			WithChainConfig(DefaultChainConfigs[chain]).
			AddMethod("function balanceOf(address)(uint256)")
		_, result, err := caller.AddCall("ts", address, "balanceOf", common.HexToAddress("0xea674fdde714fd979de3edf0f56aa9716b898ec8")).Call(nil)
		if err != nil {
			fmt.Printf("Error calling %s contract", string(chain))
		} else {
			fmt.Printf(`%v\n`, result)
			//fmt.Printf(`%v\n`, result["ts"][0].(*big.Int))
		}
	}

}

need help, what is wrong in the example?
as an argument, I passed the address where i want to see the balance

@himitsuko
Copy link
Member

Hi @growupinv

I want to get the price of the token from the address, returns map[ts:[0]]

Did you mean "I want to get the balance of the 0xB8c77482e45F1F44dE1745F52C74426C631bDD52 token from the 0xea674fdde714fd979de3edf0f56aa9716b898ec8 address, returns map[ts:[0]]"?

I can see your code in the issue did the following action:
You get the balance of BNB (0xB8c77482e45F1F44dE1745F52C74426C631bDD52) for the wallet at 0xea674fdde714fd979de3edf0f56aa9716b898ec8 on Ethereum right?

If so, that code does the right behavior, the balance is zero (0) at the comment's time.
You can confirm on etherscan in this link: https://etherscan.io/token/0xB8c77482e45F1F44dE1745F52C74426C631bDD52?a=0xea674fdde714fd979de3edf0f56aa9716b898ec8

And you can get the wallet balance with this statement: result["ts"][0].(*big.Int)

If you need to test for other wallet addresses, please take a look to test the balance with the list of the BNB holders on Ethereum at https://etherscan.io/token/0xB8c77482e45F1F44dE1745F52C74426C631bDD52#balances

@growupinv
Copy link
Author

growupinv commented Jun 20, 2022

I messed everything up myself, I thought that this (0xB8c77482e45F1F44dE1745F52C74426C631bDD52 ) was the address of the multical contract

oh, man thanks for help

@himitsuko
Copy link
Member

Oh, sorry for the messed up on the examples 🙏
I will write it more clearly in README.md

You can call the AddCall in a loop.
But take care when place it in a go routine, it is a not thread-safe library in this time 🙈. I also write down a note for it in #4

@himitsuko
Copy link
Member

@growupinv
Thanks for your question and don't forget to close the issue if the above answers is satisfy for you 🤗

@growupinv
Copy link
Author

ok, I wanted to ask something else, I will create a new question later, thank you

@himitsuko
Copy link
Member

You are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants