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

@0xintuition/protocol

v2.0.2

Published

Intuition Protocol

Downloads

587

Readme

Intuition Protocol

Intuition Protocol is a TypeScript/JavaScript SDK and smart contract interface for interacting with the Intuition onchain knowledge graph. It provides utilities for creating, managing, and querying atoms and triples, as well as encoding and parsing contract calls and events.

Version Downloads/week

Install

npm install viem 0xintuition/protocol
pnpm install viem 0xintuition/protocol
bun install viem 0xintuition/protocol

Usage

The protocol SDK provides both core/functional and class based functions for interacting with the Intuition protocol.

Setup

import {
  getMultiVaultAddressFromChainId,
  intuitionTestnet,
  multiVaultGetAtomCost,
} from '@0xintuition/protocol'

import { createPublicClient, createWalletClient, http } from 'viem'

const walletClient = createWalletClient({
  chain: intuitionTestnet,
  transport: http(),
  account: account, // metamask, private key, etc
})

const publicClient = createPublicClient({
  chain: intuitionTestnet,
  transport: http(),
})

const address = getMultiVaultAddressFromChainId(intuitionTestnet.id)

Cost Calculation and Multicall

import {
  multicallIntuitionConfig,
  multiVaultGetAtomCost,
  multiVaultGetTripleCost,
} from '@0xintuition/protocol/core'

// Get atom creation cost
const atomCost = await multiVaultGetAtomCost({ address, publicClient })

// Get triple creation cost
const tripleCost = await multiVaultGetTripleCost({ address, publicClient })

// Get multiple config values in one call
const config = await multicallIntuitionConfig({ address, publicClient })

Core Functions

Atom and Triple Creation

import {
  multiVaultCreateAtoms,
  multiVaultCreateTriples,
} from '@0xintuition/protocol'

// Create atoms (supports single or multiple)
await multiVaultCreateAtoms(
  { address, walletClient, publicClient },
  {
    args: [
      [atomUri1, atomUri2],
      [atomCost, atomCost],
    ],
    value: atomCost + atomCost,
  },
)

// Create triples (supports single or multiple)
await multiVaultCreateTriples(
  { address, walletClient, publicClient },
  {
    args: [
      [subjectId1, subjectId2],
      [predicateId1, predicateId2],
      [objectId1, objectId2],
      [tripleCost, tripleCost],
    ],
    value: tripleCost + tripleCost,
  },
)

Deposits and Redemptions

import { multiVaultDeposit, multiVaultRedeem } from '@0xintuition/protocol'

// Deposit into a vault (atom or triple)
await multiVaultDeposit(
  { address, walletClient, publicClient },
  { args: [receiver, vaultId, curveId, minShares], value },
)

// Redeem shares from a vault
await multiVaultRedeem(
  { address, walletClient, publicClient },
  { args: [receiver, vaultId, curveId, shares, minAssets] },
)

Batch Deposits and Redemptions

import {
  multiVaultDepositBatch,
  multiVaultRedeemBatch,
} from '@0xintuition/protocol/core'

// Batch deposit into multiple vaults
await multiVaultDepositBatch(
  { address, walletClient, publicClient },
  { args: [receiver, termIds, curveIds, assets, minShares], value },
)

// Batch redeem shares from multiple vaults
await multiVaultRedeemBatch(
  { address, walletClient, publicClient },
  { args: [shares, receiver, termIds, curveIds, minAssets] },
)

ABI Encoding Helpers

import {
  multiVaultCreateAtomsEncode,
  multiVaultCreateTriplesEncode,
  multiVaultDepositEncode,
  multiVaultRedeemEncode,
} from '@0xintuition/protocol/core'

// Encode a multiVaultCreateAtoms call
const data = multiVaultCreateAtomsEncode([atomUri1, atomUri2], [assets1, assets2])

// Encode a multiVaultCreateTriples call
const data = multiVaultCreateTriplesEncode(
  [subjectId1, subjectId2],
  [predicateId1, predicateId2],
  [objectId1, objectId2],
  [assets1, assets2]
)

// Encode deposit and redeem calls
const depositData = multiVaultDepositEncode(receiver, termId, curveId, assets, minShares)
const redeemData = multiVaultRedeemEncode(receiver, termId, curveId, shares, minAssets)

Event Parsing Utilities

import {
  eventParseAtomCreated,
  eventParseDeposited,
  eventParseRedeemed,
  eventParseTripleCreated,
} from '@0xintuition/protocol/events'

// Parse AtomCreated event logs from a transaction
const atomEvents = await eventParseAtomCreated(publicClient, txHash)

// Parse Deposited event logs
const depositEvents = await eventParseDeposited(publicClient, txHash)

// Parse Redeemed event logs
const redeemEvents = await eventParseRedeemed(publicClient, txHash)

// Parse TripleCreated event logs
const tripleEvents = await eventParseTripleCreated(publicClient, txHash)

Using MultiVault contract directly

import {
  getMultiVaultAddressFromChainId,
  intuitionTestnet,
  MultiVaultAbi,
} from '@0xintuition/protocol'

import {
  createPublicClient,
  createWalletClient,
  getContract,
  http,
  parseEventLogs,
  toHex,
} from 'viem'
import { privateKeyToAccount } from 'viem/accounts'

// This should be the logged in account (Metamask, etc)
export const account = privateKeyToAccount(
  '0x6c25488133b8ca4ba754ea64886b1bfa4c4b05e7fea057c61f9951fe76f1d657',
)
console.log('Using account: ', account.address)

const walletClient = createWalletClient({
  chain: intuitionTestnet,
  transport: http(),
  account: account,
})

const publicClient = createPublicClient({
  chain: intuitionTestnet,
  transport: http(),
})

const multiVault = getContract({
  abi: MultiVaultAbi,
  address: getMultiVaultAddressFromChainId(intuitionTestnet.id),
  client: {
    public: publicClient,
    wallet: walletClient,
  },
})

async function main() {
  const atomCost = await multiVault.read.multiVaultGetAtomCost()
  const { minDeposit } = await multiVault.read.getGeneralConfig()
  const hash = await multiVault.write.multiVaultCreateAtoms(
    [[toHex('hello world')], [atomCost + minDeposit]],
    {
      value: atomCost + minDeposit,
    },
  )

  const { logs, status } = await publicClient.waitForTransactionReceipt({
    hash,
  })

  if (status === 'reverted') {
    throw new Error('Transaction reverted')
  }

  const events = parseEventLogs({
    abi: MultiVaultAbi,
    logs,
    eventName: 'AtomCreated',
  })

  console.log('Atom created', events[0].args.termId)
}

main().catch(console.error)

Development

Building

Run pnpm build to build the library.

Running unit tests

Run pnpm test to execute the unit tests

Contributing

Contributions are welcome! Please see the main repository for more information on how to contribute.

License

This project is licensed under the MIT License.