Skip to content

Instantly share code, notes, and snippets.

@domob1812
domob1812 / abi.json
Last active April 11, 2023 17:33
Proof of concept Python script for using a meta transaction to approve WCHI on Polygon
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"address payable","name":"relayerAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"functionSignature","type":"bytes"}],"name":"MetaTransactionExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"i
@domob1812
domob1812 / xid-polygon-password.py
Created July 13, 2022 07:32
Script for generating XID passwords on EVM chains like Polygon
#!/usr/bin/env python3
# Copyright (C) 2022 The Xaya developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
CLI script to generate a XID password for a Polygon (or other EVM)
Xaya identity.
"""
@domob1812
domob1812 / build.sh
Created August 26, 2019 08:07
Test code for SQLite session extension and UNIQUE constraints
#!/bin/sh -e
PKGS="sqlite3 libglog"
CFLAGS="`pkg-config --cflags ${PKGS}` -std=c++14 -Wall -Werror -pedantic"
CFLAGS="${CFLAGS} -std=c++14 -Wall -Werror -pedantic"
CFLAGS="${CFLAGS} -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
LIBS=`pkg-config --libs ${PKGS}`
g++ ${CFLAGS} ${LIBS} test.cpp -o test
@domob1812
domob1812 / build.sh
Last active August 15, 2019 08:13
libjson-rpc-cpp threading deadlock
#!/bin/sh -e
jsonrpcstub test.json --cpp-client=TestRpcClient --cpp-client-file=client.h
jsonrpcstub test.json --cpp-server=TestServerStub --cpp-server-file=serverstub.h
PKGS="libjsonrpccpp-client libjsonrpccpp-server libglog"
CFLAGS="`pkg-config --cflags ${PKGS}` -std=c++14 -Wall -Wextra -Werror"
LIBS="-L/usr/local/lib `pkg-config --libs ${PKGS}` -lpthread"
g++ -g -O0 -o client client.cpp ${CFLAGS} ${LIBS}
@domob1812
domob1812 / sqlite_session_test.cpp
Created January 6, 2019 13:11
SQLite session fails with "WITHOUT ROWID" and "INSERT OR REPLACE"
#include <sqlite3.h>
#include <glog/logging.h>
#include <cstdlib>
#include <iostream>
int
printResults (void*, int numColumns, char** values, char** columns)
{
@domob1812
domob1812 / batch_test.py
Last active November 23, 2018 07:27
Tests Xaya Core with very large batch RPC requests
#!/usr/bin/env python3
# Test for https://github.com/xaya/xaya/issues/72.
# Should be run from within Xaya's test/functional directory.
from test_framework.util import str_to_b64str
import http.client
import json
import urllib.parse
@domob1812
domob1812 / pickWinner.py
Created August 30, 2018 06:29
Provably-fair selection "k out of n"
#!/usr/bin/env python3
# This script computes an ordered list of k random integers from the range
# [1, n] (both inclusive). This is done in a provably fair way based on
# some hex seed (may be a Bitcoin block hash, for instance).
import codecs
import hashlib
import math
import struct
@domob1812
domob1812 / xaya-wallet-example.py
Created August 6, 2018 09:45
Example Python script for Xaya wallet interactions
#!/usr/bin/python
# This is available in "python-jsonrpclib" on Debian/Ubuntu systems.
import jsonrpclib
import json
# Set according to your xaya.conf or the authentication cookie. Change port
# to 18396 for testnet and to 18493 for regtest.
user = "..."