I have a very basic contract to test out some functionality, but when I call the functions getContractAddress() and getThrowaway(), I get the invalid opcode error. I'm using truffle and testrpc, and I get the error after running some commands in truffle console (below).
Here is the full contract in question:
pragma solidity ^0.4.4;
import "./MetaCoin.sol";
contract Guess {
// Constructor, gives this contract 10k coins
function Guess(){
MetaCoin metaCoin = new MetaCoin(); //I think this should give the contract 10k coins
}
function getContractAddress() constant returns (address){
return this;
}
function getThrowaway() constant returns (string){
return "Hello";
}
}
And here are the commands I'm running in truffle console.
guess = Guess.deployed();
guess.then(function(instance){return instance.getThrowaway.call();})
Same problem when I run getContractAddress().
Here is the full repo for reference: https://github.com/willikers19/GuessTheEth
When I run commands in a similar fashion from this contract (https://github.com/willikers19/ethereum-demo-tools/blob/master/GeektSolidity/contracts/Geekt.sol), they succeed so it feels like I'm doing something wrong.
Best Answer
Try:
Hope it helps.