为 Azure 区块链部署智能合约时出错 Workbench

Error on deploying Smart Contract for Azure Blockchain Workbench

我一直在 Azure 区块链上构建一个投票应用程序 Workbench。 我在上传智能合约文件时不断遇到错误,构造函数和函数不是 present.The 配置文件通过了他们的检查。请帮助解决错误。

这来自智能合约文件:

pragma solidity >= 0.4.0 <0.6.0;

contract Voting{
    enum StateType{
      Creation,
      Voting,
      BallotFinish
    }
    StateType public State;
    mapping(bytes32 => uint256) public votesCount;
    address public admin;
    bytes32[] public candidatesList;
    bytes32[] public voterList;
    constructor(bytes32[] memory candidateNames,bytes32[] memory voterNames) public{
        State = StateType.Creation;
        admin = msg.sender;
        candidatesList = candidateNames;
        voterList = voterNames;
    }
    function totalVotesFor(bytes32 candidate) public view returns (uint256)
    {
        require(validCandidate(candidate));
        return votesCount[candidate];
    }
    function voteForCandidate(bytes32 voter,bytes32 candidate) public {
        if(admin == msg.sender)
        {
            revert();
        }
        if(State == StateType.Voting)
        {
            require(validVoter(voter));
            require(validCandidate(candidate));
            votesCount[candidate] += 1;
        }
        else
        {
            revert();
        }
    }
    function validVoter(bytes32 voter) public view returns (bool) {
        for(uint i=0;i<voterList.length;i++)
        {
            if(voterList[i]==voter)
                return true;
        }
        return false;
    }
    function validCandidate(bytes32 candidate) public view returns (bool) {
        for(uint i=0 ; i < candidatesList.length ; i++)
        {
            if(candidatesList[i]==candidate)
                return true;
        }
        return false;
    }
}

这是配置文件:

{
    "ApplicationName": "Voting",
    "DisplayName": "Voting",
    "Description": "Test Voting App",
    "ApplicationRoles": [
      {
        "Name": "Admin",
        "Description": "Person who generates Candidate and Voter Lists"
      },
      {
        "Name": "Voter",
        "Description": "A person who votes"
      }
    ],
    "Workflows": [
      {
        "Name": "Voting",
        "DisplayName": "Vote Here",
        "Description": "A simple way to vote.",
        "Initiators": [ "Admin" ],
        "StartState": "Creation",
        "Properties": [
          {
            "Name": "State",
            "DisplayName": "State",
            "Description": "Holds the state of the contract.",
            "Type": {
              "Name": "state"
            }
          }
        ],
        "Constructor": {
          "Parameters": [
            {
              "Name": "candidateNames",
              "Description": "List of names of candidates",
              "DisplayName": "ListOfCandidates",
              "Type":
              {
                  "Name": "array",
                  "ElementType": {
                      "Name": "string"
                  }
              }
            },
            {
              "Name": "voterNames",
              "Description": "List of names of voters",
              "DisplayName": "ListOfVoters",
              "Type":{
                "Name": "array",
                "ElementType": {
                  "Name": "string"
                }
              }
            }
          ]
        },
        "Functions": [
          {
            "Name": "totalVotesFor",
            "DisplayName": "Get Votes for a Candidate",
            "Description": "...",
            "Parameters": [
              {
                "Name": "candidate",
                "Description": "...",
                "DisplayName": "Name of Candidate",
                "Type": {
                  "Name": "string"
                }
              }
            ]
          },
          {
            "Name": "voteForCandidate",
            "DisplayName": "Vote Function",
            "Description": "...",
            "Parameters": [
              {
                "Name": "voter",
                "Description": "...",
                "DisplayName": "Name of Voter",
                "Type": {
                  "Name": "string"
                }
              },
              {
                "Name": "candidate",
                "Description": "...",
                "DisplayName": "Name of Candidate",
                "Type": {
                  "Name": "string"
                }
              }
            ]
          }
        ],
        "States": [
          {
            "Name": "Creation",
            "DisplayName": "Ballot Creation",
            "Description": "...",
            "PercentComplete": 20,
            "Style": "Success",
            "Transitions": [
              {
                "AllowedRoles": ["Voter"],
                "AllowedInstanceRoles": [],
                "Description": "...",
                "Function": "voteForCandidate",
                "NextStates": [ "Voting" ],
                "DisplayName": "Give Vote"
              },
              {
                "AllowedRoles": ["Voter"],
                "AllowedInstanceRoles": [],
                "Description": "...",
                "Function": "totalVotesFor",
                "NextStates": [ "Voting" ],
                "DisplayName": "Get No of Votes"
              }
            ]
          },
          {
            "Name": "Voting",
            "DisplayName": "Voting Stage",
            "Description": "...",
            "PercentComplete": 20,
            "Style": "Success",
            "Transitions": [
              {
                "AllowedRoles": ["Voter"],
                "AllowedInstanceRoles": [],
                "Description": "...",
                "Function": "totalVotesFor",
                "NextStates": [ "Voting" ],
                "DisplayName": "Vote for a Candidate"
              }
            ]
          },
          {
            "Name": "BallotFinish",
            "DisplayName": "Voting Finished",
            "Description": "...",
            "PercentComplete": 100,
            "Style": "Success",
            "Transitions": []
          }
        ]
      }
    ]
  }

您的 sol 文件需要包含 json 文件中指定的合约构造函数。

我认为您需要将 byte32 更改为字符串并使用 StringUtil 进行字符串比较