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 🙏

© 2026 – Pkg Stats / Ryan Hefner

typetology

v0.0.3

Published

Typescript bindings for Ontology smart contracts

Readme

TypeTology

Typescript binding script for Ontology smart contracts. Typetology is motivated and referred from TypeChain, a good script that binds typescript for Ethereum smart contract.

Install

Typetology is available through npm.

npm install --save-dev typetology

Usage

You need Ontology smart contract ABI files for generating smart contract class. Also, the generated contract class name is the same with the file name (without file extension), so you should name the ABI file with the class name you want. (such as DomainContract.json)

typetology [--force | -f] [--out | -o (directory)] [abi files(glob pattern)]

| Option | Required | Description | |------------------|:--------:|-------------| | --force, -f | false |overwrite if file already exists| | --out, -o | true | output directory for generated typescript codes|

Followings are example for DomainContract.json ABI file generated from the Ontology SmartX IDE example.

{
  "hash":"0xfd2dc90d8bdc551798c268291c81333ae7905eed",
  "entrypoint":"Main",
  "functions":[
    {"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},
    {"name":"Query","parameters":[{"name":"domain","type":"String"}],"returntype":"ByteArray"},
    {"name":"Register","parameters":[{"name":"domain","type":"String"},{"name":"owner","type":"ByteArray"}],"returntype":"Boolean"},
    {"name":"Transfer","parameters":[{"name":"domain","type":"String"},{"name":"to","type":"ByteArray"}],"returntype":"Boolean"},
    {"name":"Delete","parameters":[{"name":"domain","type":"String"}],"returntype":"Boolean"}
  ],
  "events":[]
}
/* tslint:disable */

import { AbiInfo, RestClient, RpcClient, WebsocketClient } from 'ontology-ts-sdk';
import { TypetologyContract, DeferredTransactionWrapper } from './typetology.runtime';

const abi = {
  ... // ABI
}; 

export class DomainContract extends TypetologyContract {
  public readonly abiInfo: AbiInfo = AbiInfo.parseJson(JSON.stringify(abi));
  
  constructor(client: RestClient | RpcClient | WebsocketClient) {
    super(client);
  }

  public MainTx(
    operation: string,      // String,
    args: any,      // Array
  ): DeferredTransactionWrapper {
    return new DeferredTransactionWrapper(
      this,
      'Main',
      [operation, args]
    );
  }

  public QueryTx(
    domain: string,      // String
  ): DeferredTransactionWrapper {
    return new DeferredTransactionWrapper(
      this,
      'Query',
      [domain]
    );
  }

  public RegisterTx(
    domain: string,      // String,
    owner: string | Buffer,      // ByteArray
  ): DeferredTransactionWrapper {
    return new DeferredTransactionWrapper(
      this,
      'Register',
      [domain, owner]
    );
  }

  public TransferTx(
    domain: string,      // String,
    to: string | Buffer,      // ByteArray
  ): DeferredTransactionWrapper {
    return new DeferredTransactionWrapper(
      this,
      'Transfer',
      [domain, to]
    );
  }

  public DeleteTx(
    domain: string,      // String
  ): DeferredTransactionWrapper {
    return new DeferredTransactionWrapper(
      this,
      'Delete',
      [domain]
    );
  }

}

You can send a transaction by this way.

import { RestClient, Crypto } from 'ontology-ts-sdk';
import { DomainContract } from './contract/DomainContract';

const client = new RestClient();
const contract = new DomainContract(client);

// wallet address and private key for payer
const privateKey = new Crypto.PrivateKey('75de8489fcb2dcaf2ef3cd607feffde18789de7da129b5e97c81e001793cb7cf');
const walletAddress = new Crypto.Address('AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve');

// register a domain "typetology" as the address "AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve"
contract.RegisterTx('typetology', Buffer.from('AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve')).send({
  payer: walletAddress,
  privateKey: privateKey
}).then(console.log);

You can receive the result like below.

{ Action: 'sendrawtransaction',
  Desc: 'SUCCESS',
  Error: 0,
  Result: 'd6a605c1f03839807af80ea67f0140410c320ed848a241b4b28ce87b77ac7eab',
  Version: '1.0.0' }

You can also get a storage data by calling getStorage(key: string). It doesn't need any wallet. Also, be careful that the result data is hex string, so if the data is string (not blob), you need to convert it by using hexstr2str method in utils library in ontology-ts-sdk.

import { RestClient, utils } from 'ontology-ts-sdk';
import { DomainContract } from './DomainContract';

const client = new RestClient();
const contract = new DomainContract(client);

contract.getStorage('typetology').then((data) => console.log('owner :', utils.hexstr2str(data)));

The result is like below.

owner : AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve

License

GNU Lesser General Public License v3.0