0

I'm trying to deploy the contract which does not use number to bignumber conversion itself. But I'm getting the following error about the code from node_modules:

Error: Error: [number-to-bn] while converting number "test" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported. Given value: "test"
at toBN (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3-utils\src\utils.js:64:1)
at Method.hexToNumber [as outputFormatter] (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3-utils\src\utils.js:234:1)
at Method.formatOutput (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3-core-method\src\index.js:163:1)
at sendTxCallback (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3-core-method\src\index.js:473:1)
at C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3-core-requestmanager\src\index.js:147:1
at C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\wrapper.js:112:1
at XMLHttpRequest.request.onreadystatechange (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3-providers-http\src\inbpack:\node_modules\web3-providers-http\src\index.js:96:1)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-rack:\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:1)
at XMLHttpRequest._setReadyState (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-request.js:modules\xhr2-cookies\dist\xml-http-request.js:208:1)
at XMLHttpRequest._onHttpResponseEnd (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-requestode_modules\xhr2-cookies\dist\xml-http-request.js:318:1)
at IncomingMessage.<anonymous> (C:\Users\giusha9\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-request.js:28dules\xhr2-cookies\dist\xml-http-request.js:289:47)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Truffle v5.1.15 (core: 5.1.15)
Node v10.16.0

This is my package.json file

{
  "name": "authcoin",
  "version": "1.0.0",
  "description": "Solidity Smart Contracts for Authcoin",
  "license": "MIT",
  "scripts": {
    "compile": "truffle compile",
    "build": "truffle build",
    "deploy": "truffle deploy",
    "postinstall": "truffle install",
    "console": "truffle console",
    "testrpc": "testrpc --gasLimit 60000000",
    "testrpc:coverage": "node_modules/.bin/testrpc-sc --port 8555",
    "truffle-test": "truffle test",
    "test": "run-p --aggregate-output --race testrpc truffle-test",
    "solidity-coverage": "node_modules/.bin/solidity-coverage",
    "coverage": "run-p --aggregate-output --race testrpc:coverage solidity-coverage",
    "lint": "node_modules/.bin/solium --dir ./contracts"
  },
  "devDependencies": {
    "concurrently": "^3.5.0",
    "ethereumjs-testrpc": "^6.0.3",
    "npm-run-all": "^4.1.1",
    "solidity-coverage": "^0.2.7",
    "solium": "^0.5.5",
    "ethereumjs-util": "^5.1.2"
  },
  "dependencies": {
    "chai": "^4.1.2",
    "truffle": "5.0.14"
  }
}

Truffle version returns the following:

$ truffle version
Truffle v5.1.15 (core: 5.1.15)
Solidity - 0.4.18 (solc-js)
Node v10.16.0
Web3.js v1.2.1

How can I solve this problem?

EDIT: This is constructor and the function used in constructor:

function AuthCoin() {
        registerSignatureVerifier(new DummyVerifier(), bytes32("test"));
    }


function registerSignatureVerifier(SignatureVerifier signatureVerifier, bytes32 eirType) onlyOwner public returns (bool) {
        if (address(signatureVerifiers[eirType]) == address(0)) {
            verifierIdList.push(eirType);
        }
        signatureVerifiers[eirType] = signatureVerifier;
        LogNewSignatureVerifier(signatureVerifier, eirType);
        return true;
    }

EDIT:

this is deployment code:

var AuthCoinContract = artifacts.require("./AuthCoin.sol");
var BytesUtils = artifacts.require("./utils/BytesUtils.sol");

module.exports = function (deployer) {
  deployer.deploy(BytesUtils);
  deployer.link(BytesUtils, AuthCoinContract);
  deployer.deploy(AuthCoinContract);
};
7
  • "contract which does not use number to bignumber conversion itself" - no contract does that. In contract code, there are only numbers (uint variables). Please share the relevant part of your contract code (i.e., the constructor), and the relevant part of your deployment code. Mar 2 '20 at 12:50
  • Are you sure that Truffle is configured to use solc 0.4.18? Mar 2 '20 at 13:56
  • Also, where is your deployment code? The error described in your question comes from there, not from the contract. Mar 2 '20 at 13:57
  • I have specified solc version for this prohect in truffle-config.js compilers: { solc: { version: "0.4.18", settings: { evmVersion: "constantinople" } }, }
    – GiorgiSh
    Mar 2 '20 at 14:40
  • Why do you link AuthCoinContract? Is that a library? Also, please add some printout before and after every line in your deployment script, in order to reveal which line throws the given error. Mar 2 '20 at 14:49

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.