Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View SilentCicero's full-sized avatar
🎯
Focusing

Nick SilentCicero

🎯
Focusing
View GitHub Profile
/*
You should inherit from StandardToken or, for a token like you would want to
deploy in something like Mist, see HumanStandardToken.sol.
(This implements ONLY the standard functions and NOTHING else.
If you deploy this, you won't have anything useful.)
Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20
.*/
pragma solidity ^0.4.8;
0xE4660fdAb2D6Bd8b50C029ec79E244d132c3bc2B
console.log('hello world!');
console.log(window.parent.governx);
const BN = require('bn.js');
const stripHexPrefix = val => typeof val === 'string' && val.indexOf('0x') === 0 ? val.slice(2) : val;
const hexPrefix = val => val ? (`0x${stripHexPrefix((val || {}).div ? val.toString(16) : val)}`) : val;
const hexToBN = val => (val || {}).div ? val : new BN(stripHexPrefix(hexPrefix(val)), 16);
const numToBN = val => (val || {}).div || String(val).indexOf('0x') !== -1 ? hexToBN(val) : new BN(val, 10);
function intToDecimal(weiInput, baseLength, optionsInput) {
var wei = numToBN(weiInput); // eslint-disable-line
var negative = wei.lt(new BN(0)); // eslint-disable-line
@SilentCicero
SilentCicero / Getting_Started_with_Fuel_in_NodeJS.js
Last active May 2, 2020 23:35
The NodeJS example code from the recent Fuel tutorial blog post.
const { Wallet, utils, dbs } = require("fuel-core");
(async () => {
// DB and Key Setup
const db = new dbs.Level(); // persisting db
const privateKey = (await db.get('key')) || utils.randomBytes(32);
await db.put('key', privateKey);
@SilentCicero
SilentCicero / ethers-rs-contract-example.rs
Last active November 11, 2022 06:47
A contract example for Ethers.rs, with use of provider get_logs and event decoding.
use anyhow::Result;
use ethers::{
prelude::*,
utils::{Ganache, Solc},
};
use std::{convert::TryFrom, sync::Arc, time::Duration};
// Generate the type-safe contract bindings by providing the ABI
// definition in human readable format
@SilentCicero
SilentCicero / Counter.sw
Last active January 5, 2023 19:34
A simple counter Sway contract.
contract;
use sway_libs::i8::I8;
abi TestContract {
#[storage(write)]
fn initialize_counter(value: u64) -> u64;
#[storage(read, write)]
fn increment_counter(amount: u64) -> u64;