Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ledger-sdk

Read the register without trusting anyone, including us.

Resolve a ticker to the one contract that means it, replay corporate actions with their flags intact, and read balances at a block. Every call is public RPC.

License Node Runtime deps


No API key, no endpoint of ours. The only dependency is @stockledger/core, which is pure arithmetic. If this package vanished, the same answers would still be one curl away - that is what makes them worth something.

Install

npm install @stockledger/sdk

Resolve a ticker

const { LedgerClient } = require('@stockledger/sdk');
const client = new LedgerClient();

const r = await client.resolveTicker('AAPL');
// { searched: 1127, branded: 4, resolved: '0xaf3d76f1834a1d425780943c99ea8a608f8a93f9' }

resolved is null when the answer is not unique. That is a result, not an error: on a chain where 346 contracts copy the naming scheme, an honest null beats a confident guess.

Replay the register

const r = await client.register('0xaf3d76f1834a1d425780943c99ea8a608f8a93f9');

r.absolute;   // 1000566080000000000n   the last `to` value    <- trust this
r.composed;   // every step multiplied together                <- not this
r.agree;      // true here, false for CRWD and WEEK
r.entries[0].flags;   // [] , or [{ kind: 'duplicate', of: 978630 }]

API

Call Returns
token(address) name, symbol, decimals, supply, live multiplier, implementsScaledUI
identify(address) genuine / impostor / no-code, decided by bytecode
resolveTicker(ticker) every candidate with a verdict, plus resolved or null
events({ address }) decoded UIMultiplierUpdated logs
register(address) entries with flags, plus both readings and whether they agree
balanceOf(address, holder, block) raw balance, unscaled, on purpose

balanceOf returns the raw balance and never the UI amount. Scaling is a decision, and the SDK makes you make it: applying the multiplier twice, once here and once on a Chainlink price that already includes it, is the single most common way to get this wrong.

Architecture

rpc.js       JSON-RPC + explorer transport, fetch-injectable for tests
abi.js       five selectors and one event, hand-encoded, no coder dependency
client.js    the read surface, built on @stockledger/core for the arithmetic

Run it

npm test                                 # 13 tests, stubbed transport, no network
node examples/resolve.js AAPL            # live: 1127 candidates, 1 genuine
node examples/register.js 0xaf3d...93f9  # live: the Apple dividend, both readings

License

MIT. See LICENSE.


Part of Stock Ledger - the register of record for tokenized equities.

Docs | Core | Checks

About

Read tokenized-equity corporate actions off Robinhood Chain: resolve a ticker to its real contract, replay the register, read balances at a block.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages