I am using openzeppelin, Ganache and truffle, here's a very simple smart contract for fundraising:

pragma solidity 0.4.24;

import 'openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol';

contract PrivateSale is Crowdsale {

  constructor(address wallet,
              ERC20 token,
              uint256 rate,
              Crowdsale(rate, wallet, token) {


After migrate this contract, I tried to send Ether from truffle console:

  from: web3.eth.accounts[2], 
  value: web3.toWei(10), 
  to: PrivateSale.address

But there's a exception here:

Error: VM Exception while processing transaction: revert
    at Eth.send [as sendTransaction] (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:145:1)
    at RequestManager.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:61:1)
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)

I also tried to transfer from account to account, it works fine, but only not work for contracts.

Here's how I deploy it:

const DemoToken = artifacts.require("DemoToken");
const PrivateSale = artifacts.require("PrivateSale");

module.exports = function(deployer) {
  const fundWallet = '0x629***'
  const rate = 1500

  • Is web3.eth.accounts[2] whitelisted? – user19510 Jun 8 '18 at 4:33
  • thanks, @smarx, I removed WhiteListedCrowsale, the problem still there. – WoooHaaaa Jun 8 '18 at 4:41
  • Is it after openingTime and before closingTime? What's softcap? There's a lot of code to read/debug here. I'd suggest simplifying the code as much as possible until it works (or the bug is obvious), and then build back up. – user19510 Jun 8 '18 at 4:45
  • @smarx, I tried to use the simplest Crowdsale, but the result is the same :/ – WoooHaaaa Jun 8 '18 at 4:52
  • What's the ERC20 token you're passing to the constructor? Have you transferred enough tokens to the Crowdsale contract to cover the purchase? (Maybe just show the rest of your code.) – user19510 Jun 8 '18 at 4:57

OK, silly mistake, it turns out I need to transfer my DemoToken to the contract first.

| improve this answer | |

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.