Skip to content

Instantly share code, notes, and snippets.

@danikarik
Last active December 3, 2024 15:57
Show Gist options
  • Save danikarik/60b939ec26a80c6c4423cfe72f17c322 to your computer and use it in GitHub Desktop.
Save danikarik/60b939ec26a80c6c4423cfe72f17c322 to your computer and use it in GitHub Desktop.
ERC20 Smart Contract
// 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;
}
}
@danikarik
Copy link
Author

danikarik commented Dec 3, 2024

Deployment Example

  1. initialSupply - 1000000000000000000000000
  2. priceFeed - 0x694AA1769357215DE4FAC081bf1f309aDC325306 (ETH/USD)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment