Skip to content

Instantly share code, notes, and snippets.

View nsjames's full-sized avatar

Nathan James nsjames

View GitHub Profile
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
using namespace eosio;
CONTRACT receiver : public contract {
public:
using contract::contract;
ACTION noop(){}

EOS Staking Integration Guide

The EOS Network emits a fixed percentage of the out of circulation supply of EOS to various entities (miners, foundations, staking rewards, etc.) on the network constantly. The network has a built-in mechanism to distribute these rewards to the stakers of EOS. The staking rewards are distributed to the stakers of EOS in the form of REX tokens.

REX tokens are a representation of the amount of EOS that a user has staked on the network. REX tokens cannot be transferred to other users, but they can be sold back to the network for EOS.

As the network rewards are distributed to the REX staking pool, the price of REX tokens increases. This means that the

- [ ] I understand the purpose of this PR
- [ ] I have visually inspected every line of added and removed code
- [ ] I have analyzed the side effects of the additions and removals
- [ ] I have checked the code for quality:
- [ ] Names are coherent, descriptive, and consistent
- [ ] There are no superfluous comments, only ones that give context
- [ ] All code is self-explanatory
- [ ] The code does not repeat itself
- [ ] The code follows the project standards (indentation, spacing, etc)
- [ ] I have tested the code
#include <eosio.token.hpp>
/*******************************************/
/* USAGE NOTICE */
/* --------------------------------------- */
/* This file was generated using a */
/* proprietary blockchain contract flow */
/* based programming (FBP) application. */
/* --------------------------------------- */
@nsjames
nsjames / README.md
Last active September 3, 2021 05:09
Scatter 12 backup recovery tool

Scatter 12 backup recovery tool

This is just a recovery tool for the malformed backups from scatter 12.0.0

How to use

  • Option 1: Click the "Download ZIP" button on the top of this gist, extract it somewhere, and then open index.html.
  • Option 2: Copy the contents of index.html and main.js to a folder on your computer, and then open index.html.

The unpacked_min.js file is what the main.js is before it goes through webpacking which allows it to be imported in a single file, otherwise users would have to install the node package manager and run a full blown javascript project.

@nsjames
nsjames / EOSIO_API_Signing_Filter.js
Last active October 17, 2019 04:19
An example of how to protect your dapp and keys when assuming resource control for your users.
// SECURITY CONCERNS!
// Because your backend will be signing transactions, you will need to validate
// the transaction details before actually signing them.
// Using keys designated for specific actions is okay in some situations, but not all
// (like when your dapp wants to pay for eosio.token transfers, which exposes you to risk of losing your available tokens)
// The best flow for this is the following:
// VISUAL DIAGRAM: https://t.me/ScatterDevelopers/16787
// - Front-end which implements a multi-signer (scatter + api signer)
// - Scatter signs for the user
// @ts-ignore
import BlockchainLoginToken from "../models/tokens/BlockchainLoginToken";
require('isomorphic-fetch');
// @ts-ignore
import Eos from 'eosjs';
const EOS_NODES:any = {
'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906':'https://nodes.get-scatter.com'
};
const getApiNodes = async () => {
const getBpData = async (bp, attempt = 0) => {
if(attempt >= 3) return {bp:bp.owner, error:'no bp.json'};
const json = await fetch(`${bp.url}/bp.json`).then(x => x.json()).catch(() => null);
if(!json) return getBpData(bp, attempt+1);
let ssl_endpoint, api_endpoint;
json.nodes.map(x => {
if(!ssl_endpoint && x.ssl_endpoint && x.ssl_endpoint.length) ssl_endpoint = x.ssl_endpoint;
hasHistory bp error
True eoshuobipool
True starteosiobp
True eoslaomaocom
False eosflytomars
False eosiosg11111
True atticlabeosb
False eosliquideos
True jedaaaaaaaaa
False cochainworld
package com.scatternative;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import org.java_websocket.WebSocket;
import org.java_websocket.drafts.Draft;
import org.java_websocket.exceptions.InvalidDataException;
import org.java_websocket.handshake.ClientHandshake;