Skip to content

Instantly share code, notes, and snippets.

View nonseodion's full-sized avatar
💭
BUIDLing

Ifebhor Odion Nonse nonseodion

💭
BUIDLing
View GitHub Profile
@nonseodion
nonseodion / Attacker.sol
Created February 13, 2024 23:36
Reentrancy Attacker
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
import {Test, console2} from "forge-std/Test.sol";
import {Curves} from "contracts/Curves.sol";
import {CurvesERC20Factory} from "contracts/CurvesERC20Factory.sol";
import {FeeSplitter} from "contracts/FeeSplitter.sol";
contract CurvesTest is Test {
Curves curves;
@nonseodion
nonseodion / generateRSAKeyPair.js
Created September 13, 2023 15:05
Generate public and private RSA Keys
// run this script in a nodejs environment
let {privateKey, publicKey} = crypto.generateKeyPairSync("rsa", {modulusLength: 512})
publickKey = publicKey.export({type: "pkcs1", format: "pem"})
privateKey = privateKey.export({type: "pkcs1", format: "pem"})
// publicKey value
// '-----BEGIN RSA PUBLIC KEY-----\n' +
// 'MEgCQQC5GmUc8KaG8LuRYu0KmuAuMkqX8hEhjEXeWaXZpg6rz8CTLsKK1JaTnrqk\n' +
// 'G9jVrJExmZ+jqXk7Ll5awzDRbV/HAgMBAAE=\n' +
@nonseodion
nonseodion / USDTTronGas.js
Created June 7, 2023 10:53
USDT Transfer Gas Fee on Tron
const bs58 = require('bs58');
const axios = require("axios");
const triggerUrl = "https://api.trongrid.io/wallet/triggerconstantcontract";
const energyUnitUrl = "https://api.trongrid.io/wallet/getenergyprices";
// amount should not include decimals
// sender and receiver should be in base58
async function getFee(sender, receiver, amount) {
const decimals = 10**6; //USDT decimals
//nodejs
const axios = require('axios')
async function getCurrentGasPrices() {
let response = await axios.get('https://bscgas.info/gas')
let prices = {
slow: response.data.slow,
standard: response.data.standard,
fast: response.data.fast,
instant: response.data.instant
function claimRewards(address _lpToken) public override {
updatePool(_lpToken);
Pool memory pool = pools[_lpToken];
Miner storage miner = miners[_lpToken][msg.sender];
BonusToken memory bonusToken = bonusTokens[_lpToken];
_claimCoverRewards(pool, miner);
_claimBonus(bonusToken, miner);
// update writeoff to match current acc rewards & bonus per token
function deposit(address _lpToken, uint256 _amount) external override {
require(block.timestamp >= START_TIME , "Blacksmith: not started");
require(_amount > 0, "Blacksmith: amount is 0");
Pool memory pool = pools[_lpToken];
require(pool.lastUpdatedAt > 0, "Blacksmith: pool does not exists");
require(IERC20(_lpToken).balanceOf(msg.sender) >= _amount, "Blacksmith: insufficient balance");
updatePool(_lpToken);
Miner storage miner = miners[_lpToken][msg.sender];
BonusToken memory bonusToken = bonusTokens[_lpToken];
struct Pool {
uint256 weight; // the allocation weight for pool
uint256 accRewardsPerToken; // accumulated COVER to the lastUpdated Time
uint256 lastUpdatedAt; // last accumulated rewards update timestamp
}
<body>
<head>
Just testing gists
</head>
</body>
struct Miner {
uint256 amount;
uint256 rewardWriteoff; // the amount of COVER tokens to write off when calculate rewards from last update
uint256 bonusWriteoff; // the amount of bonus tokens to write off when calculate rewards from last update
}
let gucci = “Gucci”;
let versace = “Versace”;
//We shall swap the values of versace and gucci variables
//Pre-ES6
let temp = gucci;
gucci = versace;
versace = gucci;
console.log(versace, “is better than”, gucci);
//Output: Gucci is better than Versace.