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

abi: function overloading #13079

Open
olegrok opened this issue Dec 11, 2024 · 0 comments
Open

abi: function overloading #13079

olegrok opened this issue Dec 11, 2024 · 0 comments

Comments

@olegrok
Copy link

olegrok commented Dec 11, 2024

Imagine I have following contract:

pragma solidity ^0.8.0;

contract IncrementerExtended {
    uint256 private value;

    constructor(uint256 initialValue) {
        value = initialValue;
    }

    function increment() public {
        value += 1;
    }

    function increment(uint256 amount) public {
        value += amount;
    }

    receive() external payable {}

    function get() public view returns(uint256) {
        return value;
    }
}

How can I work with both "increment" methods from Go abi module.
If I try to call abi.Pack("increment") without any arguments it returns an error. And it works for abi.Pack("increment", big.NewInt(5)).

From the code I see that methods are stored in a map. And only one element can have "increment" name:

method, exist := abi.Methods[name]

Is it a bug or feature? How should we work with such functions?

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

1 participant