Warning! Error encountered during contract execution [Bad instruction]

Here's the solidity code. Can anyone please help me find the problem in the code?


Remix doesn't give any error while creating contract. The contract is deployed without any problem. When I try to send ether to get tokens it displays the error; Warning! Error encountered during contract execution [Bad instruction]

  • Error details: { "action": { "from": "xxx", "gas": "0x118992", "init": "", "value": "0x0" }, "blockHash": "xxx", "blockNumber": 1562346, "result": { "address": "xxx", "code": "xxx", "gasUsed": "0x118991" }, "subtraces": 0, "traceAddress": [], "transactionHash": "xxx", "transactionPosition": 3, "type": "create" } ] Commented Aug 27, 2017 at 18:43

2 Answers 2


Looking at your transactions and code, you are calling the fallback function function () but your contract SampleCrowdsaleToken does not have one. Your contract is Mintable, StandardToken, BasicToken, ERC20Basic, ERC20 (twice, because BasicToken is already a ERC20) and Ownable, but the only fallback function in your code is inside the Crowdsale contract.


You deployed wrong contract. SimpleCrowdsaleToken contract you are trying to buy tokens from is not a crowdsale contract, but rather a token contact. You need to write another contract that inherits from Crowdsale and overrides createTokenContract method like this:

contract SMTCrowdsale is Crowdsale {
  function SMTCrowdsale (uint256 _startTime, uint256 _endTime, utin256 _rate, address _wallet) Crowdsale (_startTime, _endTime, _rate, _wallet) {

  function createTokenContract () internal returns (MintableToken) {
    return new SimpleCrowdsaleToken ();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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