none
Blockchain workbench doesn't support getter functions (functions that return parameters)? RRS feed

  • Question

  • I have a problem with functions that in their signature has:
    public view returns(uint...). 
    While configuring them just like the other functions in the configuration json, I get an error like:

    "Add the getDeployedContracts function to the ContractCreator contract for the ContractCreator workflow. It currently doesn’t exist or has a different function signature with different parameter names, or without public/external visibility"

    I need these functions as I am planning to use the workbench API and would like to have some getters for my mappings and arrays.

    Thanks
    Thursday, January 31, 2019 4:26 PM

All replies

  • Hi,

    Please check this document Azure Blockchain Workbench configuration reference in the section about arrays it mentions the use of getter functions. Is it possible for you to share the configuration file?

    Regards,

    Alberto Vega

    Friday, February 1, 2019 12:14 AM
    Moderator
  • Sure, the background is that I have a contract that is used as a contract factory and of course the contracts that it creates.

    I receive the error in 2 cases:

    1)

    I would like to get a list of all the deployed contracts. I have this array:

    address[] public contrctsArray;

    and this is the getter function:

    function getDeployeContracts() public view returns (address[]) {
    return contrctsArray;

    }

    The configuration I use for this is:

    "Name": "getDeployedContracts",
    "DisplayName": "Get deployed contracts",
    "Description": "Get all deployed contract addresses",
    "Parameters": []

    2) In the second case, I would just like to get the contract properties so I have 2 functions. One is inside the contract instance itself where it calls its properties and the second is in the contract factory code where it just calls the contracts instance using its ID and then calls the internal getInformation function I just mentioned. I get errors in both of these functions.

    This is the signature of the function inside the contract instance:

    function getContractDetails() public view returns (uint, address[14], uint[8], string) {

    and the configuration for it is:

    "Name": "getContractDetails",
    "DisplayName": "Contract details getter",
    "Description": "Contract details getter",
    "Parameters": []

    and inside the factory contract the function is:

    function getContractById(uint contractId) public view returns (uint id, address[14] addressMembers, uint[8] uintMembers, string stringMembers) {
    return ContractInstance(contractsMapping[contractId]).getContractDetails();

    }


    and the configuration for it is:

    "Name": "getContractById",
    "DisplayName": "Get Contract by ID",
    "Description": "Get Contract by ID",
    "Parameters": [
    {
    "Name": "contractId",
    "Description": "Id of Contract",
    "DisplayName": "Id of Contract",
    "Type": {
    "Name": "int"
    }
    }
    ]

    Thanks! 


    • Edited by Hanibol Sunday, February 3, 2019 7:43 AM
    Sunday, February 3, 2019 7:40 AM
  • Hi, still waiting for an answer.

    Edited the code a bit, this doesn't work as well:

    address[] public contractAddresses;

    function getContractCount() public view returns(uint count) {
    return contractAddresses.length;
    }

    and in the json:

    {
    "Name": "getContractCount",
    "DisplayName": "Get the number of contracts",
    "Description": "Get the number of contracts",
    }

    I get the following error:

    • Add the getContractCount function to the ContractCreator contract for the ContractCreator workflow. It currently doesn’t exist or has a different function signature with different parameter names, or without public/external visibility

    Thanks

    Monday, February 11, 2019 12:39 PM
  • Hello,

    Is it possible to share the rest of the JSON file that you're developing?


    Microsoft Azure Blockchain Team

    Thursday, February 14, 2019 1:18 AM
    Owner