0

i added some data in smart contract mapping on remix i am getting values but with web3 i am getting 0 values

 const escrowCount = await neutralG.methods.totlaEscrows().call()

  for (var i = 1; i <= escrowCount; i++) {
  const escrow = await neutralG.methods.escrows(i).call()
  console.log(escrow)
  this.setState({escrows: [...this.state.escrows, escrow]})
}

this is my code

enter image description here

remix values

enter image description here

and this is web3 values where i am wrong?

3
  • Where's your contract's code? You're wrong in for (var i = 1; i <= escrowCount; i++) for sure. Should be for (var i = 0; i < escrowCount; i++). Mar 2, 2020 at 9:53
  • Are you sure the contract which you interacting from web3 has data in mapping or both contract is the same that one in the remix and the one you are interacting with web3? Mar 2, 2020 at 9:57
  • i was wrong i have added mapping key with unique id and getting from count. now i have resolved it thankyou for your support Mar 2, 2020 at 10:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.