-
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
1 parent
b7eed27
commit f412198
Showing
12 changed files
with
337 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 @@ | ||
./DS_Store |
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,20 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
import './sourceContract.sol'; | ||
|
||
contract destinationContract{ | ||
|
||
address private use; | ||
constructor(address usable){ | ||
use = usable; | ||
} | ||
|
||
function same() public view returns(uint){ | ||
|
||
return Source(use).getValue(); | ||
|
||
//return contractA.getValue(); | ||
} | ||
} |
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,14 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol'; | ||
|
||
contract ownerTest is Ownable{ | ||
|
||
function onlyTheOwnerCancall() public view onlyOwner returns(uint){ | ||
return 100; | ||
} | ||
|
||
} | ||
|
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,23 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
contract functions{ | ||
function add(int a, int b) public pure returns(int){ | ||
return a+b; | ||
} | ||
|
||
function addTwos() private pure returns(int){ | ||
return 2+2; | ||
} | ||
|
||
|
||
string private name = "Dan"; | ||
function getName() public view returns(string memory){ | ||
return name; | ||
} | ||
|
||
function setName(string memory newName) public{ | ||
name = newName; | ||
} | ||
} |
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: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
contract homeWork{ | ||
function addNumbers(uint a, uint b) public pure returns(uint){ | ||
return a+b; | ||
} | ||
|
||
string public name = "Mahith"; | ||
|
||
function myName() public view returns(string memory){ | ||
return name; | ||
} | ||
|
||
function cookies(string memory food) public pure returns(string memory){ | ||
if(keccak256(bytes(food))==keccak256(bytes("cookie"))){ | ||
return 'yum'; | ||
}else{ | ||
return 'yuck'; | ||
} | ||
} | ||
|
||
function party(int a, int b) public pure returns(string memory){ | ||
if(a+b==10){ | ||
return "party"; | ||
}else{ | ||
return ""; | ||
} | ||
|
||
} | ||
|
||
|
||
function multiples(int a) public pure returns(int){ | ||
int count = 1; | ||
for(int i=0; i<a; i++){ | ||
count=count*2; | ||
} | ||
return count; | ||
} | ||
} |
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,52 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
contract impBasics{ | ||
|
||
address private contractOwner; | ||
uint private value = 100; | ||
bool switcher = false; | ||
|
||
//will run only when contract is deployed | ||
constructor(address accessableAddress){ | ||
contractOwner = accessableAddress; | ||
} | ||
|
||
|
||
|
||
function tryingBasics() public view returns(uint,uint,uint){ | ||
return (block.chainid,block.difficulty,block.number); | ||
} | ||
|
||
modifier onlyOwner(){ | ||
require(contractOwner == msg.sender, "Only onwer is allowed to run"); | ||
_; | ||
} | ||
|
||
modifier flip(){ | ||
if(switcher != true ){ | ||
revert("switch is off"); | ||
} | ||
_; | ||
} | ||
|
||
function getValue() public view onlyOwner returns(uint){ | ||
return value; | ||
} | ||
|
||
function run() public view returns(uint){ | ||
assert(value==100); | ||
return value; | ||
} | ||
|
||
function changeFlip(bool option) public{ | ||
switcher = option; | ||
} | ||
|
||
function runner() public view flip returns(uint){ | ||
return value; | ||
} | ||
|
||
|
||
|
||
} |
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,60 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
contract elbow{ | ||
|
||
uint private age = 24; | ||
|
||
function bend() public pure virtual returns(string memory){ | ||
return "Bending"; | ||
} | ||
|
||
function getAge() public view returns(uint){ | ||
return age; | ||
} | ||
|
||
} | ||
|
||
contract leftArm is elbow{ | ||
|
||
function raise() public virtual returns(string memory){ | ||
return string.concat("Left Arm is ",bend()); | ||
} | ||
} | ||
|
||
contract rightArm is elbow{ | ||
|
||
function raise() public virtual returns(string memory){ | ||
return string.concat("Right Arm is ",bend()); | ||
} | ||
} | ||
|
||
contract knee is elbow{ | ||
|
||
function getBend() public pure returns(string memory){ | ||
return super.bend(); | ||
|
||
} | ||
function kick() public pure returns(string memory){ | ||
return "kicking"; | ||
} | ||
} | ||
|
||
contract person is leftArm,rightArm{ | ||
|
||
function raise() public pure override(leftArm,rightArm) returns(string memory){ | ||
return string.concat("Both arms are", bend()); | ||
} | ||
} | ||
|
||
contract alien is rightArm, knee{ | ||
|
||
function bend() public pure override returns(string memory){ | ||
return "flying"; | ||
} | ||
|
||
function fly() public pure returns(string memory){ | ||
return string.concat(kick(),bend()); | ||
} | ||
} |
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,24 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
interface ISource{ | ||
function getValue() external view returns(uint); | ||
|
||
} | ||
|
||
contract user{ | ||
|
||
address private useAddress; | ||
|
||
constructor(address sourceAddress){ | ||
useAddress = sourceAddress; | ||
} | ||
|
||
function same() public view returns(uint){ | ||
|
||
ISource contractSource = ISource(useAddress); | ||
return contractSource.getValue(); | ||
} | ||
|
||
} |
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,27 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
contract A{ | ||
|
||
uint private value = 100; | ||
|
||
function getValue() view public returns(uint){ | ||
return value; | ||
} | ||
|
||
function changeValue(uint newValue) public { | ||
value = newValue; | ||
} | ||
|
||
} | ||
|
||
contract B{ | ||
|
||
function same() public view returns(uint){ | ||
|
||
return A(0x9C9fF5DE0968dF850905E74bAA6a17FED1Ba042a).getValue(); | ||
|
||
//return contractA.getValue(); | ||
} | ||
} |
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,17 @@ | ||
//SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.13; | ||
|
||
contract Source{ | ||
|
||
uint private value = 100; | ||
|
||
function getValue() view public returns(uint){ | ||
return value; | ||
} | ||
|
||
function changeValue(uint newValue) public { | ||
value = newValue; | ||
} | ||
|
||
} |
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,59 @@ | ||
//SPDX-License-Identifier: MIT | ||
// pragma solidity 0.8.13; | ||
pragma solidity ^0.8.13; | ||
// pragma solidity >= 0.8.13 < 0.9.5; | ||
|
||
|
||
contract variables{ | ||
int number1 =-1; | ||
int8 number22 = 22; | ||
int16 number222 = 222; | ||
int32 public number11 = 11; | ||
|
||
uint public number01 = 1; | ||
|
||
string public greet = 'hello world'; | ||
string[2] public names = ['ram','laxman']; | ||
uint[] public infinite = [1,2,3,4,5,6]; | ||
string[] public namesInfinite = ['robert','tom','chris']; | ||
|
||
mapping(string => int) public mapEx; | ||
|
||
address public myAddress = 0x61236DE2834fDcE9A4b4Fa3B68dDe39Eca7199Cb; | ||
|
||
enum cryogen{gas,liquid,solid} | ||
|
||
cryogen public fuel = cryogen.gas; | ||
|
||
bool public switcher = true; | ||
|
||
bytes public eg = "0x1"; | ||
bytes3 public e = "abc"; | ||
|
||
|
||
struct car { | ||
uint wheels; | ||
string model; | ||
|
||
} | ||
|
||
car public mycar=car(4,"i20"); | ||
|
||
} | ||
|
||
contract newOne{ | ||
uint[3] newArray = [1,2,3]; | ||
|
||
enum testOne{cloud, java, solidity} | ||
testOne test = testOne.cloud; | ||
|
||
struct cat{ | ||
uint legs; | ||
string name; | ||
} | ||
|
||
cat nico = cat(4,"nico"); | ||
|
||
mapping(int=>string) public testing; | ||
|
||
} |