-1

Here is my simple contract I've wrote in Remix and deployed with web3 generated code on my private dev-network.

contract test{ function say_hi() returns(string) { return "Hi"; } } 

When I mined a little and run

test_sol_test

I get the following output:

{
  abi: [{
      constant: false,
      inputs: [],
      name: "say_hi",
      outputs: [{...}],
      payable: false,
      type: "function"
  }],
  address: "0x3dbe4378e0ec4839552d036a46f653d0aee2f2ac",
  transactionHash: "0xc57df09c7ee55c1bb45ee8dbee34cbf26a76e44402d6f4bb6512796b5db17bbc",
  allEvents: function(),
  say_hi: function()
}

When I call contract's function:

test_sol_test.say_hi()

I get the following output:

I0304 20:04:56.164980 internal/ethapi/api.go:1143] Tx(0x6d15e04db58c3fee5de1965884ca73420e82bdf45e0b6aed22afe7921f971938) to: 0x3dbe4378e0ec4839552d036a46f653d0aee2f2ac
"0x6d15e04db58c3fee5de1965884ca73420e82bdf45e0b6aed22afe7921f971938"

And when I'm trying to get info about transaction:

eth.getTransaction("0x6d15e04db58c3fee5de1965884ca73420e82bdf45e0b6aed22afe7921f971938")

{
  blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  blockNumber: null,
  from: "0xca9f9e8c2f482865c326718d5a33f80f8cc05cc0",
  gas: 90000,
  gasPrice: 20000000000,
  hash: "0x6d15e04db58c3fee5de1965884ca73420e82bdf45e0b6aed22afe7921f971938",
  input: "0x37bcda61",
  nonce: 24,
  r: "0x7bc50c0fb7322b4b0d44c15247e3e10d92818131b665ce4c5988de6185723df5",
  s: "0x2ca4763ab0d291e5c66a2be39f2d50b7a5fcc0e86fc4e9a4d2ed42b4ddf3dbf4",
  to: "0x3dbe4378e0ec4839552d036a46f653d0aee2f2ac",
  transactionIndex: 0,
  v: "0x1b",
  value: 0
} 

Value is 0, not HEX encoded "Hi".
Where am I wrong? How can I display that message?

shegeley
  • 1
  • 3

1 Answers1

1

at first galance while the blocknumber is null that's mean your transaction its pending so you need to mine it. besides, value is the value transferred in Wei not your function return.

Badr Bellaj
  • 18,780
  • 4
  • 58
  • 75
  • Probably I don't understand how transactions works. So how do I 'run' that transaction after it's mined? And see data field. Help me please – shegeley Mar 05 '17 at 06:49
  • i suggest you to read this discussion http://ethereum.stackexchange.com/questions/3514/how-to-call-a-contract-method-using-the-eth-call-json-rpc-api – Badr Bellaj Mar 05 '17 at 09:50
  • It works with const added to function as described in that link. But could you please explain why or give me good source to dig into this. – shegeley Mar 05 '17 at 15:37
  • const function didn't need to send a transaction or spend any gas it is the best to use while the function didn't change any states. so its like if you run it localy (in your client) not in the private chain – Badr Bellaj Mar 05 '17 at 16:58
  • Ok. How can I access data field of transaction on blockchain in case if that function in not const? – shegeley Mar 06 '17 at 15:55