Skip to content

Instantly share code, notes, and snippets.

View mempirate's full-sized avatar
🏃
Sprinting

Jonas Bostoen mempirate

🏃
Sprinting
View GitHub Profile
async function checkBlocks(start, end) {
for (let i = start; i < end; i++) {
let block = await web3.eth.getBlock(i)
console.log(`[*] Searching block ${ i }`)
if (block && block.transactions) {
for (let txHash of block.transactions) {
let tx = await web3.eth.getTransaction(txHash)
if (account === tx.to.toLowerCase()) {
console.log(`[+] Transaction found on block ${ lastBlockNumber }`)
console.log({ address: tx.from, value: web3.utils.fromWei(tx.value, 'ether'), timestamp: new Date() })
@mempirate
mempirate / index.js
Last active November 22, 2019 08:37
'use strict'
const Web3 = require('web3')
const BuildTransactionChecker = require('./transactionChecker')
const CreateClient = require('./ethClient')
const web3 = CreateClient(Web3)
const checkBlock = BuildTransactionChecker(web3)
{
blockHash: '0xf881a143bde4964ccb4aad25c25ea0cfc49ea92d5cc4aab21a1d32a7b3c6a208',
blockNumber: 5482197,
from: '0x70432FE7B0D1130DA2e3c22Be4FB7F2ECc2883B3',
gas: 5000000,
gasPrice: '1000000000',
hash: '0x4ff7862abe6c0bc67c67c1c9551e8710279e138ab9b5e5f5b22b0c2074f595e8',
input: '0x0bc757e0000000000000000000000000000000000000000000000000',
nonce: 111934,
r: '0x2b55ad93866e91db2dfae93aee5ff35fb915530f0b2d30851ac814617847a09a',
{
difficulty: '2',
gasLimit: 10000000,
gasUsed: 717165,
hash: '0xefc05b503b822c2eeafe4cad047a6aa1587e265ed19a98a1879a3be92ab1a3fb',
miner: '0x0000000000000000000000000000000000000000',
nonce: '0x0000000000000000',
number: 5482184,
parentHash: '0xa24520a2a06ba6109f047d21adc005fdcd958e6387ae131f7aa759f34e050d7b',
receiptsRoot: '0x1415c72a4b0445f43ef4e3842041678fc892aaa400dbe81d590fd26b67ccf299',
'use strict'
module.exports = web3 => {
const account = 'YOUR_ETH_ADDRESS'.toLowerCase()
return async function checkLastBlock() {
let block = await web3.eth.getBlock('latest')
console.log(`[*] Searching block ${ block.number }...`)
if (block && block.transactions) {
for (let txHash of block.transactions) {
'use strict'
module.exports = Web3 => {
const provider = new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/YOUR_INFURA_API_KEY_HERE')
return new Web3(provider)
}
const Web3 = require('web3');
class TransactionChecker {
web3;
web3ws;
account;
subscription;
constructor(projectId, account) {
this.web3ws = new Web3(new Web3.providers.WebsocketProvider('wss://rinkeby.infura.io/ws/v3/' + projectId));
const Web3 = require('web3');
class TransactionChecker {
web3;
account;
constructor(projectId, account) {
this.web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/' + projectId));
this.account = account.toLowerCase();
}
if __name__ == "__main__":
run_algorithm(
capital_base = 1000,
data_frequency = "minute",
initialize = initialize,
handle_data = handle_data,
analyze = analyze,
exchange_name = "bitfinex",
algo_namespace = NAMESPACE,
base_currency= "usd",
def handle_data(context, data):
RSI_periods = 14
context.i += 1
if context.i < RSI_periods:
return
RSI_data = data.history(context.asset,
"price",