Selector (Function Selector)

EVM

परिभाषा

Function selector एक function signature के first 4 bytes हैं। यह function को uniquely identify करता है और EVM को बताता है कि कौन सा function call करना है। Selector को keccak256 hash से derive किया जाता है। Low-level calls और proxy patterns में selectors direct use होते हैं।

English version

Function selector is the first 4 bytes of a function signature. It uniquely identifies the function and tells the EVM which function to call. The selector is derived from the keccak256 hash. Selectors are directly used in low-level calls and proxy patterns.

Code Example

// Signature : "transfer(address,uint256)"
// Selector : 0xa9059cbb (4 premiers bytes du hash)

bytes4 selector = bytes4(keccak256("transfer(address,uint256)"));

// Appel avec selector
(bool success, ) = token.call(
    abi.encodeWithSelector(
        selector,
        recipient,
        amount
    )
);

संबंधित शब्द

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

Selector (Function Selector) को interactive exercises और integrated IDE के साथ master करें।

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