Skip to content

Instantly share code, notes, and snippets.

View Signor1's full-sized avatar
🎯
Focusing

Signor Dev Signor1

🎯
Focusing
View GitHub Profile
@Signor1
Signor1 / explanation.txt
Last active January 27, 2024 19:09
Solidity Staking Contract
#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)
@Signor1
Signor1 / SchoolManagement.sol
Last active February 8, 2024 16:08
create a smart contract for a school organization where a principal has full admin rights, students can update some of their records(limited) teachers can update students scores
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SchoolManagement {
//address of the principal
address public schoolOwner;
//student Id
uint8 public studentId;
@Signor1
Signor1 / SaaS.sol
Last active February 9, 2024 18:56
A factory pattern
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "contracts/SchoolManagement.sol";
contract SaaS{
SchoolManagement[] public schools;
uint public numOfCreatedContract;
@Signor1
Signor1 / SimpleStorage.sol
Created February 11, 2024 01:36
Write a smart contract that allows only the admin to access and call all the functions of the contract.
// 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() {
@Signor1
Signor1 / Functions.sol
Last active February 12, 2024 12:09
For this challenge, write a smart contract that uses view, pure, and payable functions. Ensure that the functions are accessible within the contract and derived contracts as well.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
contract Functions {
address public manager;
address payable[] public players;
constructor() {
manager = msg.sender;
@Signor1
Signor1 / SignorNFT.sol
Created February 15, 2024 16:31
Write an ERC721 smart contract using any solidity development environment. Deploy it on either Polygon Mumbai or Ethereum Sepolia and make sure it appears on OpenSea marketplace
// 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 {
@Signor1
Signor1 / MySave.sol
Created February 22, 2024 10:18
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
// 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();
@Signor1
Signor1 / SaveEther.sol
Created February 22, 2024 11:43
Write a smart contract that uses global functions in the message context
// 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;
@Signor1
Signor1 / Todo.sol
Created February 22, 2024 13:58
Write a smart contract that has both storage and memory types of variables in it.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract TodoList {
//struct
struct MyTodoList {
string title;
string description;
bool isDone;
}
@Signor1
Signor1 / SimpleStorage.sol
Last active February 22, 2024 15:04
Write a smart contract and make it upgradeable using a proxy contract.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract SimpleStorage {
uint private _storedData;
function get() public view returns (uint) {
return _storedData;
}