2

Warning! Error encountered during contract execution [Bad instruction]

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

https://ropsten.etherscan.io/address/0xa2ba735e2ff51fbaf9a3e12543bcd86be40e3a3d#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" } ] – Mangesh Yadav Aug 27 '17 at 18:43
1

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.

0

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, privacy policy and cookie policy

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