Skip to content

Instantly share code, notes, and snippets.

View valstu's full-sized avatar
👋
Building Intentfaces

Valtteri Karesto valstu

👋
Building Intentfaces
View GitHub Profile
@valstu
valstu / README.md
Created August 12, 2024 11:06 — forked from markuman/README.md
🗺️ OSM - self host the entire planet 🌎 in ~30 minutes 🚀

🗺️ OSM - self host the entire planet 🌎 in ~30 minutes 🚀

TL;DR

mkdir osm
wget -O osm/planet.mbtiles https://hidrive.ionos.com/api/sharelink/download?id=SYEgScrRe
podman run -ti --rm -p 9000:9000 --name sms -v $(pwd)/osm/:/data/ registry.gitlab.com/markuman/sms:latest
firefox http://localhost:9000
import {
accept,
emit,
etxn_details,
etxn_fee_base,
etxn_reserve,
hook_account,
ledger_seq,
otxn_field,
rollback,
import {
accept,
emit,
etxn_details,
etxn_fee_base,
etxn_reserve,
hook_account,
ledger_seq,
otxn_field,
rollback,

Carbon

Carbon hook sends a percentage of outgoing payments to a dedicated account.

The beneficiary account is hard-coded, so while the default version of carbon.c works, it works with an account that cannot be imported into Hooks Builder (unless you know its secret key). See later examples for how to parametrize a hook.

to test:

  • make sure Hooks Builder has at least 3 accounts: Alice, Bob and Carol
  • in carbon.c, change hardcoded beneficiary to Carol account
  • compile carbon.c and deploy it to Alice account
@external("env", "_g")
export declare function GUARD(id: i32, maxiter: i32): i32
@external("env", "accept")
export declare function ACCEPT(read_ptr: string, read_len: i32, err: i64): i64
@external("env", "trace")
export declare function TRACE(mread_ptr: string, mread_len: i32, dread_ptr: string, dread_len: i32, as_hex: i32): i64
////////////////////
@external("env", "_g")
export declare function _g(id: i32, maxiter: i32): i64
@external("env", "accept")
export declare function accept(read_ptr: string, read_len: i32, err: i64): i64
@external("env", "trace")
export declare function TRACE(mread_ptr: string, mread_len: i32, dread_ptr: string, dread_len: i32, as_hex: i32): i64
////////////////////////
import lib from "https://esm.sh/xrpl-accountlib?bundle";
import bin from "https://esm.sh/ripple-binary-codec?bundle";
import { XrplClient } from "https://esm.sh/xrpl-client?bundle";
// Alice
const notary_account = '{{ notary_account }}';
// Bob
const proposer_secret = '{{ proposer_secret }}';
const proposer_account = '{{ proposer_account }}';
<html>
<head>
<script type="module">
import lib from "https://esm.sh/xrpl-accountlib?bundle";
import bin from "https://esm.sh/ripple-binary-codec?bundle";
import { XrplClient } from "https://esm.sh/xrpl-client?bundle";
// Alice
@valstu
valstu / aa
Last active June 3, 2022 13:15
// oj