Skip to content

Instantly share code, notes, and snippets.

View megabyte0x's full-sized avatar
🎮
Playing w/ time.

megabyte megabyte0x

🎮
Playing w/ time.
View GitHub Profile
@megabyte0x
megabyte0x / MultiSourcePriceFeed.lua
Created May 9, 2024 20:14
Price Feed from Multiple Sources
local json = require("json")
-- processId of the 0rbit process.
_0RBIT = "WSXUI2JjYUldJ7CKq9wE1MGwXs-ldzlUlHOQszwQe0s"
_0RBT_TOKEN = "BUhZLMwQ6yZHguLtJYA5lLUa9LQzLXMXRfaq9FVcPJc"
-- Base URL for coingecko API
BASE_URL = "https://api.coingecko.com/api/v3/simple/price"
FEE_AMOUNT = "1000000000000" -- 1 $0RBT
@megabyte0x
megabyte0x / 0rbit-quest.md
Last active March 6, 2024 19:49
0rbit quests

0rbit Quests

  • #1

Name: Price Feed Bot

Description: Create a bot for the chatroom that will provide the price feed for a token(s) when the users ask. The bot will be evaluated based on the live demo and the codebase.

Submission: Send({Target= "O3SXXYqQCNTbBedJjsW6wkPnrKFZq8DPLkKjO7zhztE", Action = "Claim", Quest = "Price-Bot", User = <username>}) Also, submit a PR here: https://github.com/0rbit-co/quest with the Name=price-feed-bot-${username} and with the codebase and demo link in the description.

I want to create a loyalty points system.

// SPDX-License-Identifier: MIT
// Layout of Contract:
// version
// imports
// interfaces, libraries, contracts`
// errors
// Events
// Type declarations
// State variables
@megabyte0x
megabyte0x / HelperConfig.sol
Created December 7, 2023 13:23
Helper Config file for the deployment and interactions scripts
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {Script} from "forge-std/Script.sol";
import {DevOpsTools} from "foundry-devops/src/DevOpsTools.sol";
import {MainContractDeployer} from "../src/MainContractDeployer.sol";
import {MainContract} from "../src/MainContract.sol";
contract HelperConfig is Script {
@megabyte0x
megabyte0x / Token.sol
Created August 23, 2023 06:52
Basic ERC20 Contract
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
/**
* @title Token
* @author Megabyte
* @notice ERC20 token contract
*/
@megabyte0x
megabyte0x / GraphKitExchange.sol
Last active August 27, 2023 10:50
DemoSwap V1 Exchange Contract
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
/**
* @title GraphKitExchange
* @author Megabyte
* @notice This contract is used to exchange ETH and tokens
@megabyte0x
megabyte0x / .deps...npm...@openzeppelin...contracts...math...SafeMath.sol
Created June 21, 2023 09:35
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.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
@megabyte0x
megabyte0x / Stake.sol
Last active March 1, 2023 10:59
Basic Staking Contract where user can stake their own custom ERC20.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./CustomERC.sol";
contract Stake is Ownable {
CustomERC public customToken;
@megabyte0x
megabyte0x / package.json
Created February 28, 2023 15:43
package.json file including all the dependencies required to build a basic staking contract with custom ERC20
{
"name": "staking-contract",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@openzeppelin/contracts": "^4.8.1",
"hardhat": "^2.12.7"
},
"devDependencies": {