可靠性:智能合约总是会得到错误的结果

时间:2019-04-09 12:59:06

标签: solidity smartcontracts

我正在写一个令牌锁合约,根据钱包地址生成一个储物柜,代码如下:

    pragma solidity ^0.4.24;

    import "./TokenLocker.sol";

    contract TokenLockerFactory {
        address public creator;
        mapping(address => address) ownerLockers; // map owner-locker relation
        address[] private lockerList;

        function createLocker(address _owner, uint256 amount) public payable 
                returns(address locker) {
            locker = ownerLockers[_owner];

            if(locker == address(0)) {
                // Create new locker.
                locker = (new TokenLocker).value(amount)(msg.sender, _owner);
                ownerLockers[_owner] = locker;
                lockerList.push(locker);

                // Emit event.
                emit Created(locker, msg.sender, _owner);
            }
        }


        function getLocker(address _owner) public view returns(address) {
            return ownerLockers[_owner];
        }

        function getLockersNumber() public view returns(uint256) {
            return lockerList.length;
        }

    }

执行该合同时,我可以获得一个新生成的更衣室地址,但是当调用具有相关_owner地址的getLocker时,总是获得00000000000000000000,并且当检查lockList时以及当调用getLockersNumber时总是得到0,这真的很奇怪,任何人都可以帮助吗?

提前谢谢。

0 个答案:

没有答案