Last active
December 3, 2024 15:57
-
-
Save danikarik/60b939ec26a80c6c4423cfe72f17c322 to your computer and use it in GitHub Desktop.
ERC20 Smart Contract
This file contains hidden or 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.26; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; | |
contract ArysToken is ERC20 { | |
AggregatorV3Interface internal oracle; | |
constructor(uint256 initialSupply, address priceFeed) ERC20("ArysToken", "ARS") { | |
oracle = AggregatorV3Interface(priceFeed); | |
_mint(msg.sender, initialSupply); | |
} | |
function getLatestPrice() public view returns (int256) { | |
(, int256 price, , , ) = oracle.latestRoundData(); | |
return price; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Deployment Example
initialSupply
-1000000000000000000000000
priceFeed
-0x694AA1769357215DE4FAC081bf1f309aDC325306
(ETH/USD)