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

Contract response varies based on tx from value #2912

Closed
chaitanyapotti opened this issue Jun 26, 2019 · 4 comments
Closed

Contract response varies based on tx from value #2912

chaitanyapotti opened this issue Jun 26, 2019 · 4 comments
Labels
1.x 1.0 related issues 2.x 2.0 related issues Needs Clarification Requires additional input Stale Has not received enough activity

Comments

@chaitanyapotti
Copy link
Contributor

Description

Calling balances method in this contract
from an address which is an input, gives garbage results

Expected behavior

Should return correct wei balance

Actual behavior

gives garbage value

Steps to reproduce the behavior

const ABI = [{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"token","type":"address"}],"name":"tokenBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"users","type":"address[]"},{"name":"tokens","type":"address[]"}],"name":"balances","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"}]

const deployedContractAddress = '0xb1F8e55c7f64D203C1400B9D8555d050F94aDF39'
const addresses = ['0x6911207bb1B683014248E535889e79E648684b2B']
const ethContract = new web3.eth.Contract(ABI, deployedContractAddress)
const zeroAddress = [ZERO_ADDRESS]
ethContract.methods.balances(addresses, zeroAddress).call({ from: addresses[0] }, (error, result) => {
      if (error) {
        console.log(error)
      }
      addresses.forEach((address, index) => {
        const balance = result[index]
        console.log(balance)
      })
    })

Although, calling the same method using a different `from` address than the one in the `addresses` variable, gives the right results.

Error Logs

Gists

Versions

  • web3.js: 1.0.0-beta.35, 1.0.0-beta.37, 1.0.0-beta.55
  • nodejs: 10.16.0
  • browser: -
  • ethereum node: Infura
@nivida
Copy link
Contributor

nivida commented Jun 26, 2019

Thanks for opening this issue! Could you please add the returned values from this contract call?

@chaitanyapotti
Copy link
Contributor Author

chaitanyapotti commented Jun 26, 2019

@nivida Here is the requested information

result: ["115792089237316195423570985008687907853269984665631340667420729232106129639935"]

whereas the correct answer should be

result: ["98486156000000000"] (units: wei)

@nivida nivida added 1.x 1.0 related issues 2.x 2.0 related issues Needs Clarification Requires additional input and removed more information needed labels Oct 8, 2019
@nivida
Copy link
Contributor

nivida commented Oct 8, 2019

Thanks for providing the missing information. We will test and probably fix it asap.

@github-actions
Copy link

github-actions bot commented Jul 3, 2020

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment, otherwise this issue will be closed in 7 days

@github-actions github-actions bot added the Stale Has not received enough activity label Jul 3, 2020
This was referenced Mar 30, 2021
This was referenced Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues 2.x 2.0 related issues Needs Clarification Requires additional input Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

2 participants