Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

contract.methods['functionName(address)'](address) is running method with string signature #6837

@TechnicallyWeb3

Description

@TechnicallyWeb3

Expected behavior

Expect contract.methods['functionName(address)'](address).call(); to call the method with the address signature.

Actual behavior

Call happens on the method with string signature instead.

Steps to reproduce the behavior

// in js file
async function getUserData(address) {
    return await userContract.methods['getUserData(address)'](address).call();
}

// in solidity file
function getUserData(address userAddress) public view returns (UserData memory) {
    return _userData[_idOfAddress[userAddress]];
}

function getUserData(string memory userName) public view returns (UserData memory) {
    return  _userData[_idOfName[userName]];
}
  1. load contract (live on sepolia testnet @ 0x6f380E5d68D7211f305976f86c66a22Ce17C3054)
  2. in a browser with the js loaded run "await getUserData('0xF174CC549e39545a44041bbf3Daf94E5b6DD7F54')" in console
  3. in a browser with the js loaded run "await getUserData('technicallywebdev')" in console
  4. expect first to log userData object, expect 2nd to fail with incorrect type.

Logs

output of step 2:
{0: 0n, 1: '0x0000000000000000000000000000000000000000', 2: '', 3: '', 4: '', 5: Array(0), __length__: 6, registrationDate: 0n, defaultAddress: '0x0000000000000000000000000000000000000000', userName: '', userBio: '', …}
output of step 3:
{0: 1709018832n, 1: '0xF174CC549e39545a44041bbf3Daf94E5b6DD7F54', 2: 'technicallydev', 3: 'Hello World!', 4: '/assets/images/logo.png', 5: Array(1), __length__: 6, registrationDate: 1709018832n, defaultAddress: '0xF174CC549e39545a44041bbf3Daf94E5b6DD7F54', userName: 'technicallydev', userBio: 'Hello World!', …}

Environment

run client-side via html import.
npm: 9.8.0, node: 18.6.1 web3 version: https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js
the full project is available on TechnicallyWeb3/technicallyweb3.com@2cddcb6

Metadata

Metadata

Labels

4.x4.0 related

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions