Created
March 8, 2022 19:14
-
-
Save Aboudjem/245786e680fa42909a3ef829cede6c96 to your computer and use it in GitHub Desktop.
TestContract
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: Unlicensed | |
pragma solidity ^0.8.12; | |
contract TestContract { | |
uint public myUint = 111222333444555; | |
string private myString; | |
address public myAddress; | |
constructor(string memory _newString) { | |
myString = _newString; | |
myAddress = msg.sender; | |
} | |
function setMyUint(uint newUint) external { | |
require(newUint > myUint, "newUint must be higher than myUint"); | |
myUint = newUint; | |
} | |
function setMyString(string memory newString) external payable { | |
require(msg.value > 1000000, "You must pay 1,000,000 to set a new string"); | |
myString = newString; | |
} | |
function setMyAddress(address newAddress) external { | |
require(msg.sender == myAddress, "Only owner of the contract can set new Address"); | |
myAddress = newAddress; | |
} | |
function getMyUint() external view returns(uint) { | |
return myUint; | |
} | |
function getMyString() external view returns(string memory) { | |
return myString; | |
} | |
function getMyAddress() external view returns(address) { | |
return myAddress; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment