Skip to content

Instantly share code, notes, and snippets.

View developeruche's full-sized avatar
🤓
Building

Developer Uche developeruche

🤓
Building
View GitHub Profile
@developeruche
developeruche / timed-counter.sol
Created August 1, 2022 16:09
Cohort VII Classwork
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract Counter {
uint deployTime;
uint public count;
constructor() {
deployTime = block.timestamp;
@developeruche
developeruche / main.sol
Created August 2, 2022 12:55
Odd testing
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint[] public arr = [1,2,3,4,5,6,7,8,9,10];
uint[] public res;
function startWork() public {
for (uint i = 0; i < arr.length; i++) {
if(arr[i] % 2 == 0) {
res.push(arr[i]);
@developeruche
developeruche / English auction.sol
Created August 2, 2022 13:35
Solidity English Auction
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IERC721 {
function safeTransferFrom(
address from,
address to,
uint tokenId
) external;
@developeruche
developeruche / btyesmanager.sol
Created August 3, 2022 01:11
Explains Bytes Code and Init Code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ByteCodeManager {
function getBytecode(address _owner, uint _foo) public pure returns (bytes memory) {
bytes memory bytecode = type(TestContract).creationCode;
return abi.encodePacked(bytecode, abi.encode(_owner, _foo));
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract YouDeposit {
mapping(address => uint) balances;
function deposit() public payable {
require(msg.value > 0, "No value sent");
balances[msg.sender] += msg.value;
@developeruche
developeruche / depositandwithdraw.sol
Created August 4, 2022 13:55
Deposit And Withdraw
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
// Deposit funds into a contract and keep track of the funds
contract HelloWorld {
mapping (address => uint) public bal;
fallback() external payable {}
@developeruche
developeruche / depositandwithdraw.sol
Created August 4, 2022 13:56
Deposit And Withdraw
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
// Deposit funds into a contract and keep track of the funds
contract HelloWorld {
mapping (address => uint) public bal;
fallback() external payable {}
@developeruche
developeruche / assignment.sol
Created August 5, 2022 23:34
This is an week four assignment
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
contract Energy{
//have total supply
//transferrable
//name
//symbol
@developeruche
developeruche / bank_contract_updated.sol
Created August 10, 2022 03:05
This is an updated version of the bank contract
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/Pausable.sol";
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
const {
time,
loadFixture,
} = require("@nomicfoundation/hardhat-network-helpers");
const { anyValue } = require("@nomicfoundation/hardhat-chai-matchers/withArgs");
const { expect } = require("chai");
describe("Lock", function () {
// We define a fixture to reuse the same setup in every test.
// We use loadFixture to run this setup once, snapshot that state,