for some reason, i had to use python version of Ethereum implementation i.e PyEthApp. I am able to setup the local network and able mine the transactions. I was exeperimenting with contracts for my application. Here is the sample contract i was using for my learning

pragma solidity ^0.4.4;
contract Example {
    // Device Registry
    mapping (uint => string) public _registry;
    uint nIndex= 0; 
    function set_s(string new_s) {
        _registry[nIndex] = new_s;
        nIndex = nIndex + 1;
    function get_s(uint number) returns (string) {
        return _registry[number];

when i test this contract in remix, it is working fine... in the python shell, i have imported ethjsonrpc and checking the API methods

for storing data in to array,

 >>> tx = c.call_with_transaction(c.eth_coinbase(), contract_addr, 'set_s(string)', ['Dinesh'])

transaction submitted to miner, and after sometime it is mined successfully..

but i got struck with retrieving the data from mu contract array '_registry'.. i have tried to use call method directly,

>>> results = c.call(contract_addr, 'get_s(uint256)', [0], ['string'])

but it was giving

"AssertionError: Not enough data for head"

when i checked and googled it, people were saying transaction has to be mined. So i changed my command to

>>> tx = c.call_with_transaction(c.eth_coinbase(), contract_addr, 'get_s(uint256)', [0])

here also transaction submitted to miner, and it is mined eventually... But i could n't see the return value anywhere..

anyone got it worked? please let me know, if there is a workaround to call get methods with some return value

  • Have you tried marking the function constant as in function get_s(uint number) constant returns (string)? – eth Jun 7 '17 at 6:21
  • i have tried with constant function also ... :( – Dinesh Jun 7 '17 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.