msg.sender
Solidityपरिभाषा
msg.sender एक global variable है जो current function call करने वाले address को represent करता है। यह direct caller होता है - user या contract जो immediate call कर रहा है। Authentication और access control के लिए यह most commonly used variable है।
English version
msg.sender is a global variable that represents the address of the current function caller. It is the direct caller - the user or contract making the immediate call. It is the most commonly used variable for authentication and access control.
Code Example
contract Ownable {
address public owner;
constructor() {
owner = msg.sender; // Déployeur = owner
}
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
}संबंधित पेज
Solingo पर इस concept को practice करें
msg.sender को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें