Created
September 4, 2023 22:27
-
-
Save EmaBord/18cc5c313bdf290cc0cbc18232e960ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract Example { | |
address public owner; | |
// Constructor para establecer el propietario como la dirección que despliega el contrato | |
constructor() { | |
owner = msg.sender; | |
} | |
// Modificador para restringir el acceso solo al propietario | |
modifier onlyOwner() { | |
require(msg.sender == owner, "Solo el propietario puede ejecutar esto"); | |
_; // Placeholder: aquí es donde se insertará el código de la función modificada | |
} | |
// Una variable de estado | |
uint256 public data; | |
// Función que solo puede ser llamada por el propietario debido al modificador | |
function setData(uint256 _data) public onlyOwner { | |
data = _data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment