-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
is there a way to callStatic func like in ethers js? #26254
Comments
i can call this func on ethers js using callstatic and it return the result i need
|
While we don't have this feature right now, there is a workaround: encode the call yourself, submit using |
Thanks @fjl, its works using GeneratedCode : // Solidity: function collect((uint256,address,uint128,uint128) params) payable returns(uint256 amount0, uint256 amount1)
func (_UNISWAPv3 *UNISWAPv3Transactor) Collect(opts *bind.TransactOpts, params INonfungiblePositionManagerCollectParams) (*types.Transaction, error) {
return _UNISWAPv3.contract.Transact(opts, "collect", params)
} Updated Code using CallContract : // Solidity: function collect((uint256,address,uint128,uint128) params) payable returns(uint256 amount0, uint256 amount1)
func (_UNISWAPv3 *UNISWAPv3Transactor) Collect(opts *bind.CallOpts, params INonfungiblePositionManagerCollectParams) (*big.Int, *big.Int, error) {
var out []interface{}
err := _UNISWAPv3.contract.Call(opts, &out, "collect", params)
if err != nil {
return new(big.Int), new(big.Int), err
}
out0 := *abi.ConvertType(out[0], new(big.Int)).(*big.Int)
out1 := *abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return &out0, &out1, err
} |
This becomes possible via #26782 |
Just stumbled across this, thanks so much @jonathantyar for your example. It feels like this is an area where abigen is a little inflexible compared to the competition. Are there any plans to address this? Perhaps using the pull I see s1na has posted? |
One workaround here is that you can modify the abi file that is used for abigen to update the state mutability of the function you want to call. For example, I'm running into a similar issue with multicall since the functions are payable. Since I don't need to update the blockchain state, I just modified the stateMutability from |
This method is both good and simple. |
just try out go-ethereum its worked great so far. but had problem when trying to call static func like in ether js. using transactionOpt to not send the transaction. the command is worked, but abigen only return transacction and error where it should send another value. How to get the value i need on these transaction.
this is how i call to contract func, with nosend and signer params
this is generated code from abigen, it shows comment that a func should return 3 values, but instead abigen generated just 2 values
The text was updated successfully, but these errors were encountered: