Interface

Solidity

परिभाषा

Interface एक contract blueprint है जो केवल function signatures define करता है, implementation नहीं। Interfaces दूसरे contracts के साथ interact करने के लिए use होते हैं जब आपके पास पूरा code नहीं है। Interfaces किसी भी state variables या constructor नहीं रख सकते।

English version

Interface is a contract blueprint that only defines function signatures, not implementations. Interfaces are used to interact with other contracts when you don't have the full code. Interfaces cannot have any state variables or constructors.

Code Example

// Interface ERC20
interface IERC20 {
    function transfer(address to, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
}

// Utilisation de l'interface
contract MyContract {
    function sendTokens(address token, address to, uint256 amount) public {
        IERC20(token).transfer(to, amount);
    }
}

संबंधित शब्द

Solingo पर इस concept को practice करें

Interface को interactive exercises और integrated IDE के साथ master करें।

मुफ्त में शुरू करें