1

i have installed web3 latest version 1.0.0-beta.36. i am using helper libraries which i used from openzeppelin when i am running the test cases using truffle test it shows error as

TypeError: web3.toWei is not a function

it's not just web3.toWei also i am also not able to use bignumber .i don't know why i am not able to use helpers from openzeppelin this is the file with the name of ether.js in helper folder

function ether (n) {
  return new web3.BigNumber(web3.toWei(n, 'ether'));
}

module.exports = {
  ether,
};

and for big number the code which shows error is

require('chai')
  .use(require('chai-bignumber')(BigNumber))
  .should();

const RefundableCrowdsale = artifacts.require('RefundableCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyone]) {
  const rate = new BigNumber(1);
  const goal = ether(48);
  const lessThanGoal = ether(45);
  const tokenSupply = new BigNumber('1e22');

i have installed chai-bignumber and web3

  • 1
    Possible duplicate of Error: web3.toWei is not a function – shane Sep 21 '18 at 14:54
  • 1
    @shane i have tried but it's not just web3.toWei also i am not able to use bignumber .i don't know why i am not able to use helpers from openzeppelin or my own helpers for for converting to wei from ether .but am not able to use them. – AVATAR Sep 21 '18 at 15:04
  • It would help if yoy posted the code. This sounds like a JavaScript issue rather than web3 or Ethereum. – shane Sep 21 '18 at 15:05
  • @shane i have posted the code .check if there need to be any changes. i also wanna know it this the error in the new truffle beta version. – AVATAR Sep 21 '18 at 15:12
  • @shane thanks for everything i got the answer there is some error in the beta version of truffle 5.0.0-beta.0 so i changed the version to truffle 4.1.14. now all the test cases are running properly. – AVATAR Sep 21 '18 at 15:50
1

there is some error in the beta version of truffle 5.0.0-beta.0 so i changed the version to truffle 4.1.14. now all the test cases are running properly.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.