JSPM

scorechain-sdk

1.0.3
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 4377
    • Score
      100M100P100Q118647F
    • License MIT

    SDK for the Scorechain API

    Package Exports

    • scorechain-sdk
    • scorechain-sdk/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scorechain-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    scorechain-logo

    Scorechain SDK for javascript

    The goal of the Scorechain SDK for JavaScript is to simplify the integration of the Scorechain API into JavaScript applications. By providing a set of convenient functions and methods, developers can easily interact with the Scorechain API and access its features. This SDK aims to streamline the process of integrating Scorechain's blockchain analytics capabilities into JavaScript projects, enabling developers to leverage the power of Scorechain's technology with ease.

    Getting Started

    How to install

    npm install scorechain-sdk --save

    Usage

    • With Typescript
    import { ScorechainConnector } from "scorechain-sdk";
    const connector = new ScorechainConnector("MyScorechainApiKey");
    • With Javascript
    const { ScorechainConnector } = require("scorechain-sdk")
    const connector = new ScorechainConnector("MyScorechainApiKey");

    All methods in the connector are wrapper for endpoints of the Scorechain API :

    • getTransaction:
          Retrieve a transaction by its hash from the specified blockchain.
    • getAddress:
          Retrieve information about a specific address from the blockchain.
    • getTransactionScoringAnalysis:
          Get a real-time scoring analysis for a transaction.
    • getAddressScoringAnalysis:
          Get a real-time scoring analysis for a specific address.
    • getWalletScoringAnalysis:
          Get a real-time scoring analysis for a wallet.
    • feedTransaction:
          Feed a transaction for analysis by risk scenarios.
    • feedWithdrawal:
          Feed a not approved withdrawal for analysis by risk scenarios.

    Proof of Authenticity

    The ScorechainConnector includes built-in proof of authenticity checks, which validate response signatures to ensure secure communication. If you prefer to disable these checks, you can initialize the connector as follows:

    const connector = new ScorechainConnector("MyScorechainApiKey", false);

    Public Key

    In case Scorechain has to renew its private key, the recommended procedure is to update the SDK to the latest version. However, to ensure continuity, we provide a convenience function to refresh the embedded public key. This should only be used in case of emergency:

    const connector = new ScorechainConnector("MyScorechainApiKey");
    await connector.updateScorechainPublicKey();

    Example

    Here is a simple example to send a transaction to the Transaction Monitoring System

    const connector = new ScorechainConnector("MyScorechainApiKey")
    const txid = "0x308b22a8e0e9e4e7d1b9fd1dfab74d7b37325b255e566f4d81edd457937c5e0c"
    const address = "0x9f5A8089ecF94d3D4D7A53025d993E0cc29e2c5f"
    
    connector.feedTransaction(txid, BlockchainEnum.ETHEREUM, ScoringDirection.INCOMING, address)

    Here is a simple example of an address screening that you can call after detecting a deposit.

    import { BlockchainEnum, ScorechainConnector, ScoringAnalysisType, SeverityEnum } from "scorechain-sdk";
    
    (async () => {
        const connector = new ScorechainConnector("MyScorechainApiKey")
        const txid = "0x308b22a8e0e9e4e7d1b9fd1dfab74d7b37325b255e566f4d81edd457937c5e0c"
        const tx = await connector.getTransaction(txid, BlockchainEnum.ETHEREUM);
        const addressScore = await connector.getAddressScoringAnalysis(
            tx.operations[0].destinations[0].address,
            BlockchainEnum.ETHEREUM,
            "MAIN",
            ScoringAnalysisType.INCOMING,
            6
        );
        const severity = Object.keys(addressScore.analysis).reduce(
            (acc, analysis) => {
                if (addressScore.analysis[analysis]?.result?.score === addressScore.lowestScore) {
                    acc = addressScore.analysis[analysis].result.severity;
                }
                return acc;
            },
            SeverityEnum.UNDEFINED_RISK
        )
    
        if (severity !== SeverityEnum.CRITICAL_RISK && severity !== SeverityEnum.HIGH_RISK) {
            console.log("Transaction is safe");
        } else {
            console.log("Transaction is risky");
        }
    })()