Quick Start
Get started with the Intuition SDK by creating your first atom and triple in minutes.
Auto-Generated Package Documentationβ
For a complete list of 0xintuition/sdk functions and interfaces, see the Intuition SDK documentation.
For a complete list of 0xintuition/protocol functions and interfaces, see the Intuition Protocol documentation.
For a complete list of 0xintuition/graphql functions and interfaces, see the Intuition Protocol documentation.
Overviewβ
In this quick start guide, you'll:
- Set up the SDK clients
- Create an atom from a string
- Create a triple (subject-predicate-object statement)
- Query atom details
Prerequisitesβ
- Installed the SDK
- Have a wallet with testnet TRUST tokens (get testnet tokens)
- Your wallet private key
Step 1: Set Up Clientsβ
Create a new file and set up your Viem clients:
import {
intuitionTestnet,
getMultiVaultAddressFromChainId,
createAtomFromString,
createTripleStatement,
getAtomDetails,
} from '@0xintuition/sdk'
import { createPublicClient, createWalletClient, http, parseEther } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
// Setup account and clients
const account = privateKeyToAccount('0xYOUR_PRIVATE_KEY')
const publicClient = createPublicClient({
chain: intuitionTestnet,
transport: http(),
})
const walletClient = createWalletClient({
chain: intuitionTestnet,
transport: http(),
account,
})
const address = getMultiVaultAddressFromChainId(intuitionTestnet.id)
Step 2: Create Your First Atomβ
Create an atom from a simple string:
// Create an atom
const atom = await createAtomFromString(
{ walletClient, publicClient, address },
'TypeScript',
parseEther('0.01') // Optional: initial deposit of 0.01 TRUST
)
console.log('Created atom!')
console.log('Atom ID:', atom.state.termId)
console.log('Transaction:', atom.transactionHash)
console.log('URI:', atom.uri)
Expected output:
Created atom!
Atom ID: 0x1234567890abcdef...
Transaction: 0xabcdef1234567890...
URI: TypeScript
Step 3: Query Atom Detailsβ
Fetch the atom details from the Intuition API:
// Wait a moment for indexing
await new Promise(resolve => setTimeout(resolve, 2000))
// Query atom details
const details = await getAtomDetails(atom.state.termId)
console.log('Atom Details:')
console.log('- Label:', details.label)
console.log('- Creator:', details.creator)
console.log('- Vault Assets:', details.vault.totalShares)
Step 4: Create a Tripleβ
Create a triple (statement) connecting three atoms:
// Create three atoms
const alice = await createAtomFromString(
{ walletClient, publicClient, address },
'Alice'
)
const follows = await createAtomFromString(
{ walletClient, publicClient, address },
'follows'
)
const bob = await createAtomFromString(
{ walletClient, publicClient, address },
'Bob'
)
// Create triple: "Alice follows Bob"
const triple = await createTripleStatement(
{ walletClient, publicClient, address },
{
args: [
[alice.state.termId], // subjects
[follows.state.termId], // predicates
[bob.state.termId], // objects
[parseEther('0.1')], // deposit per triple
],
value: parseEther('0.1'), // total transaction value
}
)
console.log('Created triple!')
console.log('Triple ID:', triple.state[0].args.tripleId)
console.log('Transaction:', triple.transactionHash)
Complete Exampleβ
Here's the complete quick start script:
import {
intuitionTestnet,
getMultiVaultAddressFromChainId,
createAtomFromString,
createTripleStatement,
getAtomDetails,
} from '@0xintuition/sdk'
import { createPublicClient, createWalletClient, http, parseEther } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
async function main() {
// Setup
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const publicClient = createPublicClient({
chain: intuitionTestnet,
transport: http(),
})
const walletClient = createWalletClient({
chain: intuitionTestnet,
transport: http(),
account,
})
const address = getMultiVaultAddressFromChainId(intuitionTestnet.id)
// Create an atom
console.log('Creating atom...')
const atom = await createAtomFromString(
{ walletClient, publicClient, address },
'TypeScript',
parseEther('0.01')
)
console.log('β Atom created:', atom.state.termId)
// Wait for indexing
await new Promise(resolve => setTimeout(resolve, 2000))
// Query details
const details = await getAtomDetails(atom.state.termId)
console.log('β Atom label:', details.label)
// Create three atoms for a triple
console.log('\nCreating atoms for triple...')
const alice = await createAtomFromString(
{ walletClient, publicClient, address },
'Alice'
)
const follows = await createAtomFromString(
{ walletClient, publicClient, address },
'follows'
)
const bob = await createAtomFromString(
{ walletClient, publicClient, address },
'Bob'
)
// Create triple
console.log('Creating triple...')
const triple = await createTripleStatement(
{ walletClient, publicClient, address },
{
args: [
[alice.state.termId],
[follows.state.termId],
[bob.state.termId],
[parseEther('0.1')],
],
value: parseEther('0.1'),
}
)
console.log('β Triple created:', triple.state[0].args.tripleId)
console.log('\nSuccess! You created your first atom and triple.')
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error('Error:', error)
process.exit(1)
})
Run the Exampleβ
# Set your private key
export PRIVATE_KEY=0xYOUR_PRIVATE_KEY
# Run the script
npx tsx quickstart.ts
Understanding the Codeβ
Atomsβ
Atoms are the fundamental entities in Intuition. They can represent:
- Simple strings (
"TypeScript") - Ethereum addresses (
"0x1234...") - IPFS content (
"ipfs://bafkreib...") - Rich entities (JSON-LD objects)
Triplesβ
Triples connect atoms in subject-predicate-object relationships:
- Subject: The atom being described (
Alice) - Predicate: The relationship type (
follows) - Object: The target atom (
Bob)
Depositsβ
Each atom and triple has a vault for deposits:
- Depositing increases your stake in an entity
- You receive shares based on a bonding curve
- Shares can be redeemed later for assets
Next Stepsβ
Now that you've created your first atom and triple, explore:
Atom Operationsβ
- Create from Thing - Create rich entities with metadata
- Create from Ethereum Account - Create identity atoms
- Batch Creation - Create multiple atoms efficiently
Triple Operationsβ
- Querying Triples - Fetch triple details
- Counter Triples - Work with opposing positions
Vault Operationsβ
- Deposits - Deposit into vaults
- Redemptions - Redeem shares
Search & Discoveryβ
- Global Search - Search across all entities
- Semantic Search - Find similar content
Common Issuesβ
Transaction Revertsβ
If your transaction reverts, check:
- You have sufficient TRUST balance
- The atoms exist before creating a triple
- The deposit amount is greater than 0
Indexing Delaysβ
The Intuition API may take a few seconds to index new entities. Add a delay before querying:
await new Promise(resolve => setTimeout(resolve, 2000))
Network Errorsβ
Ensure you're connected to the correct network:
console.log('Network:', intuitionTestnet.name)
console.log('Chain ID:', intuitionTestnet.id)
See Alsoβ
- Core Concepts - Understand atoms and triples
- SDK Examples - More detailed examples
- GraphQL Queries - Query protocol data