Skip to content

Instantly share code, notes, and snippets.

View ddabek's full-sized avatar
🎯
Focusing

Daniel Dabek ddabek

🎯
Focusing
View GitHub Profile
@ddabek
ddabek / safex_blockchain_txn_types.js
Created June 20, 2020 12:38
getting transactions from blocks and counting transaction types
/*
In this gist you will find the functions for getting a block from a safex blockchain full node.
After obtaining a block at an incremental height, it will scan through the transaction contents
of that block and sort through the transaction types counting how many of each transaction were created until the top height.
You will need to plug this program into a nodejs project with axios installed. So you must create a package.json in the same
directory with this script.
The port set on the blockheight and block content are set to 29393 which is for testnet mainnet is 17402
stagenet port is 30393
enum class tx_out_type: uint8_t {
out_cash = 0,
out_token = 1,
out_bitcoin_migration = 2,
out_advanced = 10, //generic advanced utxo
out_staked_token = 11,
out_network_fee = 12, //safex cash collected as network trading fee
out_safex_account = 15, //safex account output
out_safex_account_update = 16, //safex account output update
out_safex_offer = 20,
/*
This function will call the public api at xcalibra.com and
return the orderbook for both buy and sell orders
the parameters to specify are:
1. pair = 'SFT_BTC'
*/
const axios = require('axios');
/*
Livecoin.net has two separate functions for buy and for sell. In this code snippet you will see how to send
a buy or sell limit order to the exchange over the API. Authentication, and formatting of the request are demonstrated.
The following parameters are required to complete a trade:
1. pair - this follows the format: SFT%2FBTC or ETH%2FBTC for example
(notice that you need the text URL encoded hence the %2F replacing a / (slash))
2. price - the price in the quote currency (the second in the pair)
3. quantity - the quantity of base currency to be obtained (quantity of the first currency in the pair)
For this function to work for you, you must generate the API Key and the Secret Key provided on the exchange website.
/*
This function enables a new order to be made on coindeal.com via an API call.
It demonstrates the usage of authentication via Basic Auth using the Public Key and Private Key generated in the user account.
With this function you set the following parameters:
1. pair - this follows the format: SFTBTC or ETHBTC for example
2. type - can be 'limit' or 'market'
3. side - 'buy' or 'sell'
4. price - the price in the quote currency (the second in the pair)
5. quantity - the quantity of base currency to be obtained (quantity of the first currency in the pair)
For this function to work for you, you must supply your own Key Set.
/*
This function enables a new order to be made on xcalibra.com via API call.
It demonstrates the usage of authentication via API and SEC keys generated by the exchange within your user account.
With this function you set the following parameters:
1. pair - this follows the format: SFT_BTC or ETH_BTC or BTC_RSD for example
2. type - can be 'limit' or 'market'
3. side - 'buy' or 'sell'
import psycopg2
import commands
from bitcoin import *
source_priv = 'privatekey'
pub = privtopub(source_priv)