New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@predicate/core

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@predicate/core

Core utilities for interacting with Predicate API

latest
npmnpm
Version
2.2.0
Version published
Maintainers
2
Created
Source

@predicate/core

npm version License: MIT

TypeScript client for interacting with the Predicate API. Handles policy evaluation, authentication, and request validation for any JavaScript/TypeScript environment.

Installation

npm install @predicate/core

V1 API Usage

import { PredicateClient, PredicateRequest } from '@predicate/core';

const client = new PredicateClient({
    apiUrl: 'https://api.predicate.io/',
    apiKey: process.env.PREDICATE_API_KEY!
});

const request: PredicateRequest = {
    from: '0xSenderAddress',
    to: '0xContractAddress',
    data: '0xEncodedArguments',
    msg_value: '0',
    chain_id: 1 // Optional
};

const result = await client.evaluatePolicy(request);
console.log("Task ID:", result.task_id);
console.log("Signers:", result.signers);
console.log("Signatures:", result.signature);

V1 Response Structure

interface PredicateResponse {
  is_compliant: boolean;
  task_id: string;
  expiry_block: number;
  signers: string[];
  signature: string[];
  results?: PredicateSignerResults;
}

V2 API Usage

import { PredicateClient, PredicateRequest } from '@predicate/core/v2';

const client = new PredicateClient({
    apiUrl: 'https://api.predicate.io/',
    apiKey: process.env.PREDICATE_API_KEY!
});

const request: PredicateRequest = {
    from: '0xSenderAddress',
    to: '0xContractAddress', 
    data: '0xEncodedArguments',
    msg_value: '0',
    chain: 'ethereum' // Required: 'ethereum' | 'solana' | 'sepolia' | 'holesky' | 'anvil'
};

const result = await client.evaluatePolicy(request);
console.log("Policy ID:", result.policy_id);
console.log("Is Compliant:", result.is_compliant);
console.log("Attestation:", result.attestation);

V2 Response Structure

interface PredicateResponse {
  policy_id: string;
  is_compliant: boolean;
  attestation: {
    uuid: string;
    expiration: number;
    attester: string;
    signature: string;
  };
}

Key Differences

FeatureV1V2
Import@predicate/core@predicate/core/v2
Endpoint/v1/task/v2/attestation
Chain Fieldchain_id?: number | stringchain: SupportedChain (required)
Response IDtask_idattestation.uuid
Expiryexpiry_block (block number)attestation.expiration (unix seconds)
SignersMultiple signers/signaturesSingle attester/signature
Policy IDNot includedpolicy_id field

Migration from V1 to V2

  • Update import path:

    // Before
    import { PredicateClient } from '@predicate/core';
    
    // After  
    import { PredicateClient } from '@predicate/core/v2';
    
  • Add required chain field:

    const request = {
      // ... other fields
      chain: 'ethereum' // Now required
    };
    
  • Update response handling:

    // V1
    console.log(result.task_id, result.signers);
    
    // V2
    console.log(result.policy_id, result.attestation.uuid, result.attestation.attester);
    

Features

  • Policy evaluation and verification
  • TypeScript support with full type safety
  • Request validation and error handling
  • Support for multiple blockchain networks
  • Compatible with Node.js, browsers, and edge environments

Documentation

For detailed documentation, visit docs.predicate.io.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

predicate

FAQs

Package last updated on 28 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts