Hei guys, after reading the documentation about contracts i understood how to use contracts and also how to reuse them. But one thing that i dont understand is how i can list them like the "normal" accounts?

Thanks for the answers



  • linderpascallinderpascal Member Posts: 10
    To answer my question. I think there are two ways:
    Firstly you could build a database synchronous to the chain. In the db you put in the address plus the abi and if you want a name. So you have the opportunity to get the contracts by name or address.
    Last but not least there is a registrar which i builded in my private network.
    Code here:
    contract About { struct About { string _name; string _description; } About[] public aboutArray; function getLength() returns (uint256 _length) { _length=aboutArray.length; } function remove(uint256 _index) internal { delete aboutArray[_index]; } } contract RegistrarModel { function name(address _address) returns (string _name); event New(uint256 indexed statusCode, string message); } contract ContractRegistrarModel is About,RegistrarModel { function cont(string _name) returns (address _address,string _abi); } contract ContractRegistrar is ContractRegistrarModel { mapping (string => ContractStruct) mapContract; mapping (address => string) mapName; struct ContractStruct { address _address; string _abi; uint256 _index; } function registrar(string _name, address _address, string _abi, string _description) { if(mapContract[_name]._address!=0x0) { remove(mapContract[_name]._index); } mapContract[_name]=ContractStruct(_address,_abi,aboutArray.length); mapName[_address]=_name; aboutArray[aboutArray.length++]=About(_name,_description); New(1,"success"); } function name(address _address) returns(string _name) { _name=mapName[_address]; } function cont(string _name) returns(address _address, string _abi) { _address=mapContract[_name]._address; _abi=mapContract[_name]._abi; } }

    Its not the final verison. I have to implement a suicide function for saving storage.
Sign In or Register to comment.