Contract Address Details

0x447c143620A4555c8aEb1596fb013ea84e7DbC03

Creator
0xb7971f–a51f91 at 0xffe109–260836
Balance
0 CLO ( )
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
15536678
Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB 0x6a56d0f7498c9f2aeb9bb6892ade5b2e0a50379f.
All metadata displayed below is from that contract. In order to verify current contract, click Verify & Publish button
Verify & Publish
Contract name:
MultisigWallet




Optimization enabled
true
Compiler version
v0.8.4+commit.c7e474f2




Optimization runs
200
Verified at
2022-06-09T14:56:25.121219Z

Contract source code

/**
 *Submitted for verification at BscScan.com on 2021-08-24
*/

// SPDX-License-Identifier: No License (None)
pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
 * (`UintSet`) are supported.
 */
library EnumerableSet {

    struct AddressSet {
        // Storage of set values
        address[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (address => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        if (!contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            address lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns 1-based index of value in the set. O(1).
     */
    function indexOf(AddressSet storage set, address value) internal view returns (uint256) {
        return set._indexes[value];
    }


    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }
}

contract MultisigWallet {
    using EnumerableSet for EnumerableSet.AddressSet;
    struct Ballot {
        uint128 votes;      // bitmap of unique votes (max 127 votes)
        uint64 expire;      // time when ballot expire
        uint8 yea;          // number of votes `Yea`
    }

    EnumerableSet.AddressSet owners; // founders may transfer contract's ownership
    uint256 public ownersSetCounter;   // each time when change owners increase the counter
    uint256 public expirePeriod = 3 days;
    mapping(bytes32 => Ballot) public ballots;
 
    event SetOwner(address owner, bool isEnable);
    event CreateBallot(bytes32 ballotHash, uint256 expired);
    event Execute(bytes32 ballotHash, address to, uint256 value, bytes data);


    modifier onlyThis() {
        require(address(this) == msg.sender, "Only multisig allowed");
        _;
    }
    
    constructor (address[] memory _owners) {
        for (uint i = 0; i < _owners.length; i++) {
            require(_owners[i] != address(0), "Zero address");
            owners.add(_owners[i]);
        }
    }

    // get number of owners
    function getOwnersNumber() external view returns(uint256) {
        return owners.length();
    }

    // returns list of owners addresses
    function getOwners() external view returns(address[] memory) {
        return owners._values;
    }

    // add owner
    function addOwner(address owner) external onlyThis{
        require(owner != address(0), "Zero address");
        require(owners.length() < 127, "Too many owners");
        require(owners.add(owner), "Owner already added");
        ownersSetCounter++; // change owners set
        emit SetOwner(owner, true);
    }

    // remove owner
    function removeOwner(address owner) external onlyThis{
        require(owners.length() > 1, "Remove all owners is not allowed");
        require(owners.remove(owner), "Owner does not exist");
        ownersSetCounter++; // change owners set
        emit SetOwner(owner, false);
    }
    
    function setExpirePeriod(uint256 period) external onlyThis {
        require(period >= 1 days, "Too short period");  // avoid deadlock in case of set too short period
        expirePeriod = period;
    }

    function vote(address to, uint256 value, bytes calldata data) external {
        uint256 index = owners.indexOf(msg.sender);
        require(index != 0, "Only owner");
        bytes32 ballotHash = keccak256(abi.encodePacked(to, value, data, ownersSetCounter));
        Ballot memory b = ballots[ballotHash];
        if (b.expire == 0 || b.expire < uint64(block.timestamp)) { // if no ballot or ballot expired - create new ballot
            b.expire = uint64(block.timestamp + expirePeriod);
            b.votes = 0;
            b.yea = 0;
            emit CreateBallot(ballotHash, b.expire);
        }
        uint256 mask = 1 << index;
        if (b.votes & mask == 0) {  // this owner don't vote yet.
            b.votes = uint128(b.votes | mask); // record owner's vote
            b.yea += 1; // increase total votes "Yea"
        }

        if (b.yea >= owners.length() / 2 + 1) {   // vote "Yea" > 50% of owners
            delete ballots[ballotHash];
            execute(to, value, data);
            emit Execute(ballotHash, to, value, data);
        } else {
            // update ballot
            ballots[ballotHash] = b;
        }
    }

    function execute(address to, uint256 value, bytes memory data) internal {
        (bool success,) = to.call{value: value}(data);
        require(success, "Execute error");
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address[]","name":"_owners","internalType":"address[]"}]},{"type":"event","name":"CreateBallot","inputs":[{"type":"bytes32","name":"ballotHash","internalType":"bytes32","indexed":false},{"type":"uint256","name":"expired","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Execute","inputs":[{"type":"bytes32","name":"ballotHash","internalType":"bytes32","indexed":false},{"type":"address","name":"to","internalType":"address","indexed":false},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"bytes","name":"data","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"SetOwner","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":false},{"type":"bool","name":"isEnable","internalType":"bool","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"votes","internalType":"uint128"},{"type":"uint64","name":"expire","internalType":"uint64"},{"type":"uint8","name":"yea","internalType":"uint8"}],"name":"ballots","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"expirePeriod","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getOwners","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getOwnersNumber","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"ownersSetCounter","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setExpirePeriod","inputs":[{"type":"uint256","name":"period","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"vote","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]}]
            

Deployed ByteCode

Verify & Publish
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80637dd0dd16116100665780637dd0dd16146100e55780638638fb5a1461015d57806386cbaed814610165578063a0e67e2b14610178578063d7a52fa91461018d57600080fd5b8063163d262f14610098578063173825d9146100b457806321407e53146100c95780637065cb48146100d2575b600080fd5b6100a160025481565b6040519081526020015b60405180910390f35b6100c76100c2366004610a5f565b6101a0565b005b6100a160035481565b6100c76100e0366004610a5f565b6102c9565b61012c6100f3366004610b02565b6004602052600090815260409020546001600160801b03811690600160801b810467ffffffffffffffff1690600160c01b900460ff1683565b604080516001600160801b03909416845267ffffffffffffffff909216602084015260ff16908201526060016100ab565b6000546100a1565b6100c7610173366004610a80565b610418565b6101806106f1565b6040516100ab9190610b87565b6100c761019b366004610b02565b610755565b3033146101c85760405162461bcd60e51b81526004016101bf90610c23565b60405180910390fd5b60016101d360005490565b116102205760405162461bcd60e51b815260206004820181905260248201527f52656d6f766520616c6c206f776e657273206973206e6f7420616c6c6f77656460448201526064016101bf565b61022b600082610833565b61026e5760405162461bcd60e51b815260206004820152601460248201527313dddb995c88191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016101bf565b6002805490600061027e83610cc6565b9091555050604080516001600160a01b0383168152600060208201527f5501576e82029b0850ec7c74ac25b5a46839bf523772a6ac579cc55b092281c891015b60405180910390a150565b3033146102e85760405162461bcd60e51b81526004016101bf90610c23565b6001600160a01b03811661032d5760405162461bcd60e51b815260206004820152600c60248201526b5a65726f206164647265737360a01b60448201526064016101bf565b607f61033860005490565b106103775760405162461bcd60e51b815260206004820152600f60248201526e546f6f206d616e79206f776e65727360881b60448201526064016101bf565b6103826000826107bf565b6103c45760405162461bcd60e51b815260206004820152601360248201527213dddb995c88185b1c9958591e481859191959606a1b60448201526064016101bf565b600280549060006103d483610cc6565b9091555050604080516001600160a01b0383168152600160208201527f5501576e82029b0850ec7c74ac25b5a46839bf523772a6ac579cc55b092281c891016102be565b33600090815260016020526040902054806104625760405162461bcd60e51b815260206004820152600a60248201526927b7363c9037bbb732b960b11b60448201526064016101bf565b60008585858560025460405160200161047f959493929190610b1a565b60408051808303601f190181528282528051602091820120600081815260048352839020606085018452546001600160801b0381168552600160801b810467ffffffffffffffff16928501839052600160c01b900460ff1692840192909252909250158061050457504267ffffffffffffffff16816020015167ffffffffffffffff16105b1561056e576003546105169042610c52565b67ffffffffffffffff16602082810182905260008084526040808501919091528051858152918201929092527fdba396e3f86ba92c12e944cda2d787eea52a24f6babcbd54c8ffb2d369bca7c9910160405180910390a15b80516001841b9081166001600160801b03166105b25781516001600160801b038083169116178252604082018051600191906105ab908390610c6a565b60ff169052505b60026105bd60005490565b6105c79190610c8f565b6105d2906001610c52565b826040015160ff16106106815760008381526004602090815260409182902080546001600160c81b03191690558151601f880182900482028101820190925286825261063d918a918a91908a908a908190840183828082843760009201919091525061099f92505050565b7fc75495e0be082158e5855c35d211235055bf668ec3933eb9f3cf757c6493ee6d8389898989604051610674959493929190610bd4565b60405180910390a16106e7565b60008381526004602090815260409182902084518154928601519386015160ff16600160c01b0260ff60c01b1967ffffffffffffffff909516600160801b026001600160c01b03199094166001600160801b039092169190911792909217929092161790555b5050505050505050565b60606000800180548060200260200160405190810160405280929190818152602001828054801561074b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161072d575b5050505050905090565b3033146107745760405162461bcd60e51b81526004016101bf90610c23565b620151808110156107ba5760405162461bcd60e51b815260206004820152601060248201526f151bdbc81cda1bdc9d081c195c9a5bd960821b60448201526064016101bf565b600355565b6001600160a01b038116600090815260018301602052604081205461082957508154600180820184556000848152602080822090930180546001600160a01b0319166001600160a01b0386169081179091558554908252828601909352604090209190915561082d565b5060005b92915050565b6001600160a01b03811660009081526001830160205260408120548015610995576000610861600183610caf565b855490915060009061087590600190610caf565b9050600086600001828154811061089c57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015487546001600160a01b03909116915081908890859081106108d957634e487b7160e01b600052603260045260246000fd5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905561090d836001610c52565b6001600160a01b0382166000908152600189016020526040902055865487908061094757634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038816825260018981019091526040822091909155945061082d9350505050565b600091505061082d565b6000836001600160a01b031683836040516109ba9190610b4e565b60006040518083038185875af1925050503d80600081146109f7576040519150601f19603f3d011682016040523d82523d6000602084013e6109fc565b606091505b5050905080610a3d5760405162461bcd60e51b815260206004820152600d60248201526c22bc32b1baba329032b93937b960991b60448201526064016101bf565b50505050565b80356001600160a01b0381168114610a5a57600080fd5b919050565b600060208284031215610a70578081fd5b610a7982610a43565b9392505050565b60008060008060608587031215610a95578283fd5b610a9e85610a43565b935060208501359250604085013567ffffffffffffffff80821115610ac1578384fd5b818701915087601f830112610ad4578384fd5b813581811115610ae2578485fd5b886020828501011115610af3578485fd5b95989497505060200194505050565b600060208284031215610b13578081fd5b5035919050565b6bffffffffffffffffffffffff198660601b1681528460148201528284603483013760349201918201526054019392505050565b60008251815b81811015610b6e5760208186018101518583015201610b54565b81811115610b7c5782828501525b509190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015610bc85783516001600160a01b031683529284019291840191600101610ba3565b50909695505050505050565b8581526001600160a01b0385166020820152604081018490526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b60208082526015908201527413db9b1e481b5d5b1d1a5cda59c8185b1b1bddd959605a1b604082015260600190565b60008219821115610c6557610c65610ce1565b500190565b600060ff821660ff84168060ff03821115610c8757610c87610ce1565b019392505050565b600082610caa57634e487b7160e01b81526012600452602481fd5b500490565b600082821015610cc157610cc1610ce1565b500390565b6000600019821415610cda57610cda610ce1565b5060010190565b634e487b7160e01b600052601160045260246000fdfea264697066735822122082cb06275be9280a5cfe5e4d64cb4b58193a6991cf85b6b847d8217513bfe06a64736f6c63430008040033