Skip to main content

Create Triple

Creating triples in the Intuition protocol involves establishing relationships between atoms through the EthMultiVault contract. This process creates both the triple structure and its associated vaults for positive and negative positions.

Prerequisites

This implementation guide assumes that you've completed the setup steps in the Overview guide and have existing atoms to work with.

Implementation

We recommend creating a multivault.ts that includes the following triple creation functionality:

Core Triple Creation Pattern

// Create triple with initial deposit
const createTripleConfig = {
...multiVaultContract,
functionName: 'createTriple',
args: [subjectId, predicateId, objectId, initialDeposit],
}

// Execute transaction
const hash = await walletClient.writeContract(createTripleConfig)

Key Functions

We use this pattern to create triples and manage their lifecycle:

createTriple

Creates a new triple with optional initial deposit and returns triple/vault IDs.

validateTripleComponents

Validates that subject, predicate, and object atoms exist and are valid.

estimateTripleCost

Estimates the cost of creating a triple including fees and gas costs.

Usage Example

Basic Triple Creation

// Create a new triple
const subjectId = 123n  // Atom ID for "Alice"
const predicateId = 456n // Atom ID for "knows"
const objectId = 789n    // Atom ID for "Bob"
const initialDeposit = parseEther("0.1")

const result = await createTriple(
MULTIVAULT_CONTRACT_ADDRESS,
subjectId,
predicateId,
objectId,
initialDeposit,
walletClient,
publicClient
)

Vault Management

Each triple creates two vaults:

Positive Vault

For users who believe the triple is true. Deposits here signal agreement.

Negative Vault

For users who believe the triple is false. Deposits here signal disagreement.

Best Practices

  • Validate all atom IDs before creating triples
  • Check for existing triples to avoid duplicates
  • Estimate costs before executing transactions
  • Implement proper error handling and user feedback
  • Use multicall patterns for batch operations

Next Steps

After creating triples, explore:

For a full reference implementation, see the Intuition TypeScript SDK.