Skip to content

Instantly share code, notes, and snippets.

View kianenigma's full-sized avatar

Kian Paimani kianenigma

View GitHub Profile
export async function RcTICheck(): Promise<void> {
const rcApi = await getApi("wss://paseo-rpc.n.dwellir.com");
const ahApi = await getApi("wss://asset-hub-paseo-rpc.n.dwellir.com");
let rcSent = new BN(0);
let ahReceived = new BN(0);
{
const start = await rcApi.query.rcMigrator.migrationStartBlock() as Option<BlockNumber>;
const startHash = await rcApi.rpc.chain.getBlockHash(start.unwrap());
const end = await rcApi.query.rcMigrator.migrationEndBlock() as Option<BlockNumber>;
@kianenigma
kianenigma / polkadot-sdk-currency.rs
Created September 18, 2025 00:44
Permutations of combining Polkadot-SDK's Currency related primitives.
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@kianenigma
kianenigma / wifi-cleanup.sh
Created September 16, 2025 10:39
wifi-cleanup.sh
#!/bin/bash
# WiFi Network Cleanup Tool
# This script helps you review and remove unwanted WiFi networks
# Colors for better readability
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
@kianenigma
kianenigma / polkadot-sync-cron
Last active May 18, 2025 10:02
Cron job spec to run Polkadot nodes in a crontab for a few mins every hour, enough to keep them synced.
# create these functions in some bash file to be imported in the crontab
# crontab in macos is weird and cannot load normal zsh functions.
# cat ~/.shell_functions
function base_run_chain() {
chain=$1
port=$2
sync=$3
polkadot --chain $chain \
--sync $sync \
// rought file paths writte above each item.
// pallet-balances::weights.rs
trait WieghtInfo {
fn transfer() -> u32;
}
// pallet-balances
trait Config {
type WeightInfo: weights::WeightInfo;
import { ApiPromise, WsProvider } from "@polkadot/api";
import axios from "axios";
import { writeFileSync } from "fs";
import { strict as assert } from 'assert'
async function findLastNicksBlock(block: number, key: string) {
while (true) {
let next = block + 1;
const data = await axios.post(`https://kusama.api.subscan.io/api/scan/block`, {
"block_num": next
import { ApiPromise, WsProvider } from "@polkadot/api";
import { BN } from "@polkadot/util";
import axios from "axios";
async function scrapeSubscan(api: ApiPromise) {
const [from, to] = [3899547, 4876134];
const DOTS = new BN(10000000000);
const HUNDRED = new BN(100);
const REFUND = new BN(new BN(495).mul(DOTS).div(HUNDRED))
const key = process.env['API'] || "DEFAULT_KEY";
@kianenigma
kianenigma / bags.rs
Created November 2, 2021 11:56
Simple script to see the status of an account in bags-list. Just paste this in Polkadot JS App's Javascript page.
// This must be a STASH account.
const yourAccount = "xxx";
// This is your node in the bags list. Use `node.prev` and `.next` to see where you are located.
const node = await api.query.bagsList.listNodes(yourAccount);
// This is the bag to which you belong.
const bagUpper = api.createType("Balance", node.toJSON().bagUpper);
// This is the list of all the bags.
const bagThresholds = api.consts.bagsList.bagThresholds.map((x) => api.createType('Balance', x));
//
// This function will always indicate that for an account with stake (aka, weight) `w`, to which bag they belong to.
@kianenigma
kianenigma / staking-updates.md
Last active October 5, 2022 00:58
Polkadot's Monthly Staking Update

DEPRECATED: Polkadot Staking Progress Report

I started this gist as an index for all of the staking reports. Almost a year in, we migrated everything to https://polkadot.network/tag/staking-updates/. This page will no longer be updated:

1 kianenigma@build-host[13:46] ~/substrate-sync (git)-[2ef0f1cb2] % cargo run -- --tmp --dev :(
Finished dev [unoptimized + debuginfo] target(s) in 0.62s
Running `target/debug/substrate --tmp --dev`
2021-01-13 13:47:34 Running in --dev mode, RPC CORS has been disabled.
2021-01-13 13:47:34 Substrate Node
2021-01-13 13:47:34 ✌️ version 2.0.0-2ef0f1cb2-x86_64-linux-gnu
2021-01-13 13:47:34 ❤️ by Parity Technologies <[email protected]>, 2017-2021
2021-01-13 13:47:34 📋 Chain specification: Development
2021-01-13 13:47:34 🏷 Node name: raspy-wealth-5222
2021-01-13 13:47:34 👤 Role: AUTHORITY