Skip to content

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
ArDapps committed Dec 5, 2021
0 parents commit 2b4d5c2
Show file tree
Hide file tree
Showing 30 changed files with 1,073 additions and 0 deletions.
55 changes: 55 additions & 0 deletions contracts...Car.sol
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;
}















}
46 changes: 46 additions & 0 deletions contracts...DonateContract.sol
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];
}












}
21 changes: 21 additions & 0 deletions contracts...InterfacePayMethods.sol
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;
}







8 changes: 8 additions & 0 deletions contracts...IpaymentMethods.sol
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;
}
33 changes: 33 additions & 0 deletions contracts...Lottery.sol
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);
_;
}

}
15 changes: 15 additions & 0 deletions contracts...Main.sol
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;
}
6 changes: 6 additions & 0 deletions contracts...Name.sol
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";
}
22 changes: 22 additions & 0 deletions contracts...Overloading.sol
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);
}


}
18 changes: 18 additions & 0 deletions contracts...Owner.sol
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"
);
_;
}
}
18 changes: 18 additions & 0 deletions contracts...Sum.sol
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 (){

}
}
53 changes: 53 additions & 0 deletions contracts...VolunteerContract.sol
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()
40 changes: 40 additions & 0 deletions contracts...blockData.sol
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;
}


}
Loading

0 comments on commit 2b4d5c2

Please sign in to comment.