2
contract MyContract {
struct Posposal{
    uint posposalId;//防止复核数组变动时
    address voteSponsorAddr;//投票发起人

    bytes1 description_;//投票内容信息  0 转币  以后扩展
    uint userId;//投票给目标以太币地址所对应的id
    uint amount;//转多少代币
}
Posposal[] public curPosposals; //当前提议投票记录
uint public posposalNextId=0;// 标识投票建议递增  

function MyContract() {

}
uint public expId;
address public expTarget;
uint public expAmount;
function issuse(uint userId,address target_,uint amount_)  {
    //投票目标用户肯定是存在的
    expId=userId;
    expAmount=amount_;
    expTarget=target_;
    curPosposals.push(Posposal(posposalNextId,msg.sender,0x01,userId,amount_));//0 未投票 默认情况  1支持票 -1 反对
    posposalNextId++;
}}

Why the curPosposals[0] is wrong? But when I move bytes1 description_; to the end of struct Posposal, all are designed answer. Why? Following :

invoke function and pass params: enter image description here

the result:

enter image description here

expId=2 (right); and curPosposalId[0].userId should be 2, curPosposalId[0].amount should be 20000, but they are wrong. Why?

  • How are you fetching curPosposals[0]? – Edmund Edgar Sep 7 '16 at 4:17
  • I could fetching by the ethereum wallet(mist), the result before.When I type 0, the User id(0) and Amount(512) are wrong, but actually 1, 20000 are right。 – Jim Green Sep 7 '16 at 6:26
  • It is working fine on solidity browser. – Aniket Sep 8 '16 at 13:27

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.