This file contains hidden or 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
| #Explanations | |
| First of all, to create a staking contract there is need to make use of a token for the staking. Creating an ERC20 token is paramount. Then after that, we talk about the components of a staking contract. For a stake to happen, there would be a staker, a range of amount to be staked, the duration of the staking, the reward which will be calculated by the duration and the amount staked, then after a certain duration of staking, the staker can withdraw. | |
| In this solidity staking contract, we have the Solidity version that is ^0.8.20 which would instruct the compiler to use a certain version for compilations. | |
| The Structure of the Contract | |
| 1. Contract Definition and Imports | |
| The contract is defined with a name - StakingRewards (Staring it a capital letter is the best practise) |
This file contains hidden or 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.0; | |
| contract SchoolManagement { | |
| //address of the principal | |
| address public schoolOwner; | |
| //student Id | |
| uint8 public studentId; |
This file contains hidden or 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.0; | |
| import "contracts/SchoolManagement.sol"; | |
| contract SaaS{ | |
| SchoolManagement[] public schools; | |
| uint public numOfCreatedContract; |
This file contains hidden or 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.0; | |
| contract SimpleStorage { | |
| uint256 private storedData; | |
| address public owner; | |
| //initializing the contract deployer to be the owner | |
| constructor() { |
This file contains hidden or 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.2; | |
| contract Functions { | |
| address public manager; | |
| address payable[] public players; | |
| constructor() { | |
| manager = msg.sender; |
This file contains hidden or 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.9; | |
| import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
| import "@openzeppelin/contracts/access/Ownable.sol"; | |
| contract SignorNFT is ERC721URIStorage, Ownable{ | |
| constructor(address initialOwner) Ownable(initialOwner) ERC721("Signor ONE", "SNE"){} | |
| function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner { |
This file contains hidden or 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.9; | |
| import "./IERC20.sol"; | |
| error ADDRESS_ZERO_DETECTED(); | |
| error ZERO_VALUE_NOT_ALLOWED(); | |
| error INSUFFICIENT_BALANCE(); | |
| error TRANSFER_FROM_FAILED(); | |
| error TRANSFER_FAILED(); |
This file contains hidden or 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.9; | |
| error ADDRESS_ZERO_DETECTED(); | |
| error ZERO_VALUE_NOT_ALLOWED(); | |
| error INSUFFICIENT_BALANCE(); | |
| contract SaveEther{ | |
| mapping (address => uint256 ) savings; |
This file contains hidden or 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.9; | |
| contract TodoList { | |
| //struct | |
| struct MyTodoList { | |
| string title; | |
| string description; | |
| bool isDone; | |
| } |
This file contains hidden or 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.9; | |
| contract SimpleStorage { | |
| uint private _storedData; | |
| function get() public view returns (uint) { | |
| return _storedData; | |
| } |
OlderNewer