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?

  • 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++). – goodvibration Mar 2 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? – Mr. Sirja Mar 2 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 – Love Chawda Mar 2 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.