npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

madeline-ton

v1.0.10

Published

Pure JS client-side implementation of the Telegram TON blockchain protocol

Downloads

3

Readme

MadelineTon.js

Pure JS client-side implementation of the Telegram TON blockchain protocol.

Interact directly with the TON blockchain with no middlemans, directly from your browser!

This is possible thanks to a client-side implementation of the ADNL P2P protocol (whitepaper).
Connection to the liteservers is made through a simple websocket proxy that simply acts as a TCP <=> websocket proxy.

All cryptography is done exclusively in the browser, allowing fully secure interaction with the chosen TON node.

The client is fully asynchronous, making use of workers and/or browser webcrypto APIs for cryptography (curves & AES).

Possible applications are entirely client-side off-chain components for a distributed TON project; API explorers; and much more!


This is my submission for the second stage of the TON blockchain contest.

Initially, I intended to submit an OUTPACE-inspired ad network controlled by the TON blockchain.

However, as I studied the concepts of OUTPACE payment channels, I realized that OUTPACE is a suboptimal solution in the context of the TON blockchain.

The TON blockchain is an incredibly powerful and flexible blockchain: In the whitepaper, the TON blockchain is proposed as a solution to all scalability issues of previous blockchains: with support for infinite sharding and most importantly custom workchains, the need for side-chain applications like PLASMA and OUTPACE is removed, allowing developers to simply write their own workchain instances with custom rules.

I initially decided to develop a custom TON workchain for the needs of my ad network, but then realized that I first needed a way to interact with the TON network, first.
Which is why I developed this pure-JS lite-client, which can be directly downloaded by the users viewing ads, and used to directly send an external event to the on-chain ad network smart contract.

I initially intended to create also a very basic ad network smart contract, but then decided to focus all efforts on finishing this library, first.

TL-B parser, fift interpreter and TVM are all on the roadmap in this order (TL-B in particular should be pretty easy with the current TL parser and my bitstream.js, with the only real problem being template parameters (damn you Unary)). BOC deserialization is implemented in lite.js (builder/slice is represented by a BitStream, a cell is a Uint8Array).

Other projects

MadelineProto with TON integration - fully separate, standalone, async PHP implementation of the TON lite-client protocol.

Install

Yarn:

yarn add madeline-ton

NPM (ew :):

npm install madeline-ton

Usage

This project provides an ADNL protocol lite-client, allowing to fetch blocks from the TON blockchain and send ext messages to the validators.

import Lite from 'madeline-ton';

const liteClient = new Lite()

liteClient.connect().then(async () => {
    console.log("Connected!")

    console.log(await liteClient.getVersion())
    console.log(await liteClient.getTime())
    console.log(await liteClient.methodCall('liteServer.getMasterchainInfo'))

    await liteClient.last()
    const state = await liteClient.methodCall('liteServer.getAccountState', {
        account: 'EQAnoW6-IZHisrcCsiSFDewx79W4oYfocKveh3b44uNIIepe'
    })
    console.log(state)
    console.log(liteClient.slice(state.state)) // Deserialize BOC
})

By default, the lite client will connect and authorize to the endpoints specified in the testnet config file, however you can provide your own config to the constructor (all fields are optional and will be filled automatically if missing):

const liteClient = new Lite({
    config: liteConfig, // Contents of ton-lite-client-test1.config.json
    wssProxies: {       // Websocket proxy endpoints, per-IP
        1137658550: 'wss://ton-ws.madelineproto.xyz/testnet'
    },
    schemes: {
        1: schemeTON, // ton API TL scheme JSON file
        2: schemeLite // lite API TL scheme JSON file
    },
})

For a list of methods that can be used, take a look at the lite scheme files (in a few days will provide an automatically-generated doc here).

The project is actually based on yet another project of mine, a pure JS Telegram MTProto client (madeline.js) which will be released soon.


Copyright 2019 Daniil Gentili

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.