injectos-injective-sdk
v0.1.0
Published
The InjectOS Injective SDK is the standalone blockchain communication layer for InjectOS.
Readme
InjectOS Injective SDK
The InjectOS Injective SDK is the standalone blockchain communication layer for InjectOS.
It is built as a lightweight TypeScript package that turns Injective EVM into an AI-native execution runtime for the InjectOS workflow:
User Prompt -> Intent Parsing -> Safety Verification -> Transaction Preview -> Human Approval -> Injective Execution -> Execution Monitoring -> Completion Status
This package is designed for the InjectOS command center, backend orchestration services, future automation workers, and any application that needs a safe, realtime, frontend-friendly Injective integration.
Repository: https://github.com/rohan911438/Inject-OS
Product Goals
- Make Injective EVM feel like the core transport layer of an AI operating system.
- Keep blockchain communication modular, typed, and easy to reason about.
- Expose wallet, simulation, execution, safety, event, and analytics primitives in one place.
- Support a mission-control style frontend where workflow state updates in realtime.
- Stay hackathon-friendly and Remix-compatible while remaining easy to extend later.
What This SDK Does
- Detects MetaMask or any injected EIP-1193 wallet.
- Switches users to Injective EVM Testnet when they are on the wrong chain.
- Wraps the deployed InjectOS contracts with ethers.js helpers.
- Generates deterministic execution previews for SAFE and OPTIMIZED modes.
- Submits and reads safety analysis onchain.
- Listens to workflow events and synchronizes execution state.
- Collects ecosystem metrics from Injective-compatible RPC endpoints.
- Exposes a clean API that can be consumed from a frontend dashboard or backend orchestration engine.
Workflow Coverage
The SDK is centered on the exact InjectOS pipeline:
- User prompt enters the command center.
- Intent is parsed into an execution plan.
- Safety logic scores the request and verifies the route.
- A transaction preview is generated with output, slippage, and gas context.
- The human operator approves or rejects the action.
- The execution transaction is sent through Injective EVM.
- Smart contract events stream back into the UI.
- The workflow is marked completed or failed with a synchronized state snapshot.
Package Layout
src/lib/injective/
constants.ts - chain config, contract addresses, workflow enums
provider.ts - ethers.js provider helpers and network switching
wallet.ts - MetaMask connection and status detection
contracts.ts - InjectOS contract ABIs and contract wrappers
execution.ts - execution state store and state synchronization helpers
safety.ts - local safety analysis and onchain safety submission
events.ts - contract event listeners and realtime workflow updates
simulation.ts - preview generation and SAFE/OPTIMIZED simulation helpers
analytics.ts - network health, activity, and ecosystem metrics helpersContract Addresses
The SDK is preconfigured with the current Remix deployments:
InjectOSEvents-0x33491e1b1fbD9F1d757a0ABd1a2930D189d4990EInjectOSExecution-0x975839Ce675306f2329c526F70c64D803828E9D9InjectOSStorage-0xff0Ea64C7B7046929CAcDFeDd32D0d4208F00266InjectOSSafety-0xd7412cB8b75A45fe5aD6bF9Ca5500811BA3B3e97
InjectOSInterfaces.sol is source-only and is not deployed by itself.
Injective EVM Configuration
The SDK uses the following Injective EVM defaults:
- Chain name:
Injective EVM Testnet - Chain ID:
2525 - RPC:
https://mainnet.rpc.inevm.com/http - Explorer:
https://inevm.calderaexplorer.xyz
These values live in src/lib/injective/constants.ts.
Install
npm installBuild
npm run buildUsage Example
import {
connectMetaMaskToInjective,
getBrowserProvider,
getExecutionContract,
simulateSwapPreview,
executionStore
} from "./src/index.js";
const wallet = await connectMetaMaskToInjective();
const provider = getBrowserProvider();
const signer = await provider.getSigner();
const executionContract = getExecutionContract(signer);
const preview = simulateSwapPreview(1000n, "SAFE");
console.log(preview.summary);
const state = executionStore.getState();
console.log(state.workflowState);Key Capabilities
wallet.tshandles wallet discovery, chain switching, and connection state.provider.tsstandardizes read/write access through ethers.js.contracts.tskeeps the contract ABI surface aligned with the deployed Solidity workflow.simulation.tsgenerates deterministic previews that match the InjectOS UX rules.safety.tsmirrors the local safety policy used by the broader InjectOS product.events.tsconverts blockchain events into immediate workflow updates.execution.tsacts as the workflow state machine for frontend synchronization.analytics.tsexposes network and activity telemetry for dashboard widgets.
Frontend Integration Notes
The SDK is intentionally frontend-friendly:
- Use it from React pages, Zustand stores, or framework-agnostic services.
- Use the execution store to keep UI state synchronized with blockchain state.
- Use event listeners to drive realtime dashboard animations and workflow badges.
- Use preview helpers before any signature request reaches MetaMask.
Safety Behavior
The local safety layer follows the InjectOS policy:
- confidence score must be at least
80 - slippage must be
5or less - ambiguity must be false
SAFE mode and OPTIMIZED mode are simulated as follows:
- SAFE:
10 USDT = 0.1 INJ - OPTIMIZED:
10 USDT = 0.2 INJ
Notes
- The SDK is intentionally modular and easy to expand.
- It uses ethers.js for all Injective EVM communication.
- It is safe to point the constants file at a different Injective RPC if the deployment target changes.
- The package is designed to be readable first and protocol-complete second, which fits the InjectOS hackathon MVP goal.
