Описание изменений

This commit is contained in:
2025-02-19 20:22:29 +03:00
parent 7cb967138d
commit 6937079ec0
20 changed files with 777 additions and 3753 deletions

View File

@@ -3,9 +3,13 @@ pragma solidity ^0.8.0;
contract MyContract {
address public owner;
uint256 public price;
event Purchase(address buyer, uint256 amount);
constructor() {
owner = msg.sender;
price = 0.01 ether; // Начальная цена 0.01 ETH
}
modifier onlyOwner() {
@@ -17,4 +21,21 @@ contract MyContract {
require(newOwner != address(0), "New owner cannot be zero address");
owner = newOwner;
}
function setPrice(uint256 newPrice) public onlyOwner {
price = newPrice;
}
function getPrice() public view returns (uint256) {
return price;
}
function purchase(uint256 amount) public payable {
require(msg.value == price * amount, "Incorrect payment amount");
emit Purchase(msg.sender, amount);
}
function withdraw() public onlyOwner {
payable(owner).transfer(address(this).balance);
}
}