Skip to main content
replaced http://ethereum.stackexchange.com/ with https://ethereum.stackexchange.com/
Source Link
Improvement
Source Link
BokkyPooBah
  • 40.4k
  • 14
  • 123
  • 193

Your code is working perfectly on testnet. Check your deployment processstatement, in particular your myescrow.start.sendTransaction(...) statement.

Your code is working perfectly on testnet. Check your deployment process.

Your code is working perfectly on testnet. Check your deployment statement, in particular your myescrow.start.sendTransaction(...) statement.

Source Link
BokkyPooBah
  • 40.4k
  • 14
  • 123
  • 193

Work perfectly on testnet.

I'm using the stripCrLf script at How to load Solidity source file into geth.

Here's your code, slightly tidied, saved into MyEscrow.sol :

pragma solidity 0.4.2;

contract Mortal {
    address owner;

    function Mortal() { owner = msg.sender; }

    function kill() { if (msg.sender == owner) suicide(owner); }
}

contract MyEscrow is Mortal {
    uint numEscrows;

    function queryNumEscrows() constant returns (uint) {
        return numEscrows;
    }

    function start() returns (uint) {
        numEscrows++;
        return numEscrows;
    }
}

I ran the following command to flatten your code:

user@Kumquat:~/ESE/Escrow$ echo "var myEscrowSource='`stripCrLf MyEscrow.sol`'"
var myEscrowSource='pragma solidity 0.4.2;contract Mortal { address owner; function Mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); }}contract MyEscrow is Mortal { uint numEscrows; function queryNumEscrows() constant returns (uint) { return numEscrows; } function start() returns (uint) { numEscrows++; return numEscrows; }}'

I executed the following code in my geth --cache=1024 --testnet console command line:

> var myEscrowSource='pragma solidity 0.4.2;contract Mortal { address owner; function Mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); }}contract MyEscrow is Mortal { uint numEscrows; function queryNumEscrows() constant returns (uint) { return numEscrows; } function start() returns (uint) { numEscrows++; return numEscrows; }}'
undefined
> var myEscrowCompiled = web3.eth.compile.solidity(myEscrowSource);
undefined
> personal.unlockAccount(eth.accounts[0], "MyVerySecretPasswordNumber1");
true
> var myEscrowContract = web3.eth.contract(myEscrowCompiled.MyEscrow.info.abiDefinition);
undefined
> var myEscrow = myEscrowContract.new({from:web3.eth.accounts[0], data: myEscrowCompiled.MyEscrow.code, gas: 1000000}, 
  function(e, contract) {
    if (!e) {
      if (!contract.address) {
        console.log("Contract transaction send: TransactionHash: " + 
          contract.transactionHash + " waiting to be mined...");
      } else {
        console.log("Contract mined! Address: " + contract.address);
        console.log(contract);
      }
    }
  }
)
Contract mined! Address: 0x3fd50995536919085c28fdf9e07a03bad955cc33

myEscrow.start(eth.accounts[0], {
  from:web3.eth.accounts[0], 
  data: myEscrowCompiled.MyEscrow.code,
  gas: 1000000
});
"0x0b2ec2ee98b21214cca5be9294f3c019239d3d90f6e23c03a3eb7d6fcc8c1c29"
> myEscrow.queryNumEscrows()
1

Your code is working perfectly on testnet. Check your deployment process.