Skip to content

abi: function overloading #13079

@olegrok

Description

@olegrok

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions