Skip to content

Instantly share code, notes, and snippets.

View rcmorano's full-sized avatar
🏠
Working from home

Roberto C. Morano rcmorano

🏠
Working from home
View GitHub Profile
@rcmorano
rcmorano / 10-cardano-addresses
Last active March 1, 2022 01:05
cardano-addresses baids
#!/bin/bash
function cardano-address-init() {
WALLETS_DIR=${HOME}/.cardano/wallets
MNEMONICS_SIZE=24
}
function cardano-address-testnet-init() {
@rcmorano
rcmorano / send-tx-thru-dandelion.sh
Created January 3, 2021 21:15
send-tx-thru-dandelion.sh
#!/usr/bin/env bash
set -e
NETWORK_MAGIC=1097911063
SOURCE_ADDRESS=$(cat ~/.cardano/wallets/testnet-repoc/payment.addr)
DESTINATION_ADDRESS=addr_test1vq87dp3djy6sz2yj23msw5d6ur96h0jsvks0p8mdwh2c0mghc68m3
PAYMENT_SKEY=${HOME}/.cardano/wallets/testnet-repoc/payment.skey
SEND_AMOUNT=10000000
@rcmorano
rcmorano / cdbs-functions.psql
Last active November 2, 2022 18:23
cardano-db-sync functions
# curl -X POST -H "Content-Type: application/json" -d '{ "data": { "addresses" : ["stake_test1uz605p766mvsyrufagjw5fepqfp8x9ff2ty2hzdrjuvuj8g5efx4w","stake_test1uq3zf47elmdxp92wgmcx4lrkjrlts5fffs36c7dz02d7faqye6l9j"] } }' -s "https://postgrest-api.testnet.dandelion.link/rpc/get_delegation_history_for_stake_address" | jq .
CREATE OR REPLACE FUNCTION get_delegation_history_for_stake_address(data json) RETURNS TABLE (epoch bigint, poolbech32 character varying, stake_address character varying, lovelace_rewards lovelace) AS $$
DECLARE
addresses text[];
BEGIN
addresses := (SELECT array_agg(replace(rec::text, '"', ''))
FROM json_array_elements(data->'addresses') rec);
RETURN QUERY (select reward.epoch_no, pool_hash.view as poolbech32, stake_address.view as stake_address, reward.amount as lovelace_rewards
from reward inner join stake_address on reward.addr_id = stake_address.id
inner join pool_hash on reward.pool_id = pool_hash.id
#!/usr/bin/env bash
set -e
# set -x
# This script creates, signs, and submits a transaction that creates some new tokens.
# It uses the output of the transaction from update-4.sh.
NETWORK_MAGIC=3
SOURCE_ADDRESS=$(cat ../base.addr)
@rcmorano
rcmorano / use-daedalus-bundled-cardano-cli.sh
Last active March 14, 2021 19:26
use-daedalus-bundled-cardano-cli (macos)
CARDANO_NODE_SOCKET_PATH=$(ps ax | grep -v grep | grep cardano-node.run.*socket | sed -e 's|.*\(--socket-path\) \(.*cardano-node.socket\) --.*|\2|g')
PATH=${PATH}:"/Applications/Daedalus Mainnet.app/Contents/MacOS"
cardano-cli get-tip --mainnet
@rcmorano
rcmorano / use-daedalus-bundled-cardano-cli.sh
Last active August 31, 2020 09:15
use-daedalus-bundled-cardano-cli (linux)
# apt install lsof coreutils
export CARDANO_NODE_SOCKET_PATH=$(pgrep -a cardano-wallet | sed -e 's|.*\(--node-socket\) \(.*cardano-node.socket\).*|\2|g')
CARDANO_BRIDGE_NIX_STORE_BINDIR="~/.daedalus/$(dirname $(lsof -np $(pgrep -af cardano-wallet | grep -v grep | awk '{print $1}') 2>/dev/null | grep bin.cardano-wallet | awk '{print $NF}' | sed -e 's|\(^/tmp.*\)/\(nix.*\)|\2|'))"
PATH=${PATH}:${CARDANO_BRIDGE_NIX_STORE_BINDIR}
cardano-cli get-tip --mainnet
@rcmorano
rcmorano / peers-info.csv
Last active November 24, 2021 16:35
cardano-mainnet-peers-info
IP COUNTRY CITY NETNAME ORGANIZATION / ISP
100.11.12.145 US Ashburn V4-VZO MCI Communications Services, Inc. d/b/a Verizon Business (MCICS) / unknown
100.14.55.71 US West Chester V4-VZO MCI Communications Services, Inc. d/b/a Verizon Business (MCICS) / Verizon Fios / Verizon Fios US
100.20.133.7 US West Chester AMAZO-ZPDX Amazon.com, Inc. (AMAZO-4) / Verizon Fios / Verizon Fios US
101.36.108.23 US West Chester UCLOUD-HK UCLOUD INFORMATION TECHNOLOGY (HK) LIMITED / Verizon Fios / Verizon Fios US
101.36.109.32 HK unknown UCLOUD-HK UCLOUD INFORMATION TECHNOLOGY (HK) LIMITED / /
102.130.116.45 ZA unknown HA-VPS-NET HA-VPS-NET / xneelo / xneelo
102.130.124.12 ZA unknown HA-VPS-NET HA-VPS-NET / xneelo / xneelo
102.37.6.155 ZA unknown Microsoft South Africa Allocations / xneelo / xneelo
103.103.192.229 ID unknown RACKH-ID Dedicated Hosting / Rackh Lintas Asia / pt
#!/bin/bash
# apt install -y netcat-traditional mtr jq curl
function find-optimal-peers-get-relay-hops() {
# This will stop counting hops on 5th imcp-unreachable hop
# or on finished, successful traceroute
mtr --json -c 1 -n -Z 1 -G 1 -U 5 ${1} | jq -r .report.hubs[].count | sort -n | tail -n1 | awk '{print $1}'
}
@rcmorano
rcmorano / find-optimal-peers
Created July 2, 2020 23:21
find alive and close peers for cardano-node (based on traceroute hops)
#!/bin/bash
# apt install -y netcat-traditional mtr jq curl
MAX_PEERS=20
PROBE_CONN_TIMEOUT=1
SOURCE_ROUTE_POINTER=4
TOPOLOGY_JSON_URL=https://explorer.shelley-testnet.dev.cardano.org/relays/topology.json
TOPOLOGY_JSON_FILE=/tmp/topology.json
PROXIMITY_TOPOLOGY_JSON=/tmp/proximity-topology.json
@rcmorano
rcmorano / gist:f4bcd5033376cd40ab544139262e6680
Created December 18, 2019 15:35
jormungandr-same-fragment_id-in-multiple-blocks
root@5bafa702cbe1:/data# jormungandr-get-txs-sent-from-local | jq '.fragment_id="d533cc12c2053833a28b490c97e349546404c7ab5d1345f9b5a5aee744967730"' | jq '.status.InABlock.block="1edcf1b0315d0106ddf16c5aeb4341da3386e01997fb125f8364c2d6c6da6ef0"'
{
"fragment_id": "d533cc12c2053833a28b490c97e349546404c7ab5d1345f9b5a5aee744967730",
"last_updated_at": "2019-12-18T10:42:19.253812841+00:00",
"received_at": "2019-12-18T10:29:04.245659185+00:00",
"received_from": "Rest",
"status": {
"InABlock": {
"block": "1edcf1b0315d0106ddf16c5aeb4341da3386e01997fb125f8364c2d6c6da6ef0",
"date": "4.26517"