Ownership Exploitation in Solidity

function (<parameter types>) {internal|external|public|private} [pure|constant|view|payable] [(modifiers)] [returns (<return types>)]

// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

contract PriceOracle{

uint256 public AssetPrice;

address owner;

constructor(uint256 _price){

AssetPrice=_price;

owner = msg.sender;

}

function upgradeAssetPrice(uint256 _price) external {

AssetPrice = _price;

}

}

contract SafePriceOracle{

uint256 public AssetPrice;
address owner;

constructor(uint256 _price){
AssetPrice=_price;
owner = msg.sender;
}

modifier CheckOwner(){
require(msg.sender == owner, “ No owner!”);
_;
}

function upgradeAssetPrice(uint256 _price) external CheckOwner {
AssetPrice = _price;
}

}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store