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
//SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
contract Storage { | |
struct student{ | |
string Name; | |
uint Age; | |
} |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.24; | |
import "./School.sol"; | |
contract SchoolFactory { | |
School public schoolSystem; |
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
//SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
contract School { | |
enum Rank { | |
Principle, | |
Teacher, | |
Student | |
} |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.17; | |
// Write a smart contract that defines and triggers 3-4 events | |
// Index the events so that they can be easily searched | |
// Capture these events in your JavaScript code | |
contract Events { | |
uint public x = 0; | |
event AddressLog(address indexed sender, string message); |
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
let contract_abi = [ | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "sender", | |
"type": "address" | |
}, |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.17; | |
contract Function { | |
uint public a = 5; | |
// View function | |
function multiplyNumbers(uint b) public view returns (uint) { | |
return a * b; | |
} |
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
The contract allows users to stakes tokens using the staking Token and get ther rewards using the rewards token. There are a number of features included in the cntract to ensure that it runs smoothly. These include: | |
-Pragma declaration: Defines the solidity version to be used for the contract (version 0.5.16 and higher). | |
-The imports are used to bring in various functionalities from OpenZappelinlibrary such as safemath mathematical operations, ERC20 transferes and security against reentrancy. | |
-It also inherits multiple contracts and interfaces to acces their functionality. | |
-The contract declares various state variables for staking and rewards, defining the timing for reward distribution, store data about the participants and track the individual balances and the total staked tokens. | |
-THe constructor uses the reward token, distribution, staking addresses and the owner to initialize the contract. |
NewerOlder