Instantly share code, notes, and snippets.

View basis_points.txt
basis points
1 bp = 0.01
10 bp = 0.1%
100 bp = 1%
1000 bp = 10%
View Example.sol
pragma solidity ^0.4.23;
contract Example {
uint256 public data;
function set(uint256 _data) public {
data = _data;
}
}
View scatter_example.js
const ScatterJS = require('scatterjs-core').default
const ScatterEOS = require('scatterjs-plugin-eosjs').default
const Eos = require('eosjs')
ScatterJS.plugins(new ScatterEOS())
const connectionOptions = {
initTimeout: 10000
}
const network = {
View set_account_permission.sh
# key is active public key
cleos -u http://api.kylin.alohaeos.com set account permission myaccount123 active '{"threshold":1, "keys":[{"key":"EOS5nKgVwRvRnjf4tyViZ61iydQ6CiFMoURta36RUk9hxi5wpAkLb", "weight":1}], "accounts": [{"permission":{"actor":"myaccount123","permission":"eosio.code"},"weight":1}]}' owner -p myaccount123
View sign.cpp
int main(int argc, const char * argv[]) {
// using sha256 = fc::sha256;
// char b[32];
// memset(b, 0, sizeof(b));
// auto sb = fc::sha256::hash(b, sizeof(b));
auto sb = fc::sha256("0000000000000000000000000000000000000000000000000000000000000000");
auto strpkey = std::string("5HxQKWDznancXZXm7Gr2guadK7BhK9Zs8ejDhfA9oEBM89ZaArv");
auto pkey = eosio::chain::private_key_type(strpkey);
auto sig2 = pkey.sign(sb);
auto strsig2 = (std::string)sig2;
View signout.js
const auth2 = window.gapi.auth2.getAuthInstance()
auth2.signOut().then(function () {
})
View limit_gas_price.sol
function() payable {
require(tx.gasprice < 30000000000); // 30000000000 is 30 gwei
// if gas price is higher than it, the tx will fail
doOtherProcessing();
}
View build_create2_address.js
function buildCreate2Address(creatorAddress, saltHex, byteCode) {
const parts = [
'ff',
creatorAddress.slice(2),
saltHex.slice(2),
web3.utils.sha3(byteCode).slice(2),
]
const partsHash = web3.utils.sha3(`0x${parts.join('')}`)
return `0x${partsHash.slice(-40)}`.toLowerCase()
View wikipedia_random_url.txt
https://en.wikipedia.org/wiki/Special:Random
View main.go
package main
import (
"bufio"
"bytes"
"fmt"
)
func main() {
b := []byte("hello\nworld")