4

I deploy a smart contract and it shows this error after I see it is created on testnet:

Warning! Error encountered during contract execution [Bad instruction] 

When I go to contract code tab, it is empty and just has a 0x there.

Almost like contract created but not completely.

Here is the transaction that created the contract:

https://testnet.etherscan.io/tx/0xaf1adfc8a995068e0f8eb02ad5fa4582244997e4d8b8284165bd18937d6371b9

Here is the constructor piece of the contract:

pragma solidity ^0.4.8;

contract RouteCoin {

    string public parentContracts;

    address private buyer;   

    address private seller;

    uint private contractStartTime;

    address private finalDestination;  

    uint private contractGracePeriod;

    function RouteCoin(address _finalDestination, uint _contractGracePeriod, string _parentContracts) {
        buyer = msg.sender;
        contractStartTime = now;        
        finalDestination = _finalDestination;
        contractGracePeriod = _contractGracePeriod;
        parentContracts = _parentContracts;
    }

Also when I use the Ethereum wallet i get this error: enter image description here

No data is deployed on the contract address!

And when i go to Etherscan i see this:

Warning! Error encountered during contract execution [Bad jump destination] 

https://testnet.etherscan.io/tx/0xadd8d2807cc9405ef317f664d86195464afcd62471dc890c9de69ac3a122f31d

Any ideas?

enter image description here

Aram
  • 375
  • 2
  • 13
  • Possible to post your contract code? Likely either constructor error or insufficient gas. – Rob Hitchens Feb 23 '17 at 19:05
  • @RobHitchens updated the question with the top section of the contract – Aram Feb 23 '17 at 19:09
  • Contract is valid. I would focus on the deployment method. There are multiple ways to do it, so hard to be specific. Recently, people have been having issues like this and they are getting good results by updating their wallets and/or Geth. For example, here: http://ethereum.stackexchange.com/questions/12386/mist-error-no-data-is-deployed-on-this-contract-address – Rob Hitchens Feb 23 '17 at 19:26
  • Thanks @RobHitchens .Yeah, I'm using Nethereum (.net) to deploy. and when I update the Geth version to latest it doesn't deploy at all. Also getting a different error trying to deploy with ethereum wallet 0.8.9 win 64. – Aram Feb 23 '17 at 19:35
  • @RobHitchens I get that "No data is deployed on this contract address" from the link you sent when using Ethereum wallet – Aram Feb 23 '17 at 19:40
  • Hmmm ... there has been another issue recently that sort of rhymes with this but I'm unsure it matters in Nethereum. Have a look here http://ethereum.stackexchange.com/questions/11912/unable-to-define-greetercontract-in-the-greeter-tutorial-breaking-change-in-sol. I'm just wondering if your compiler is sneaking in that unwanted . – Rob Hitchens Feb 23 '17 at 19:42
  • @RobHitchens Looks like this happens when i try to send Ethers to the contract when deploying it. this used to work before! Can i send Ethers to contract when deploying? – Aram Feb 23 '17 at 21:12
  • Oh wow. That's a (the?) problem. After solc 4.x if I recall correctly, you can't send Ether to any function unless the function is marked with the keyword payable. A constructor can be payable, but if it's not (it isn't), then sending Ether to it causes it to throw an error instead of executing as expected. – Rob Hitchens Feb 23 '17 at 21:15
  • @RobHitchens Yep, adding payable to constructor fixed the issue! – Aram Feb 23 '17 at 22:43
  • Hi @Aram - please add an answer with these details :-) (And then accept it.) – Richard Horrocks Feb 28 '17 at 20:20

1 Answers1

1

So with the help of @RobHitchens, turns out now after sol 4.x, if i want to send Ethers to a contract at the time of creating the contract, I should put payable to the constructor method (Just like any normal functions in the contract that transfers ethers)

So changed the contract constructor to look like this and works fine now:

function RouteCoin(address _finalDestination, uint _contractGracePeriod) 
payable
{
    buyer = msg.sender;
    contractStartTime = now;        
    finalDestination = _finalDestination;
    contractGracePeriod = _contractGracePeriod;
}
Aram
  • 375
  • 2
  • 13