Skip to content

Instantly share code, notes, and snippets.

View amarachiugwu's full-sized avatar

Amarachi Ugwu amarachiugwu

View GitHub Profile
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 < 0.9.0;
contract Wallet {
// recieve ether
// send ether
// store ether
// withdrawl ether
// check balance
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ComprehensiveContract {
// State variables with different visibility specifiers
uint256 public publicData; // Public visibility: accessible from outside
uint256 internal internalData; // Internal visibility: accessible within this contract and derived contracts
uint256 private privateData; // Private visibility: accessible only within this contract
// Enum definition
//SPDX-License-Identifier:MIT
pragma solidity 0.8.5;
contract ATMMachine {
// this is the reserve of the atm machine
address public owner;
constructor () {
owner = msg.sender;
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
// GGGF -> Great Grand Grand Father
// GGF -> Great Grand Father
// GF -> Grand Father
// F -> Father
contract GGGF {
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
library MathLibrary {
function add(uint a, uint b) external pure returns(uint){
return a + b;
}
}
contract A {
@amarachiugwu
amarachiugwu / Golfer.sol
Created October 18, 2022 19:50
Unoptimized gas golfer contract
contract Golfer {
struct Data{
//always a preset date
uint256 timeStart;
//30 days after the start
uint256 timeFinish;
//names are at most 3 characters long
string name;
@amarachiugwu
amarachiugwu / DataStore.sol
Created October 18, 2022 15:54
retrieve the data stored to storage by line 10 below
contract DataStore{
uint256[50] _____gap_____;
struct Data{
uint256[] numbers;
bool in__;
bytes32 key;
}
constructor() public{
returnDataSlot().key=keccak256('YEP FOUND IT');
// SPDX-License-Identifier: MIT
// An example of a consumer contract that relies on a subscription for funding.
pragma solidity ^0.8.7;
import '@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol';
import '@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol';
import '@chainlink/contracts/src/v0.8/ConfirmedOwner.sol';
/**
* Request testnet LINK and ETH here: https://faucets.chain.link/
@amarachiugwu
amarachiugwu / index.html
Created September 26, 2022 05:27 — forked from shobhitic/index.html
Wallet Connect Integration Code - https://youtu.be/Ws5jIo4NMDc
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Wallet Connect</title>
<script src="https://cdn.jsdelivr.net/npm/@walletconnect/web3-provider@1.7.1/dist/umd/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
</head>
<body>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
contract Energy{
//have total supply
//transferrable
//name
//symbol