First commit
This commit is contained in:
		
							
								
								
									
										19
									
								
								contracts/Migrations.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								contracts/Migrations.sol
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| // SPDX-License-Identifier: MIT | ||||
| pragma solidity >=0.4.22 <0.9.0; | ||||
|  | ||||
| contract Migrations { | ||||
|   address public owner = msg.sender; | ||||
|   uint public last_completed_migration; | ||||
|  | ||||
|   modifier restricted() { | ||||
|     require( | ||||
|       msg.sender == owner, | ||||
|       "This function is restricted to the contract's owner" | ||||
|     ); | ||||
|     _; | ||||
|   } | ||||
|  | ||||
|   function setCompleted(uint completed) public restricted { | ||||
|     last_completed_migration = completed; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										31
									
								
								contracts/SargaTrxUsdPrice.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								contracts/SargaTrxUsdPrice.sol
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| // SPDX-License-Identifier: MIT | ||||
| pragma solidity ^0.8.20; | ||||
|  | ||||
| import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; | ||||
|  | ||||
| contract SargaTrxUsdPrice { | ||||
|     AggregatorV3Interface internal _priceFeed; | ||||
|  | ||||
|     /** | ||||
|      * Network: Tron | ||||
|      * Aggregator: TRX/USD | ||||
|      * Address: TC6o8AakUg4Xz9nHY9qXpJNsgF7CQkwBqF | ||||
|      */ | ||||
|     constructor(address priceFeedAddress) { | ||||
|         _priceFeed = AggregatorV3Interface(priceFeedAddress); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the latest price | ||||
|      */ | ||||
|     function getLatestPrice() public view returns (int) { | ||||
|         ( | ||||
|             , | ||||
|             /* uint80 roundID */ int price /* uint startedAt */ /* uint timeStamp */ /* uint80 answeredInRound */, | ||||
|             , | ||||
|             , | ||||
|  | ||||
|         ) = _priceFeed.latestRoundData(); | ||||
|         return price; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user