From 2b4d5c2652dfb30eeebc8a3c62e22a3d871eb379 Mon Sep 17 00:00:00 2001 From: Bahaa Ehab El Dien Abdelmawla <91119772+ArDapps@users.noreply.github.com> Date: Sun, 5 Dec 2021 08:08:58 +0200 Subject: [PATCH] add files --- contracts...Car.sol | 55 +++++++++++++ contracts...DonateContract.sol | 46 +++++++++++ contracts...InterfacePayMethods.sol | 21 +++++ contracts...IpaymentMethods.sol | 8 ++ contracts...Lottery.sol | 33 ++++++++ contracts...Main.sol | 15 ++++ contracts...Name.sol | 6 ++ contracts...Overloading.sol | 22 ++++++ contracts...Owner.sol | 18 +++++ contracts...Sum.sol | 18 +++++ contracts...VolunteerContract.sol | 53 +++++++++++++ contracts...blockData.sol | 40 ++++++++++ contracts...campaign.sol | 116 ++++++++++++++++++++++++++++ contracts...carOwner.sol | 32 ++++++++ contracts...constOOP.sol | 74 ++++++++++++++++++ contracts...currencyBank.sol | 55 +++++++++++++ contracts...dataMemory.sol | 27 +++++++ contracts...eventsFallback.sol | 39 ++++++++++ contracts...freelance.sol | 46 +++++++++++ contracts...functionFt.sol | 18 +++++ contracts...functions.sol | 18 +++++ contracts...hashSecurity.sol | 11 +++ contracts...ifElse.sol | 34 ++++++++ contracts...loopsArray.sol | 77 ++++++++++++++++++ contracts...mappingStruct.sol | 36 +++++++++ contracts...operators.sol | 27 +++++++ contracts...patreon.sol | 38 +++++++++ contracts...requireStudy.sol | 23 ++++++ contracts...searchContract.sol | 47 +++++++++++ contracts...sendValues.sol | 20 +++++ 30 files changed, 1073 insertions(+) create mode 100755 contracts...Car.sol create mode 100755 contracts...DonateContract.sol create mode 100755 contracts...InterfacePayMethods.sol create mode 100755 contracts...IpaymentMethods.sol create mode 100755 contracts...Lottery.sol create mode 100755 contracts...Main.sol create mode 100755 contracts...Name.sol create mode 100755 contracts...Overloading.sol create mode 100755 contracts...Owner.sol create mode 100755 contracts...Sum.sol create mode 100755 contracts...VolunteerContract.sol create mode 100755 contracts...blockData.sol create mode 100755 contracts...campaign.sol create mode 100755 contracts...carOwner.sol create mode 100755 contracts...constOOP.sol create mode 100755 contracts...currencyBank.sol create mode 100755 contracts...dataMemory.sol create mode 100755 contracts...eventsFallback.sol create mode 100755 contracts...freelance.sol create mode 100755 contracts...functionFt.sol create mode 100755 contracts...functions.sol create mode 100755 contracts...hashSecurity.sol create mode 100755 contracts...ifElse.sol create mode 100755 contracts...loopsArray.sol create mode 100755 contracts...mappingStruct.sol create mode 100755 contracts...operators.sol create mode 100755 contracts...patreon.sol create mode 100755 contracts...requireStudy.sol create mode 100755 contracts...searchContract.sol create mode 100755 contracts...sendValues.sol diff --git a/contracts...Car.sol b/contracts...Car.sol new file mode 100755 index 0000000..797baf4 --- /dev/null +++ b/contracts...Car.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.5.0 <0.9.0; + +contract car { + + //Satrt the First Hello Contract + //Variable + + /* + CareName, + CarModel, + RedCar? + + */ + + //Type Name = Value ; + + //Types :String,integer,Boolean + + //Name: CareName,CarModel,RedCar? + + //Value:Haund,2019,ture/false + + string careName = "Haunda"; + uint256 carModel = 1990; + + uint256 firstAmount = 800; + uint256 secondAmount = 900; + + bool redCar = false; + + uint256 total = firstAmount + secondAmount; + + + function carOpen(bool isOpen) public returns(bool){ + //Script + return isOpen; + } + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/contracts...DonateContract.sol b/contracts...DonateContract.sol new file mode 100755 index 0000000..a0d89f3 --- /dev/null +++ b/contracts...DonateContract.sol @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +import "./IpaymentMethods.sol"; + +contract Donate is IpaymentMethods { + + uint public founderId; + + mapping (uint=>address) private funders; + + mapping (address=>bool) private savedfunders; + + modifier accounthasBalnce(){ + require((msg.sender.balance)>0,"You Dont have Money,Recharge"); + _; + } + + function addFunds() override external accounthasBalnce payable { + + address funder = msg.sender; + + if(!savedfunders[funder]){ + founderId++; + funders[founderId] = funder; + savedfunders[funder] =true; + } + + } + + function getFounderAtIndex(uint _index) external view returns(address){ + return funders[_index]; + } + + + + + + + + + + + + +} \ No newline at end of file diff --git a/contracts...InterfacePayMethods.sol b/contracts...InterfacePayMethods.sol new file mode 100755 index 0000000..5a94319 --- /dev/null +++ b/contracts...InterfacePayMethods.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.4.22 <0.9.0; + +// they cannot inherit from other smart contracts +// they can only inherit from other interfaces + +// They cannot declare a constructor +// They cannot declare state variables +// all declared functions have to be external + +interface InterfacePayMethods { + function addFunds() external payable; + function withdraw(uint withdrawAmount) external; +} + + + + + + + diff --git a/contracts...IpaymentMethods.sol b/contracts...IpaymentMethods.sol new file mode 100755 index 0000000..6ebd6bd --- /dev/null +++ b/contracts...IpaymentMethods.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +interface IpaymentMethods{ + + function addFunds()external payable; +} \ No newline at end of file diff --git a/contracts...Lottery.sol b/contracts...Lottery.sol new file mode 100755 index 0000000..12b1391 --- /dev/null +++ b/contracts...Lottery.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract Lottery { + address public manager; + address[] public players; + + function Lottery() public { + manager = msg.sender; + } + + function enter() public payable { + require(msg.value > .01 ether); + players.push(msg.sender); + } + + function random() private view returns (uint) { + return uint(keccak256(block.difficulty, now, players)); + } + + function pickWinner() public restricted { + uint index = random() % players.length; + players[index].transfer(this.balance); + players = new address[](0); + } + + modifier restricted() { + require(msg.sender == manager); + _; + } + +} \ No newline at end of file diff --git a/contracts...Main.sol b/contracts...Main.sol new file mode 100755 index 0000000..7560e2b --- /dev/null +++ b/contracts...Main.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +contract Main{ + uint public data; + + constructor(){ + data = 20; + } +} + +contract child is Main{ + Main private m; + m.data =30; +} \ No newline at end of file diff --git a/contracts...Name.sol b/contracts...Name.sol new file mode 100755 index 0000000..8b560d8 --- /dev/null +++ b/contracts...Name.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.4.22 <0.9.0; + +contract Name { +string public name = "ArDapps.com"; +} diff --git a/contracts...Overloading.sol b/contracts...Overloading.sol new file mode 100755 index 0000000..4a2fb83 --- /dev/null +++ b/contracts...Overloading.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +contract Overloading{ + + function sumNumbers(uint _x,uint _y,uint _z)public view returns (uint){ + + return _x +_y +_z; + } + + function sumNumbers(uint _x,uint _y)public view returns (uint){ + + return _x + _y; + } + + + function chckWitchOne()public view returns (uint){ + return sumNumbers(10,20,80); + } + + +} \ No newline at end of file diff --git a/contracts...Owner.sol b/contracts...Owner.sol new file mode 100755 index 0000000..62312d4 --- /dev/null +++ b/contracts...Owner.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.4.22 <0.9.0; + +contract Owner { + address public owner; + + constructor() { + owner = msg.sender; + } + + modifier onlyOwner { + require( + msg.sender == owner, + "Only owner can call this function" + ); + _; + } +} diff --git a/contracts...Sum.sol b/contracts...Sum.sol new file mode 100755 index 0000000..c3b186a --- /dev/null +++ b/contracts...Sum.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract Sum { + + function getSum () public pure returns(uint256){ + + uint256 fNum = 70; + uint256 sNum = 30; + + return fNum +sNum; + } + + function اسم الدالة () returns (){ + + } +} \ No newline at end of file diff --git a/contracts...VolunteerContract.sol b/contracts...VolunteerContract.sol new file mode 100755 index 0000000..d1894fc --- /dev/null +++ b/contracts...VolunteerContract.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.4.22 <0.9.0; +import "./Owner.sol"; +import "./InterfacePayMethods.sol"; + +contract VolunteerContract is Owner, InterfacePayMethods { + uint public numOfFunders; + + mapping(uint => address) private funders; + + modifier limitWithdraw(uint withdrawAmount) { + require( + withdrawAmount <= 100000000000000000, + "Cannot withdraw more than 0.1 ether" + ); + _; + } + + + + + function addFunds() override external payable { + address funder = msg.sender; + + + if (!funders[funder]) { + uint index = numOfFunders++; + funders[index] = funder; + } + + + + function withdraw(uint withdrawAmount) override external limitWithdraw(withdrawAmount) { + payable(msg.sender).transfer(withdrawAmount); + } + + + + function getFunderAtIndex(uint8 index) external view returns(address) { + return funders[index]; + } +} + + +// const instance = await Faucet.deployed(); + +// instance.addFunds({from: accounts[0], value: "2000000000000000000"}) +// instance.addFunds({from: accounts[1], value: "2000000000000000000"}) + +// instance.withdraw("500000000000000000", {from: accounts[1]}) + +// instance.getFunderAtIndex(0) +// instance.getAllFunders() diff --git a/contracts...blockData.sol b/contracts...blockData.sol new file mode 100755 index 0000000..cafa94f --- /dev/null +++ b/contracts...blockData.sol @@ -0,0 +1,40 @@ + +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract Owner{ + + address manager; + + constructor () public { + manager =msg.sender; + } + + modifier onlyManager{ + require(msg.sender ==manager,"The amanger only can access this data"); + + + _; + } + +} + +contract blockData is Owner { + + mapping(address=>uint) public balnces; + + +function setData( uint _value) public { + + balnces[msg.sender] = _value; + +} + +function changeValue(uint _value) public onlyManager { + + balnces[msg.sender] = _value; +} + + +} \ No newline at end of file diff --git a/contracts...campaign.sol b/contracts...campaign.sol new file mode 100755 index 0000000..a25ad7a --- /dev/null +++ b/contracts...campaign.sol @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.4.22 <0.7.0; + + + +contract CampaignFactory{ + Campaign [] public deployedCampaigns; + + function createCampaign (uint minium ) public{ + Campaign newCampaign = new Campaign(minium, msg.sender); + deployedCampaigns.push(newCampaign); + + } + + function getDeployedCampaign() public view returns( Campaign [] memory ) { + + return deployedCampaigns; + } +} + +contract Campaign { + + + mapping(address=>bool) approvals; + + + struct Request{ + string description; + uint value; + address payable recipient; + bool complete; + uint approvalCount; + + } + + + + Request [] public requests; + address public manager; + + uint public minimumContributionMoney; + + mapping (address=>bool) public approvers; + uint public approversCount ; + + + + constructor(uint minimum,address creator) public{ + manager = creator; + minimumContributionMoney = minimum; + + + } + + modifier restricted(){ + require(msg.sender == manager); + _; + } + + + + function contribute() public payable { + require(msg.value >= minimumContributionMoney); + approvers[msg.sender] = true; + approversCount ++; + } + + + function createRequest(string memory description,uint value,address payable recipient) public restricted{ + Request memory newRequest = Request ({ + description: description, + value:value, + recipient : recipient, + complete:false, + approvalCount: 0 + }); + + requests.push(newRequest); + } + + + function approverequest(uint index)public{ + Request storage request = requests[index]; + + require(approvals[msg.sender]); + require(!approvals[msg.sender]); + + approvals[msg.sender] = true; + request.approvalCount++; + + } + + function finalizeRequest(uint index) public restricted{ + Request storage request = requests[index]; + require(request.approvalCount >(approversCount/2)); + require(!request.complete); + request.recipient.transfer(request.value); + request.complete=true; + + } + + function getCampaignSumery () public view returns(uint,uint,uint,uint,address){ + return( + minimumContributionMoney, + address(this).balance, + requests.length, + approversCount, + manager + ); + } + + function getRequestsCount()public view returns(uint){ + return requests.length; + } + +} \ No newline at end of file diff --git a/contracts...carOwner.sol b/contracts...carOwner.sol new file mode 100755 index 0000000..995456f --- /dev/null +++ b/contracts...carOwner.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract CarOwner { + + address private owner; + + event OwnerSet(address indexed oldOwner, address indexed newOwner); + + modifier isOwner() { + require(msg.sender == owner, "Caller is not owner"); + _; + } + + + constructor() { + owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor + emit OwnerSet(address(0), owner); + } + + + function changeOwner(address newOwner) public isOwner { + emit OwnerSet(owner, newOwner); + owner = newOwner; + } + + + function getOwner() external view returns (address) { + return owner; + } +} \ No newline at end of file diff --git a/contracts...constOOP.sol b/contracts...constOOP.sol new file mode 100755 index 0000000..e9a7106 --- /dev/null +++ b/contracts...constOOP.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract constOOP{ + // string public firstName = "ardapps.com"; + + // constructor(string memory _firstName){ + + // firstName = _firstName; + + // } + //Start WIth struct + + + struct Account { + string userName; + int balance; + string phoneNumber; + } + + Account bahaaAccount; + + + function createAccount()public { + bahaaAccount = Account("BahaaTaha",1000,"096656565656"); + } + + function getUserName()public view returns(int ){ + + return bahaaAccount.balance; + } + + + + + + + + + + + + + + + + + + + + + + + + +// //Start WIth Enum + +// enum Languages {Arabic,English,Frensh} + +// Languages constant defaultLanguage = Languages.English; +// Languages public choice; + + +// function mychoice() public{ +// choice = Languages.Frensh; +// } + +// function getDefaultLanguage () public view returns(uint){ +// uint myDefaultINdex = uint(defaultLanguage); +// return myDefaultINdex; +// } +} + diff --git a/contracts...currencyBank.sol b/contracts...currencyBank.sol new file mode 100755 index 0000000..51995d8 --- /dev/null +++ b/contracts...currencyBank.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +contract currencyBank{ + + + //0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2,50000 -2 + //0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c,85000 -3 + + address public minter; + + mapping(address=>uint)public accounts; + + error noBalnce(uint amountRequsted,uint amountAvaliable); + event Sent(address from,address receiver,uint amount); + + constructor(){ + minter = msg.sender; + } + + //create the money for the first time + + function mint(address receiver, uint amount)public{ + require(msg.sender ==minter); + accounts[receiver] +=amount ; + + } + + //Send -(money found) + + function send(address receiver,uint amount)public{ + if(amount > accounts[msg.sender]) + revert noBalnce({ + amountRequsted:amount, + amountAvaliable:accounts[msg.sender] + }); + + accounts[msg.sender] -= amount; + accounts[receiver] +=amount; + emit Sent(msg.sender,receiver,amount); + } + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/contracts...dataMemory.sol b/contracts...dataMemory.sol new file mode 100755 index 0000000..10fc93b --- /dev/null +++ b/contracts...dataMemory.sol @@ -0,0 +1,27 @@ + +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract dataMemory{ + + string public name = "Arabic ket\"s,Dapps"; //'' "" + + function setName(string memory _name) public returns(string memory){ + require(bytes(_name).length >0,"Name Should Be char or More"); + name = _name; + + return name; + } + + + + + + function getStringLen()public view returns(uint){ + + bytes memory convertString = bytes(name); + + return convertString.length; + } +} \ No newline at end of file diff --git a/contracts...eventsFallback.sol b/contracts...eventsFallback.sol new file mode 100755 index 0000000..2012c9c --- /dev/null +++ b/contracts...eventsFallback.sol @@ -0,0 +1,39 @@ + +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract EventFallback{ + + event Log(uint256 gasLeft); + + fallback() external payable{ + + emit Log(gasleft()); + } + + uint balnce; + + function getContractBalnce() public view returns (uint){ + + return address(this).balance ; + } + + +} + +contract senMoneyBetweenUs { + + + function sendMoney(address payable _to) public payable { + // _to.transfer(msg.value); + (bool sucess,) = _to.call{value:msg.value}(''); + + require(sucess,"Faild To send MOney"); + } + + + + + +} \ No newline at end of file diff --git a/contracts...freelance.sol b/contracts...freelance.sol new file mode 100755 index 0000000..d1d9dbb --- /dev/null +++ b/contracts...freelance.sol @@ -0,0 +1,46 @@ +pragma solidity >=0.7.0 <0.9.0; + + +contract Freelance { + + uint256 numm = 10; + + modifier onlyPerson(){ + require(numm >8,"Number Must be Greater than 8") ; + _; + } + + //struct + + struct person { + string name; + uint256 id; + bool success; + } + + person bahaa = person("bahaa Ehab taha",1,true); + + string [] names = ["bhaa","Ali"]; + + + //mapping (Dic) + + mapping(address=>person) public persons; + + //Storage,memory,CallData + + //event + + + + event personEvent ( + string name, + uint256 id, + bool success + ); + + + + + +} diff --git a/contracts...functionFt.sol b/contracts...functionFt.sol new file mode 100755 index 0000000..ac19012 --- /dev/null +++ b/contracts...functionFt.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.7.0 <0.9.0; + +contract FunctionFt { + + uint256 public num ; + + constructor(uint256 _num){ + num = _num; + } + + + function sumNumbers (uint256 _num) public returns(uint256) { + num =_num; + return num ; + + } + +} \ No newline at end of file diff --git a/contracts...functions.sol b/contracts...functions.sol new file mode 100755 index 0000000..e37595f --- /dev/null +++ b/contracts...functions.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract Functions { + + // uint256 a = 70; + + + function addValues(uint256 number,uint256 a) public view returns(uint256){ + + uint256 results = a + number; + + return results; + } + + +} \ No newline at end of file diff --git a/contracts...hashSecurity.sol b/contracts...hashSecurity.sol new file mode 100755 index 0000000..7759a95 --- /dev/null +++ b/contracts...hashSecurity.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +contract HashSecurity{ + + function hashData(string memory data)public view returns(bytes32 Hash){ + + return sha256(bytes(data)); + } + +} \ No newline at end of file diff --git a/contracts...ifElse.sol b/contracts...ifElse.sol new file mode 100755 index 0000000..c5e47e2 --- /dev/null +++ b/contracts...ifElse.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract ifElse{ + + +uint256 internal doorCount = 6; //state var + + + + function getNewDoorCount() external pure returns(uint256){ + uint256 newCount = 130; + return newCount; + } +// function showNewDoorCount() public pure returns(uint256){ +// return getNewDoorCount(); +// } + + + + + + + + + function setDoorCount()public returns (uint256){ + return doorCount = 200; + } + + + + +} \ No newline at end of file diff --git a/contracts...loopsArray.sol b/contracts...loopsArray.sol new file mode 100755 index 0000000..ef36639 --- /dev/null +++ b/contracts...loopsArray.sol @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract loopsArray{ + uint num = 10; + //Index of arry start from Zero + uint [] salaries = [1000,2000,400,4000,6000,7999,8898]; + uint [] public numbers ; + + uint bahaaSalary = salaries[2]; + + //pop + //push + //delete + + function saveNumbers(uint _number) public{ + numbers.push(_number); + } + + function removeLastOne()public { + numbers.pop(); + } + + function getArrayLenght() public view returns(uint){ + return numbers.length; + } + + function replaceAtindexWithZero(uint _index) public{ + + delete numbers[_index]; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + // //Start With For Loops + + + // function numberIsFound(uint number) public view returns(bool){ + // bool isExisted = false; + + // for(uint start = 0;start=0.7.0 <0.9.0; + +contract mappingStruct { + + struct Account { + string userName; + int balance; + string phoneNumber; + string currency; + } + + + mapping(address=>Account) public userAddresses; + mapping(uint=>mapping(address=>Account)) public allUsers; + + //Set name and address + + function setUserAccount(uint _id,string memory _useName,int _balance,string memory _phoneNum,string memory _currency)public{ + + // userAddresses[msg.sender]=Account(_useName,_balance,_phoneNum,_currency); + allUsers[_id][msg.sender] =Account(_useName,_balance,_phoneNum,_currency); + + } + + + + //Get Special Name with address + + function getUserAccount(uint _id)public view returns(Account memory){ + return allUsers[_id][msg.sender]; + } + + +} \ No newline at end of file diff --git a/contracts...operators.sol b/contracts...operators.sol new file mode 100755 index 0000000..8d65bb5 --- /dev/null +++ b/contracts...operators.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +contract operators{ + + + +function sum(int x,int y) public pure returns (int){ + + return x+y; +} + + function multi(int x,int y) public pure returns (int){ + + return x*y; +} + +function div(int x,int y) public pure returns (int){ + + return x/y; +} + +function exponentiation(uint x,uint y) public pure returns (uint){ + + return x**y; +} +} \ No newline at end of file diff --git a/contracts...patreon.sol b/contracts...patreon.sol new file mode 100755 index 0000000..41d0d52 --- /dev/null +++ b/contracts...patreon.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + + +contract Patreon { + + + address public owner; + + address[] public contributors; + + constructor() { + owner = msg.sender; + } + + function pay() payable public { + require(msg.value > 0.0001 ether); + contributors.push(msg.sender); + } + + function sendMoneyToOwner()public restricted { + owner.transfer(this).balance; + contributors = new address[](0); + } + + modifier restricted() { + require(msg.sender == owner); + _; + } + + + function getcontributors() public view returns ( address []memory){ + return contributors; + } + + +} \ No newline at end of file diff --git a/contracts...requireStudy.sol b/contracts...requireStudy.sol new file mode 100755 index 0000000..a15f338 --- /dev/null +++ b/contracts...requireStudy.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract requireStudy { + + uint256 a = 20; + uint256 b = 30; + + +function getNumbers()public view returns (uint256){ + + if(!(a>b) && b>20){ + + return 100; + }else { + + return 500; + } +} + + +} \ No newline at end of file diff --git a/contracts...searchContract.sol b/contracts...searchContract.sol new file mode 100755 index 0000000..bcf9395 --- /dev/null +++ b/contracts...searchContract.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +library SearchLB{ + + function indexAtSearch(int256 [] storage numbers,int256 value) public view returns(uint256){ + for(uint256 index = 0; index < numbers.length; index++){ + + if(numbers[index] == value){ + return index; + } + + } + } +} +//Create contractMath + +contract Table { + + using SearchLB for int256[]; + + int256 [] numbers; + + constructor() public{ + numbers.push(-100);//0 + numbers.push(-200);//1 + numbers.push(-300);//2 + numbers.push(400);//3 + numbers.push(500);//4 + + } + + function numberIsFound(int256 _value) external view returns(uint256){ + uint result = numbers.indexAtSearch(_value); + return result; + } +} + + + + + + + + + diff --git a/contracts...sendValues.sol b/contracts...sendValues.sol new file mode 100755 index 0000000..39b32de --- /dev/null +++ b/contracts...sendValues.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +contract sendValues{ + + mapping(address=>uint) public balnces; + function addValue(uint _value) public { + balnces[msg.sender ] = _value; + } + +} + +contract ExtraCoins { + + function addExtraValue () public{ + sendValues sendValues = new sendValues(); + sendValues.addValue(50); + } + +} \ No newline at end of file