Skip to content

Instantly share code, notes, and snippets.

View jimscarver's full-sized avatar

Jim Whitescarver jimscarver

View GitHub Profile
: collect rev transactions to update balances.
end=${2-4ce82f16b5d214d18c4538ea5f4e7ea61e7660e2c7ce8914b68b629766c09f3c}
#TODO let latest block should not be hard coded.
latest=${1-0c436d462b09f5c2ab4ab791522729df5ec97ff994cba997e133cb32e8223d7c}
while [ $latest != $end ]; do
curl -s https://observer.services.mainnet.rchain.coop/api/block/$latest >/tmp/rho
latest=$(jq -r '.blockInfo.parentsHashList[0]' </tmp/rho)
#echo $latest
deploys=$(jq '.deploys' </tmp/rho)
#echo $deploys
for k in $(cat addresses.txt); do
echo 'match ["'$k'"] {
[pubkey] => {
new
return,
revAddress(`rho:rev:address`),
lookup(`rho:registry:lookup`),
RevAddress(`rho:rev:address`),
stdout(`rho:io:stdout`),
@jimscarver
jimscarver / mq.rho
Last active July 30, 2021 19:41
simple publish subscribe message queue
new logList, result(`rho:io:stdout`), stdout(`rho:io:stdout`), log, mq in {
result!("starting") |
contract mq(ret) = {
new head, tail, pub, sub, isend in {
tail!(*head) |
ret!(*pub, *sub, *isend) |
contract sub(listener) = {
new loop, ack in {
loop!(*head) |
contract loop(curr) = {
match [3] {
[height] => {
new result, stdout(`rho:io:stdout`), move, ack, log, list in { // create names/channels needed
// towers of hanoi - use EXPLORE
// derived from prolog example https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_3.html
// Move a pile of disks of [height] from the "left" peg to the "right" peg
// using the "center" peg as an intermetiate place to put them.
// Never put a larger disk on a smaller on.
// Then write to the ack channel to acknowledge completion
move!(height,"left","right","center", *ack) |
<!DOCTYPE html>
<!-- saved from url=(0029)https://iancoleman.io/shamir/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Shamir Secret Sharing Scheme</title>
<style>/*!
* Bootstrap v3.3.6 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
new return(`rho:rchain:deployId`), lookup(`rho:registry:lookup`), ret, alicePurseCh, bobPurseCh,
initialAlicePurseBalanceCh, initialBobPurseBalanceCh,successCh, finalAlicePurseBalanceCh,
finalBobPurseBalanceCh, stdout(`rho:io:stdout`) in {
lookup!( `rho:id:rgd9xzheeo33tn765wjijox7kd7ciar4jr7qkq9g64n4qmdxxrd35m` , *ret) |
for (mint <- ret) {
stdout!("got mint") |
match (100000000, 1000) {
(aliceAmt, bobAmt) => {
stdout!("got init bals") |
// Alice's purse has maximum balance.
<script>
const revBalance = addr => `
new return, rl(\`rho:registry:lookup\`), RevVaultCh, vaultCh in {
rl!(\`rho:rchain:revVault\`, *RevVaultCh) |
for (@(_, RevVault) <- RevVaultCh) {
@RevVault!("findOrCreate", "${addr}", *vaultCh) |
for (@maybeVault <- vaultCh) {
match maybeVault {
(true, vault) => @vault!("balance", *return)
(false, err) => return!(err)

Keybase proof

I hereby claim:

  • I am jimscarver on github.
  • I am jimscarver (https://keybase.io/jimscarver) on keybase.
  • I have a public key whose fingerprint is B104 52B5 F197 5F7E 2CDC BFB6 6F9A 0757 7103 12A2

To claim this, I am signing this object:

/ Rholang Abstract Graph Node Object exposing properties and links, gaving an object wrapper, super, and public key
// Nodes can be used for hierarchical directories with loops suitable for use with graphql providing for user name spaces.
// simple Object capability wrapper proxy
// prevents direct access to object model channels
new Object, stdout(`rho:io:stdout`) in {
contract Object(class, @instance, ret) = {
new this in {
ret!(bundle+{*this}) |
//instance methods
contract this(@method, args) = {