Skip to content

Instantly share code, notes, and snippets.

View Techworker's full-sized avatar

Benjamin Ansbach Techworker

View GitHub Profile
<?php
namespace Shame;
use ZF\Apigility\Admin\Exception;
/**
* Class RpcServiceModel
*
* @todo wait for release of zf-apigility-admin
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0xABC
Migrations: 0xDEF
Saving successful migration to network...
... 0xABC
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying MyContract...
... 0xDEF
@Techworker
Techworker / getpendings.js
Created April 18, 2018 16:55
Checks getpendings with PascalCoin until a null value is found
const { exec } = require('child_process');
let aliveCounter = 0;
/**
* Executes the getpendings JSON RPC call and checks its response.
*/
function executeGetPendings() {
//console.log('exec');
@Techworker
Techworker / pascalcoin_payload.md
Last active June 8, 2018 09:18
PascalCoin payload

Payloads in PascalCoin

Each Operation in PascalCoin (transaction, buy account,..) holds a payload that contains arbitrary data and can be defined when executing an operation.

It can hold values up to 2^8 - 1 bytes or can simply be left empty.

This is a powerful feature often misunderstood or simply not used at all. Exchanges for example use the payload to identify incoming transactions and can associate them with their users. Or an online shop can use the payload to identify a transaction and associate it with an order.

The possibilities are endless, but for now we will stick with explaining how the payload is constructed, what methods to decrypt/encrypt a payload are available and how one can use the JSON RPC API to create transactions with (un)encrypted payloads.

// escrow example using pascalsocks
const PascalSocks = require('../client.js');
// name of transaction event
const EV_TX = PascalSocks.Events.Transaction.name();
// filter object
const Filter = PascalSocks.Filter;
const PascalSocks = require('../client.js');
const EV_TX = PascalSocks.Events.Transaction.name();
const Filter = PascalSocks.Filter;
const socket = new PascalSocks.Client('127.0.0.1:8080');
// show account
const shopAccount = '123456-78';
socket.connect().then(() => {
const PascalSocks = require('../client.js');
const EV_TX = PascalSocks.Events.Transaction.name();
const Filter = PascalSocks.Filter;
const socket = new PascalSocks.Client('127.0.0.1:8080');
// show account
const myAccount = '123456-78';
socket.connect().then(() => {
<script>
if (window !== window.top) {
var rIframe = {};
rIframe.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) {
@Techworker
Techworker / tx.php
Created August 24, 2018 07:52
Sample IOTA PHP transaction
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$container = new \IOTA\DI\IOTAContainer([]);
$transaction = new \IOTA\Type\Transaction($container->get(\IOTA\Cryptography\Hashing\CurlFactory::class), 'E9KERWN9XNHRPXLIVLXOGMTQLQCTARVHXNIKGRHMCPKHFWZFBODHDLJLCYKSWEETPKYZCMSOJVNBRBRFSKBBJPWLYUWVZWUFRCVYICAGWEALBTOLZILVZIFWSHOAVDHPDCQJQJHZPPKXITULYURGQDQJPMKEZY9XLXMQPJFISJRTUEKRLJVFQXIXJDRGQFGGSFHAUOBCAR9IWDKHLNROZQDNZMXJJMILVGXFMZJZBRRZLGHQFXJKHKMGKNLKTUINXZASURRKGFCMCXRBOOWUFYJTVDKCJHU99CVTCZKXQEB9GOEHZFMPICDCQORRKVUUHVJGCAJS9FXMONXOKOCSNADFTY9FETUADBOHNHFUAHRTBXXMOTKKOFDTZDGEDGXSDOGBRYEYGNXAOVLDWKY9QRATIMYAGTDXUVXEANZRLCHNQZNFUWQ9ORZNYXHGOOMEIHUKPQUSEIOYKLZPGNVOMXJVCKBNOJPUXNSISPNINNUSKRVMEVMUHLPUIBPBVRZHFYARQSFA9OKNEFTLDTSOHCR9YYXIXZ9HLMT9UMSHY9IJRZDZNCNQD9TXMSNRDSFMJUVPNGCWQTZARNWQVDOPUJNVHHBCUELQDDFTDKZ9SNJKFNAA9HNFYY9NOWNFZUEOG9LVL9FOLJJWEZEUXQSRFDSXIYIJITEYEDHFLKYDDXOMBPWIXPVIFYWNYVFSEHSXQMNCWICYNITFVPVOWFFA9LJ9LFWDKMPAX9OMAWTIBRSENFWBXNELQWHXAYNUWHGOHHMCXGESH9YNFZZYHKRRHIINXGLIOMDAJUHBFYWVAXK9DI
@Techworker
Techworker / Makefile
Last active September 28, 2018 10:24
Install digitalocean PascalCoin droplet
clean:
curl -s -X POST --data '{"jsonrpc":"2.0","method":"cleanblacklist","id":123}' http://localhost:4103 | json_pp
addnode:
curl -s -X POST --data '{"jsonrpc":"2.0","method":"addnode","params":{"nodes":"$(node)"}},id":123}' http://localhost:4103 | json_pp
status:
curl -s -X POST --data '{"jsonrpc":"2.0","method":"nodestatus","id":123}' http://localhost:4103 | json_pp --json_opt=canonical,pretty
watch: