Skip to content

Instantly share code, notes, and snippets.

@toknT
toknT / btc-zmq-demo.php
Last active January 10, 2020 03:18
php bitcoind zeromq sub demo
<?php
// require zmq extension in ubuntu run `sudo apt install php-zmq` to install it
$context = new \ZMQContext();
$subscriber = new \ZMQSocket($context, \ZMQ::SOCKET_SUB);
$subscriber->connect("tcp://192.168.1.136:28332");
$subscriber->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, "hashblock");
$subscriber->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, "hashtx");
$subscriber->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, "rawblock");
@toknT
toknT / main.js
Created October 29, 2019 04:10
rpc-proxy
var httpProxy = require('http-proxy');
const rpcPort = process.env.RPC_PORT;
const exportPort = process.env.EXPORT_PORT;
httpProxy.createProxyServer({ target: `http://127.0.0.1:${rpcPort}` }).listen(exportPort);
{
"apps": [
{
"name": "artisan-queue-work",
"script": "artisan",
"args": [
"queue:work",
"--tries=1",
"--sleep=1"
],
@toknT
toknT / ecRecoverTest.php
Created November 21, 2018 02:59
php eth
<?php
/**
* example of package https://github.com/digitaldonkey/ethereum-php
*/
require __DIR__ . '/vendor/autoload.php';
use Ethereum\DataType\EthD;
use Ethereum\Ethereum;
// https://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html#recover
$recoveredAddr = Ethereum::personalEcRecover('Some data', new EthD('0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c'));