I want develop a contract that can be interacted from outside with a considerably complex argument(like a string of struct), but the Ethereum seems that the contracts can only be communicated with functions using simple arguments like type uint, string, bytes, how can I manage it? I mean if I want to develop a function with arguments of a string of struct of unspecified length, how can I manage it?

Currently Solidity does not allow you to pass complex types as function arguments into or out of a smart contract. So currently you neither do

function setMyStruct (myStruct ms) { ... }

nor can you do

function getMyStruct constant returns (myStruct ms) { ... }

On work-around is to pass the elements of the struct one by one into the setter and return them one by one from the getter as in

contract testStruct {
    struct myStr {
        int a;
        string b;
    }
    myStr storedStr;

    function setMyStr(int a, string b) {
        storedStr.a = a;
        storedStr.b = b;
    }

    function getMyStr() constant returns (int a, string b) {
        a = storedStr.a;
        b = storedStr.b;
    }
}

Check also the following links to follow up on that:

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.