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.

Problem with decoding complex types returned from contract function #2607

@adammalczewski

Description

@adammalczewski

Description

I am trying to call a method from blockchain contract which returns single value of type tuple[]:

    const web3 = new Web3(ProviderAddress);
    const contract = new web3.eth.Contract(Web3ContractABI, ContractAddress);
    const users = await contract.methods.getAllUsers().call();

part of ABI JSON regarding getAllUsers function:

  {
    'constant': true,
    'inputs': [],
    'name': 'getAllUsers',
    'outputs': [
      {
        'components': [
          {
            'name': 'idUser',
            'type': 'address'
          },
          {
            'name': 'param1',
            'type': 'int256'
          },
          {
            'name': 'param2',
            'type': 'int256'
          }
        ],
        'name': '',
        'type': 'tuple[]'
      }
    ],
    'payable': false,
    'stateMutability': 'view',
    'type': 'function'
  },

on remix.ethereum.org when i call the function i get:

0: tuple(address,int256,int256)[]: 0xf2D38fC631d4FCFbAeDB274D2b95C436ab75a1B4,0,0

Expected behavior

users should be [["0xf2D38fC631d4FCFbAeDB274D2b95C436ab75a1B4", ...]]

Actual behavior

users is [[]]

Additional notes

I have already found the source of this error, will create PR soon.

Versions

  • web3.js: 1.0.0-beta.51
  • nodejs: 10.14.2
  • ethereum node - instance: Geth/v1.8.16-stable-477eb093/linux-amd64/go1.11, private network

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAddressing a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions