Integration Guide
Getting started with Integra smart contract integration.
Overview
This guide walks you through integrating Integra’s smart contracts into your application, from initial setup to production deployment. Whether you’re building a document tokenization platform, property management system, or custom blockchain application, this guide provides the step-by-step instructions you need.
Prerequisites
Before integrating with Integra, ensure you have:
- Web3 Development Environment: Node.js 18+, npm or yarn
- Wallet Configuration: MetaMask or similar Web3 wallet
- Test Network Access: Polygon Amoy or Base Sepolia for development
- API Credentials: Integra API key for attestation services
Quick Start
Step 1: Install Dependencies
# Install Integra SDK
npm install @integra/sdk viem
# Or with yarn
yarn add @integra/sdk viemStep 2: Initialize the SDK
import { IntegraClient } from '@integra/sdk';
import { createWalletClient, http } from 'viem';
import { polygonAmoy } from 'viem/chains';
const client = new IntegraClient({
chain: polygonAmoy,
apiKey: process.env.INTEGRA_API_KEY,
});Step 3: Register Your First Document
// Hash your document
const documentHash = await client.hashDocument(documentContent);
// Register on-chain
const result = await client.registerDocument({
documentHash,
referenceHash: ipfsCID, // Where full document is stored
tokenizer: 'ownership', // Which tokenizer to use
});
console.log('Document registered:', result.integraHash);Integration Patterns
Pattern 1: Simple Document Registration
For basic document verification without tokenization:
const integraHash = await client.registerDocument({
documentHash,
referenceHash,
tokenizer: null, // No tokenizer needed
});Pattern 2: NFT Ownership
For documents with transferable ownership:
const integraHash = await client.registerDocument({
documentHash,
referenceHash,
tokenizer: 'ownership',
});
// Reserve token for recipient
await client.reserveToken(integraHash, recipientAddress);Pattern 3: Multi-Party Agreements
For contracts with multiple signers:
const integraHash = await client.registerDocument({
documentHash,
referenceHash,
tokenizer: 'multiparty',
parties: [buyerAddress, sellerAddress],
});Contract Addresses
Get current contract addresses for your target chain:
const addresses = await client.getContractAddresses('polygon');
console.log('Document Registry:', addresses.documentRegistry);
console.log('Ownership Tokenizer:', addresses.ownershipTokenizer);Error Handling
try {
const result = await client.registerDocument({...});
} catch (error) {
if (error.code === 'INSUFFICIENT_GAS') {
// Handle gas issues
} else if (error.code === 'DOCUMENT_EXISTS') {
// Document already registered
}
}Testing
Always test on testnet before mainnet deployment:
// Use testnet for development
const testClient = new IntegraClient({
chain: polygonAmoy, // Testnet
apiKey: process.env.INTEGRA_TEST_API_KEY,
});
// Run integration tests
await testClient.registerDocument({...});Production Checklist
Before deploying to production:
- Test all flows on testnet
- Configure production API keys
- Set up monitoring and alerts
- Implement retry logic for failed transactions
- Configure appropriate gas settings
- Set up event listeners for important events
Next Steps
- Architecture Overview - Understand contract structure
- Tokenizer Comparison - Choose the right tokenizer
- Security Guide - Security best practices
- API Reference - Complete API documentation
Support
- Documentation: You’re here!
- GitHub: github.com/IntegraLedger
- Support Email: support@integra.io