erc1996i

    0

    0

    lucycodes42

    Solidity Code Snippets

    The IHoldable interface defines methods for holding ERC20 tokens. The hold() method takes an input of calldata containing the details of the operation to be performed, such as the operation ID and the address of the recipient, the notary, and the amount of tokens to be held (in wei) and the expiration time. The holdFrom() method takes the same inputs, but the data is to be sent to the address from. The releaseHold() and executeHold() methods release or execute the tokens held, respectively. The balanceOnHold(), netBalanceOf(), totalSupplyOnHold(), and authorizeHoldOperator() methods return the token's current balance or the total number of tokens in existence, respectively. The revokeHoldOperator() method removes the specified holder from the list of authorized holders. The isHoldOperatorFor() method returns true if the given address is an authorized holder for the given account.

    Shortcut: erc1996i_draft

    // https://eips.ethereum.org/EIPS/eip-1996
    // https://github.com/IoBuilders/holdable-token (example)
    // SPDX-License-Identifier: MIT
    /*
    An extension to the ERC-20 standard token that allows tokens to be put on hold.
    This guarantees a future transfer and makes the held tokens unavailable for transfer in the mean time.
    Holds are similar to escrows in that are firm and lead to final settlement.
    */
    pragma solidity >=0.5.0 <0.8.0;
    
    interface IHoldable /* is ERC-20 */ {
        enum HoldStatusCode {
            Nonexistent,
            Ordered,
            Executed,
            ReleasedByNotary,
            ReleasedByPayee,
            ReleasedOnExpiration
        }
    
        function hold(string calldata operationId, address to, address notary, uint256 value, uint256 timeToExpiration) external returns (bool);
        function holdFrom(string calldata operationId, address from, address to, address notary,
                                                         uint256 value, uint256 timeToExpiration) external returns (bool);
        function releaseHold(string calldata operationId) external returns (bool);
        function executeHold(string calldata operationId, uint256 value) external returns (bool);
        function renewHold(string calldata operationId, uint256 timeToExpiration) external returns (bool);
        function retrieveHoldData(string calldata operationId) external view returns (address from, address to, address notary,
                                                                                    uint256 value, uint256 expiration, HoldStatusCode status);
    
        function balanceOnHold(address account) external view returns (uint256);
        function netBalanceOf(address account) external view returns (uint256);
        function totalSupplyOnHold() external view returns (uint256);
    
        function authorizeHoldOperator(address operator) external returns (bool);
        function revokeHoldOperator(address operator) external returns (bool);
        function isHoldOperatorFor(address operator, address from) external view returns (bool);
    
        event HoldCreated(address indexed holdIssuer, string  operationId, address from,
                                    address to, address indexed notary, uint256 value, uint256 expiration);
        event HoldExecuted(address indexed holdIssuer, string operationId, address indexed notary, uint256 heldValue, uint256 transferredValue);
        event HoldReleased(address indexed holdIssuer, string operationId, HoldStatusCode status);
        event HoldRenewed(address indexed holdIssuer, string operationId, uint256 oldExpiration, uint256 newExpiration);
        event AuthorizedHoldOperator(address indexed operator, address indexed account);
        event RevokedHoldOperator(address indexed operator, address indexed account);
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.