Skip to content

Instantly share code, notes, and snippets.

View Apolloelephen's full-sized avatar

Apolloelephen Apolloelephen

View GitHub Profile
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MT") {
_mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract MessageApp {
string name;
function setTheName(string memory _name) public {
name = _name;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
contract pureView{
struct Class{
uint year;
uint id;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract Message {
address public sender;
uint256 public value;
uint256 public gas;
uint256 public gasPrice;
uint256 public blockNumber;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract EventContract {
uint public counter = 0;
event LogAddress(address indexed _sender, string _message);
event LogDeposit(address indexed _from, uint _amount, string _message);
event LogValueIncrease(address indexed _owner, uint _oldValue, uint _newValue, string _message);
function emitEvents() public payable {
@Apolloelephen
Apolloelephen / gist:a3cc42b18681e73e08301420e2d029dc
Created February 24, 2024 17:48
a simple Deposit Contract.
/ SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract Deposit {
// this maps the balance to the address of the depositor
mapping(address => uint256) public balances;
function deposit() external payable {
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import "contracts/school.sol";
contract factory {
School public cms; // Here we are defining the variable cms with the type School which corresponds with the name of the contract we imported.
function CreateSchoolCms() public {
cms = new School();
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
contract School {
address public principal;
mapping(address => bool) public teachers;
mapping(address => Student) public students;
struct Student {
string name;
@Apolloelephen
Apolloelephen / Stakingcontract.sol
Created January 27, 2024 19:01
this is a staking contract with the explanation
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
// import "@openzeppelin/contracts/utils/math/Math.sol";
// import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./Blessed.sol";
import "./BlessedWETH.sol";
import "./interface/IWETH.sol";