Skip to content

Instantly share code, notes, and snippets.

@npty
npty / step-4.js
Last active May 16, 2021 09:51
Example code for Covalent article 4/5
// Colorized output
const chalk = require('chalk');
// Step 4: Sanitize and format output
function getTransferEventParams({ tokens, transaction, nativeTokenSymbol, address }) {
// Extracts `Transfer` event
const transferEvents = transaction.log_events
.filter(({ decoded }) => decoded && decoded.name === 'Transfer')
// Filters `Transfer` event as the given address is the sender.
@npty
npty / step-3.js
Last active May 16, 2021 09:51
Example code for Covalent article 3/5
// Step 3: Filters transactions out in the following cases:
// 1. Swap event doesn't exist
// 2. Mint event exists
const _swapTransactions = _transactions.filter(({ log_events, value }) => {
const events = log_events
.filter(({ decoded }) => decoded)
.map(({ decoded }) => decoded)
const eventNames = events
.map(({ name }) => name)
@npty
npty / step-2.js
Last active May 16, 2021 09:51
Example code for Covalent article 2/5
const { get } = require('axios').default
// Step 2: Fetches transaction history from given chainId and address
const _transactions = await get(`https://api.covalenthq.com/v1/${chainId}/address/${address}/transactions_v2/`, {
params: {
'page-size': 100 // Number of transactions per page
}
}).then(result => result.data.data.items)
@npty
npty / step-1.js
Last active May 16, 2021 09:50
Example code for Covalent article 1/5
const { get } = require('axios').default
// Define native token symbol for given chain
let nativeTokenSymbol;
switch (chainId) {
case '1':
nativeTokenSymbol = 'ETH'
break;
case '56':
nativeTokenSymbol = 'BNB'
@npty
npty / aleo100.service
Last active May 2, 2021 07:50
minimum 100 connections
Description=Aleo systemd service
After=network.target
[Service]
User=aleo_service
Restart=always
RestartSec=10
ExecStart=/var/lib/aleo-data/snarkos \
--max-peers 150 \
--min-peers 100 \
@npty
npty / spacemesh.log
Created April 20, 2021 08:16
Full log of go-spacemesh node.
This file has been truncated, but you can view the full file.
Apr 20 04:22:51 spacemesh-falcon-node spacemesh[22987]: 2021-04-20T04:22:51.265Z INFO f8bb0.sync .peers now connected {"node_id": "f8bb0dfa9f7384841c8c28fff702e0d4aedafb02641ffb80feb0ac48028a37fa", "n_peers": 8}
Apr 20 04:22:51 spacemesh-falcon-node spacemesh[22987]: 2021-04-20T04:22:51.551Z INFO f8bb0.sync epoch has atxs {"node_id": "f8bb0dfa9f7384841c8c28fff702e0d4aedafb02641ffb80feb0ac48028a37fa", "epoch_id": 11}
Apr 20 04:22:51 spacemesh-falcon-node spacemesh[22987]: 2021-04-20T04:22:51.611Z INFO f8bb0.sync handle atx hash request {"node_id": "f8bb0dfa9f7384841c8c28fff702e0d4aedafb02641ffb80feb0ac48028a37fa", "requestId": "886b76ed-7404-4fdd-a704-d662d3ce12cf", "sessionId": "1120c6b4-7c06-4f95-8ddb-d758ff8c6aa7", "epoch_id": 11}
Apr 20 04:22:51 spacemesh-falcon-node spacemesh[22987]: 2021-04-20T04:22:51.614Z INFO f8bb0.atxDb returned epoch atxs {"node_id