Packages
The @0xintuition packages are TypeScript libraries for building on
Intuition. They derive identifiers, describe the networks and their
contracts, and wrap the protocol's contract calls. Install only the ones you
need.
The packages are ESM-only: they have no CommonJS entry points. The packages that work with identifiers or the chain declare viem (opens in a new tab) 2 as a peer dependency.
Install
For an application that reads from and writes to the protocol, install these four packages:
pnpm add @0xintuition/protocol@3.0.0 @0xintuition/deployments@alpha @0xintuition/ids@alpha viem| Package | What it gives you |
|---|---|
@0xintuition/protocol | Contract ABIs, with typed helpers for their functions |
@0xintuition/deployments | Chain definitions for viem, and contract addresses for each network |
@0xintuition/ids | Identifier derivation for atoms, triples, and counter-triples, offline |
viem | The client that reads from the chain and sends transactions |
Versions and tags
Most packages are on the 0.1.0-alpha line, published under the alpha
distribution tag.
@0xintuition/protocol is the exception. Version 3 is published under the
alpha tag, and the latest tag still points at the earlier 2.x line,
which has a different API. Always request version 3 explicitly. Version 3 does
not include addresses or chain definitions: import those from
@0xintuition/deployments.
Set up the clients
The pages that read from and write to the chain share this setup: a public
client to read, a wallet client to send transactions, and the MultiVault
contract address.
import {
getMultiVaultAddressFromChainId,
intuitionTestnet,
} from '@0xintuition/deployments';
import { createPublicClient, createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const publicClient = createPublicClient({
chain: intuitionTestnet,
transport: http(),
});
const walletClient = createWalletClient({
account,
chain: intuitionTestnet,
transport: http(),
});
const address = getMultiVaultAddressFromChainId(intuitionTestnet.id);PRIVATE_KEYis the private key of an account that holds testnet TRUST. Keep it in an environment variable, never in source code.http()with no argument uses the chain's public RPC endpoint.- Replace
intuitionTestnetwithintuitionMainnetto use mainnet.
The protocol helpers take a configuration object as their first argument. A
read helper needs address and publicClient. A write helper also needs
walletClient:
const config = { address, publicClient, walletClient };Use a browser wallet
In a web application, the user's wallet signs instead of a private key:
import 'viem/window';
import { intuitionTestnet } from '@0xintuition/deployments';
import { createWalletClient, custom } from 'viem';
const [account] = await window.ethereum!.request({
method: 'eth_requestAccounts',
});
const walletClient = createWalletClient({
account,
chain: intuitionTestnet,
transport: custom(window.ethereum!),
});The viem/window import declares the type of window.ethereum, which the
wallet extension injects.
Use the React hooks
@0xintuition/react wraps the same contract calls in hooks for applications
built with wagmi (opens in a new tab) and TanStack Query. Install it with its
peer dependencies:
pnpm add @0xintuition/react@alpha @0xintuition/protocol@3.0.0 @0xintuition/deployments@alpha wagmi viem @tanstack/react-queryConfigure wagmi with the chain definitions from @0xintuition/deployments.
Then wrap your application in IntuitionProvider, inside the wagmi and
TanStack Query providers, and choose a network:
import { IntuitionProvider, useAtomCost } from '@0xintuition/react';
export function App() {
return (
<IntuitionProvider network="testnet">
<AtomCost />
</IntuitionProvider>
);
}
function AtomCost() {
const { data: atomCost } = useAtomCost();
return <p>{atomCost?.toString()} wei</p>;
}network is mainnet or testnet. The provider resolves the MultiVault
address from @0xintuition/deployments.
All packages
| Package | Purpose |
|---|---|
@0xintuition/ids (opens in a new tab) | Derives identifiers for atoms, triples, counter-triples, and predicates |
@0xintuition/predicates (opens in a new tab) | The canonical predicate registry, with fixed identifiers |
@0xintuition/classifications (opens in a new tab) | Classification specifications, and builders that produce consistent atom data |
@0xintuition/schema-org (opens in a new tab) | A pinned schema.org vocabulary |
@0xintuition/primitives (opens in a new tab) | Higher-level builders and validators for atoms and triples |
@0xintuition/protocol (opens in a new tab) | Contract ABIs, contract helpers, and event parsers |
@0xintuition/deployments (opens in a new tab) | Chain definitions and contract addresses |
@0xintuition/curves (opens in a new tab) | Bonding curve mathematics, for previews without a network call |
@0xintuition/periphery (opens in a new tab) | Helpers for the bridge and router contracts |
@0xintuition/react (opens in a new tab) | React hooks for protocol reads and writes |
What the packages do not cover
The packages talk to the chain, one term at a time. They do not search, filter, or list the graph, and they do not pin files to IPFS. To search atoms, list the triples around an atom, or list an account's positions, query an Intuition Core node through its REST API or with SQL.