Skip to content

Instantly share code, notes, and snippets.

@shortthefomo
shortthefomo / fetch.js
Last active May 4, 2024 16:20
Fetch USD price XRPL - DEVNET THREE ORACLE
const { XrplClient } = require('xrpl-client')
const xrpl = new XrplClient(['wss://s.devnet.rippletest.net:51233'])
// change this code to a different currency code one of others published, EUR/ZAR/MXN/JPY/BTC/USDT......
let code = 'USD'
if (code.length > 3) {
const characters = Buffer.from(code, 'utf8').toString('hex')
let s = '0'
for (let index = 1; index < 40 - characters.length; index++) {
@shortthefomo
shortthefomo / example.js
Created November 3, 2023 14:42
payment
const { XrplClient } = require('xrpl-client')
const payment = {
"TransactionType" : "Payment",
"Account" : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Destination" : "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
"Amount" : {
"currency" : "USD",
"value" : "1",
"issuer" : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"
@shortthefomo
shortthefomo / .txt
Last active October 1, 2023 20:05
exchange pairs three
{
tidex: [ 'USDT', 'BSDT', 'USDC', 'BTC', 'ETH' ],
localtrade: [ 'USDT', 'BTC' ],
'ripio-trade': [ 'BRL' ],
coinbase: [ 'USD', 'EUR', 'GBP', 'USDT' ],
ndax: [ 'CAD', 'USD'],
trubit: [ 'USDT', 'USDC', 'BTC', 'MMXN' ],
pionex: [ 'USDT', 'BTC' ],
changelly: [ 'USDT', 'USDC', 'DAI', 'BTC', 'ETH' ],
bitget: [ 'BTC', 'ETH', 'USDT', 'USDC' ],
@shortthefomo
shortthefomo / uri_token_hook.c
Last active August 1, 2023 20:06
URIToken hook
#include "hookapi.h"
#define MIN_XRP_AMOUNT 100000000 // 100 XRP in drops
#define ISSUER_ACCOUNT "rL4usRexjgCPTG8RoZvVHXmUjuYdWbRx2T"
#define MY_ACCOUNT "rL4usRexjgCPTG8RoZvVHXmUjuYdWbRx2T"
int64_t hook(uint32_t reserved) {
TRACESTR("HookOnURITokenCreateSellOffer: Start.");
@shortthefomo
shortthefomo / mem.js
Last active July 26, 2023 17:52
websocket memory
const WebSocketServer = require('ws').Server
// dissable the perMessageDeflate this causes memory fragmentation!!!!!
const wss = new WebSocketServer({ port: process.env.APP_PORT, perMessageDeflate: false })
wss.on('connection', (ws, req) => {
ws.on('message', (data) => {
// do something
})
ws.on('close', () => {
'use strict'
/**
* Keep a transaction window.
*/
module.exports = class TransactionWindow {
// First in First out
constructor(name, time = null) {
this.name = name
@shortthefomo
shortthefomo / fetch.js
Last active February 24, 2023 14:56
Fetch all transactions on an account.
const { XrplClient } = require('xrpl-client')
const client = new XrplClient()
const account = 'rJeBz69krYh8sXb8uKsEE22ADzbi1Z4yF2'
const account_tx = {
'id': 2,
'command': 'account_tx',
'account': account,
'ledger_index_min': -1,
'ledger_index_max': -1,
@shortthefomo
shortthefomo / account-info.js
Created January 18, 2023 03:58
Get account info
import { XrplClient } from "xrpl-client"
const client = new XrplClient("wss://xrplcluster.com") // add node ws here you want to connect to
const res = await client.send({
"id": 2,
"command": "account_info",
"account": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
"strict": true,
"ledger_index": "current",
"queue": true
@shortthefomo
shortthefomo / pathing-example.js
Last active January 17, 2023 00:45
pathing-example.js
// to start off call pathFind() that will get all paths to what you define in the command aka what currency you want ouy.
// then you will need to render a button for each paths result (commented below) I use vue so can get boiler plate as well for that but wietses example where i took it from
// so when user selects pair it then calls into makepathingPayment(path) with the path they are paying with.
rand(size) {
return [...Array(size)]
.map(() => Math.floor(Math.random() * 16).toString(16))
.join('');
},
@shortthefomo
shortthefomo / ntfDeriveSale.js
Last active November 5, 2022 01:35
XTPL NFT deriveSale
//pass tx as returned from ledger
ntfDeriveSale(tx) {
let hash = tx.hash || tx.transaction.hash
let trade = {}
let taker = tx.Account
for(let affected of (tx.meta || tx.metaData).AffectedNodes){
let node = affected.DeletedNode
if(!node || node.LedgerEntryType !== 'NFTokenOffer')
continue