1

Getting BigNumber Error .. tried almost everything

This is the web3js function call

creditPoints: function() {
var self = this;
alert("Credit Coins");

this.setStatus("Initiating transaction... (please wait)");
var meta;
MetaCoin.deployed().then(function(instance) {
  meta = instance;
  //alert("credit Points");
  alert(account);
  return meta.creditCoin( account, {from: account,gas: 300000});
}).then(function() {
  console.log("Transaction complete");
  self.setStatus("Transaction complete!");
 // self.refreshBalance();
}).catch(function(e) {
  console.log(e);
  self.setStatus("Error sending coin; see log.");
});
},

This is the contract function in solidity

 function creditCoin(address receiver) returns(bool sufficient) {
    uint amount;
    amount=100;
    if (balances[0xE208914454c16c7a2CD561071519bea9207Dda59] < amount) return false;
    balances[0xE208914454c16c7a2CD561071519bea9207Dda59] -= amount;
    balances[receiver] += amount;
    Transfer(0xE208914454c16c7a2CD561071519bea9207Dda59, receiver, amount);
    return true;
}

I am getting the BigNumber error when calling the above function

Error: new BigNumber() not a number: [object Object]
at raise (app.js:17546)
at app.js:17534
at new BigNumber (app.js:16561)
at new BigNumber (app.js:16571)
at toBigNumber (app.js:2719)
at Object.toTwosComplement (app.js:2730)
at SolidityTypeUInt.formatInputInt [as _inputFormatter] (app.js:3888)
at SolidityTypeUInt.SolidityType.encode (app.js:5111)
at app.js:21124
at Array.map (<anonymous>)
heypran
  • 126
  • 1
  • 11
  • I am using Nodejs 6.9.1 and npm 5.4.2 .. using solidity and truffle. – heypran Dec 20 '17 at 12:49
  • Read through the answers here, that should help: https://ethereum.stackexchange.com/questions/12876/getting-uncaught-error-new-bignumber-not-a-number-object-object – Michael Kohl Dec 20 '17 at 15:23
  • We have tried to test this link already. Nothing working. – Saurabh Dec 21 '17 at 07:21
  • The problem is not in the **solidity code** I guess. It is in javascript somewhere around promise part. The `bigNumber()` error comes from promises. – Pramesh Bajracharya Feb 09 '18 at 16:44
  • @Chessy did you solve the error? If yes, please answer how? You can be of great help. – Pramesh Bajracharya Feb 09 '18 at 17:05
  • Sorry I have been off the grid. I was using the function incorrect way. You have to make sure that you re not performing storing & fetching data in the same function. If that doesnt work try reinstalling the truffle stack – heypran Oct 12 '18 at 14:40

0 Answers0