Skip to content

Instantly share code, notes, and snippets.

View Ifeanyi-Ani's full-sized avatar

Ifeanyi Ani Ifeanyi-Ani

View GitHub Profile
@Ifeanyi-Ani
Ifeanyi-Ani / Test4.sol
Created August 14, 2023 14:56
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.21+commit.d9974bed.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract loopAndFunctionChallenge{
// function that takes two number and add them together
function addTwoNumber(uint a, uint b) external pure returns (uint) {
return a + b;
}
// function that substract two given number
function substractTwoNumber(uint a, uint b) external pure returns (uint){
//checking to make sure it does not return negative number
@Ifeanyi-Ani
Ifeanyi-Ani / Test3.sol
Created August 14, 2023 12:22
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.21+commit.d9974bed.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract IfElse {
function foo(uint x) public pure returns (uint) {
if (x < 10) {
return 0;
} else if (x < 20) {
return 1;
} else {
@Ifeanyi-Ani
Ifeanyi-Ani / Test2.sol
Created August 14, 2023 07:25
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.9+commit.e5eed63a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract EtherConverter {
uint256 public weiFactor = 10**18; // Conversion factor from ether to wei
uint256 public gweiFactor = 10**9; // Conversion factor from ether to gwei
function etherToWei(uint256 _etherValue) public view returns (uint256) {
return _etherValue * weiFactor;
@Ifeanyi-Ani
Ifeanyi-Ani / Test.sol
Created August 14, 2023 05:17
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
// FIRST CHALLENGE
// Write a simple contract and declare four different types of variables.
// Write get and set functions for each of these variables.
//Return the value of the variable in the “set function”.
contract ChallengeOne {