Closed huahuayu closed 3 years ago
for the uniswap StakingRewards contract, I have invoke it successfuly
But for tether token, abigen error: use --alias for renaming
I don't know how to solve it
Looks like the generated ABI has a totalSupply
method as well as a _totalSupply
method so the problem is the generator will pascal case the names and remove special characters so they both become normalized to TotalSupply
which creates an ambiguity conflict.
[
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"type": "function"
},
...
{
"constant": true,
"inputs": [],
"name": "_totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"type": "function"
},
]
The solution is to use the --alias
flag to change the name of one the ABI method names to something else so there's no conflict:
abigen --bin=bin/TetherToken.bin --abi=build/TetherToken.abi --pkg=usdt --out=usdt.go --alias _totalSupply=TotalSupply1
@miguelmota got it, thanks for the explain!
Hi, for all the example within the book, the contract is simple. What if the contract is a complex one(with many libraries and helper contract in it)?
Let's say, uniswap StakingRewards contract https://etherscan.io/address/0xCA35e32e7926b96A9988f61d510E038108d8068e#code
Can you demonstrate how to interact with it? Many
abi
andbin
file will generate, but specifically, I want interactive with the contractStakingRewards
.Also, I try to interact with TetherToken https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code
then I get an error