Skip to content

Instantly share code, notes, and snippets.

@SilentCicero
SilentCicero / ethers-rs-contract-example.rs
Last active Feb 15, 2021
A contract example for Ethers.rs, with use of provider get_logs and event decoding.
View ethers-rs-contract-example.rs
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 / Getting_Started_with_Fuel_in_NodeJS.js
Last active May 2, 2020
The NodeJS example code from the recent Fuel tutorial blog post.
View Getting_Started_with_Fuel_in_NodeJS.js
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);
View intToDecimal.js
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
View TestJS
console.log('hello world!');
console.log(window.parent.governx);
View addr
0xE4660fdAb2D6Bd8b50C029ec79E244d132c3bc2B
View MiniMeStandardToken.sol
/*
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;