-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2b4d5c2
Showing
30 changed files
with
1,073 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
interface IpaymentMethods{ | ||
|
||
function addFunds()external payable; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
_; | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.4.22 <0.9.0; | ||
|
||
contract Name { | ||
string public name = "ArDapps.com"; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
); | ||
_; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 (){ | ||
|
||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.