我想给几个账号按冻结比例分钱,可结果不对,问题出在哪里呢?

pragma solidity ^0.5.8 ;

import "./SafeMath.sol";

    contract dropping{
        using SafeMath for uint;

        mapping(uint256 => address) public NoToAddr;
        mapping(address => uint256) public AddTomount;
        mapping(address => uint256) public AddToDrop;
        uint256 public total;

        function testfor(address t1, address t2, address t3, uint256 mount_)public returns(uint256,uint256,uint256){
            NoToAddr[0] = t1;
            NoToAddr[1] = t2;
            NoToAddr[2] = t3;
            AddTomount[t1] = 10;
            AddTomount[t2] = 20;
            AddTomount[t3] = 30;
            total = 60;

            for(uint256 i = 0; i<=2; i++){

                AddToDrop[NoToAddr[i]] += (mount_.mul(AddTomount[NoToAddr[i]])).div(total);

            }

            return(AddToDrop[t1], AddToDrop[t2], AddToDrop[t3]);
        }
    }

{
    "0": "uint256: 300",
    "1": "uint256: 1200",
    "2": "uint256: 450"
}
请先 登录 后评论

1 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
  • 1 关注
  • 0 收藏,2541 浏览
  • 金浦哥哥 提出于 2020-11-26 18:54