Description:
Smart contract deployed on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ACSPriceFeed {
int256 private currentPrice; // Store the price in ACS tokens per ETH
address private owner;
event PriceUpdated(int256 newPrice);
constructor() {
owner = msg.sender;
// Initialize with your current price (e.g., 200 ACS per ETH)
currentPrice = 200 * 10 ** 8; // 8 decimal places
}
modifier onlyOwner() {
require(msg.sender == owner, "Only owner can update");
_;
}
// Function to set the price (call by the owner/admin)
function setPrice(int256 _price) external onlyOwner {
require(_price > 0, "Price must be positive");
currentPrice = _price;
emit PriceUpdated(_price);
}
// Function to get the latest price
function getLatestPrice() external view returns (int256) {
return currentPrice;
}
// Optional: get decimals (8 for this example)
function decimals() external pure returns (uint8) {
return 8;
}
}
Submitted on: 2025-10-12 16:46:06
Comments
Log in to comment.
No comments yet.