JSON RPC error on Angular Truffle Box

by Edward Vlad   Last Updated October 09, 2019 15:28 PM

I use angular-truffle-box to create a dapp and when i tried to create a method getAge() and deploy the contract it shows me this error: Error: Returned error: {"id":12,"jsonrpc":"2.0","error":{"code":-32603}}

by default getBalance() works and my getAge() doesn't work

smart contract:

mapping (address => uint) nrs; mapping (address => uint) balances; constructor() public { balances[tx.origin] = 10000; nrs[tx.origin] = 99; } function getBalance(address addr) public view returns(uint) { return balances[addr]; } function getNumber(address addr) public view returns(uint) { return nrs[addr]; } and typescript component code:

async refreshBalance() {
console.log('Refreshing balance');

try {
  const deployedMetaCoin = await this.MetaCoin.deployed();
  console.log(deployedMetaCoin);
  console.log('Account', this.model.account);
  const metaCoinBalance = await deployedMetaCoin.getBalance(this.model.account);
  // const metaCoinName = await deployedMetaCoin.getName.call(this.model.account);
  console.log('Found balance: ' + metaCoinBalance);
  this.model.balance = metaCoinBalance;
  // console.log('Found name: ' + metaCoinName);
  // this.model.name = metaCoinName;
} catch (e) {
  console.log(e);
  this.setStatus('Error getting balance; see log.');
}

}

async getAge(){
    try {
      const deployedMetaCoin = await this.MetaCoin.deployed();
      console.log(deployedMetaCoin);
      console.log('Account', this.model.account);
      const metaCoinAge = await deployedMetaCoin.getNumber.call((this.model.account));
      // const metaCoinAge = 666;
      console.log('Found age: ' + metaCoinAge);
      this.model.age = metaCoinAge;
    } catch (e){
      console.log(e);
      this.setStatus('Error getting AGE; see log.');
    }
  }

What should i do? This is the box: https://www.trufflesuite.com/boxes/angular-truffle-box



Related Questions


How can I use web3.js with Angular 2

Updated June 24, 2017 14:28 PM

Getting Metamask account's balance using fromWei

Updated February 17, 2018 14:28 PM



Transfer ERC20 token using Web3 and angular

Updated July 28, 2018 01:28 AM