Skip to content

Instantly share code, notes, and snippets.

View gist:99e8eb658e2ccae6cab772c8e54dad45
const mask = (w) => (1n << w) - 1n;
const bnToHex = (bn) => {
let s = bn.toString(16);
if(bn % 2n === 0n){
s = `0${s}`;
}
return `0x${s}`;
}
const CLAIM_FLAGS_WIDTH = 8n;
@kbahr
kbahr / HexBars.txt
Created Feb 23, 2020
HTML, CSS, and Javascript for hexagonal progress bars with the HEX color gradient
View HexBars.txt
<!-- HTML for hex progress bar -->
<div id="wrapper" class="center">
<svg class="hex-progress noselect" data-progress="87.5" x="0px" y="0px" viewBox="0 0 776 628">
<path class="track" d="M723 314L543 625.77 183 625.77 3 314 183 2.23 543 2.23 723 314z" ></path>
<path class="fill" d="M723 314L543 625.77 183 625.77 3 314 183 2.23 543 2.23 723 314z" stroke="url(#cl1)"></path>
<text class="value" x="50%" y="61%">0%</text>
<text class="text" x="50%" y="122%">Staked</text>
</svg>
@kbahr
kbahr / HEXLottoProposal.sol
Created Feb 21, 2020
Proposed solution to the lotto entry traversal issue
View HEXLottoProposal.sol
pragma solidity >=0.5.16
contract HEXLotto {
// I didn't see where hexAmount was ever used
struct Entry {
uint256 ticketNumber; // could be uint96 to save space (12bytes + 20bytes address)
address buyer;
}
@kbahr
kbahr / HexUtilities.sol
Last active Feb 21, 2020
HEX utilities in solidity to get stake values
View HexUtilities.sol
pragma solidity ^0.5.12;
import "./HEX.sol";
contract HexUtilities {
struct StakeStore {
uint40 stakeId;
uint72 stakedHearts;
uint72 stakeShares;
@kbahr
kbahr / BasicUtilities.js
Last active Sep 29, 2021
HEX pull interest to date
View BasicUtilities.js
const Web3 = require('web3');
const compiledContractABI = require('./HEX.abi.json');
const hexAddr = "0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39";
const findStakeAndIndex = async (addr, stakeId) => {
let stakes = await hex.stakeList(addr);
for(let i = 0; i < stakes.length; i++){
if(stakes[i].stakeId === stakeId){
@kbahr
kbahr / ReferralContract.sol
Created Jan 6, 2020
A HEX/ETH "referral" contract that takes an erc20 token address (made for HEX, but any should work), a set of splitter addresses and their percentages. It will split ETH and ERC20 tokens by the addresses' percentages
View ReferralContract.sol
pragma solidity ^0.5.12;
import "./HEX.sol"; // TODO: Windows file separator
contract ReferralSplitter {
event DistributedShares(
uint40 timestamp,
address indexed memberAddress,
uint256 amount
View keybase.md

Keybase proof

I hereby claim:

  • I am kbahr on github.
  • I am kylebahr (https://keybase.io/kylebahr) on keybase.
  • I have a public key ASD4gYsgeXmvAEZ-ohOdOISGzYxZ-oKOsARmRCWM2606QQo

To claim this, I am signing this object: