Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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-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-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 / result.js
Last active May 16, 2021 09:50
Example code for Covalent article 5/5
/** Ethereum Chain **/
// Picking random address from https://etherscan.io/
getSwapTransactions('1', '0x6b873dedab01e217b964d1786ecad7f4ee77fbd8')
// Output for Ethereum Chain
Swapped 218024.165017 USDC -> 15912.620260763577 RAD (0x47892d5f5526462244278a55d6b4c94b39c93e485ede8bb668664c9da5f75e08)
Swapped 221395.535603 USDC -> 17975.98032142739 RAD (0x58e4aa8ef3ed5e851161e6f174011a47641938cec5b89d29940ee02b26c2cfa8)
Swapped 43529.645353 USDC -> 3584.958088860996 RAD (0x2f88838acb274c5cf0fcc529dc7b587644192706a1218cdbb5b433c6047be59c)
Swapped 1000 OCC -> 1046.4886117345636 RAD (0xffa5e832ba5b08c9e4dbdf8be20230190eeb21132c6fb42b421ff6169b7bd809)
@npty
npty / index.js
Last active May 21, 2021 09:59
biggest-swap-01
const Web3 = require('web3')
const routerAbi = require('./abi/router.json')
// The most common geth rpc is infura.
const GETH_RPC_ENDPOINT = "YOUR_GETH_RPC_ENDPOINT"
// First block on 2021-03-16 on Ethereum
const fromBlock = "12046295"
// 1Inch's AggregatorRouterV3 contract
@npty
npty / index.js
Last active May 21, 2021 09:57
biggest-swap-02
const Web3 = require('web3')
// The most common geth rpc is infura.
const GETH_RPC_ENDPOINT = "YOUR_GETH_RPC_ENDPOINT"
// First block on 2021-03-16 on Ethereum
const fromBlock = "12046295"
// 1Inch's AggregatorRouterV3 contract
const routerV3 = "0x11111112542D85B3EF69AE05771c2dCCff4fAa26"
@npty
npty / index.js
Last active May 21, 2021 10:03
biggest-swap-03
const Web3 = require('web3')
// The most common geth rpc is infura.
const GETH_RPC_ENDPOINT = "YOUR_GETH_RPC_ENDPOINT"
// First block on 2021-03-16 on Ethereum
const fromBlock = "12046295"
// 1Inch's AggregatorRouterV3 contract