npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shield3/react-sdk

v0.2.2

Published

The Shield3 React SDK provides a convenient way to integrate Shield3's policy simulation and transaction analysis capabilities into your React applications. By leveraging the `Shield3Provider` and the `useShield3Context` hook, developers can easily query

Downloads

27

Readme

Shield3 React SDK

The Shield3 React SDK provides a convenient way to integrate Shield3's policy simulation and transaction analysis capabilities into your React applications. By leveraging the Shield3Provider and the useShield3Context hook, developers can easily query policy results for Ethereum transactions, helping to ensure that transactions comply with specified policies before being sent to the network.

Features

  • Policy Simulation: Simulate transactions against Shield3's policy engine to get immediate feedback on compliance.
  • Easy Integration: Seamlessly integrates with React applications, providing context and hooks to interact with the Shield3 API.
  • Customizable: Configure with your own API key and chain ID to connect to the appropriate network.

Installation

To install the Shield3 React SDK, run the following command in your project directory:

To install the Shield3 React SDK, run the following command in your project directory:

npm install @shield3/react-sdk

Usage

To use the Shield3 React SDK in your React application, follow these steps:

1. Wrap your application with Shield3Provider

First, import Shield3Provider from the SDK and wrap your application's root component. This requires an apiKey for authenticating with the Shield3 API and a chainId to specify the blockchain network.

import { Shield3Provider } from '@shield3/react-sdk';

function App() {
  return (
    <Shield3Provider apiKey="your_api_key_here" chainId={1}> {/* Use the appropriate chain ID */}
      {/* Your app components */}
    </Shield3Provider>
  );
}

export default App;

2. Use useShield3Context to access the SDK functionality

Anywhere in your component tree that is wrapped by Shield3Provider, you can use useShield3Context to access the SDK's functionality. This hook provides access to the shield3Client, which includes the getPolicyResults method for simulating transactions.

import { useShield3Context } from '@shield3/react-sdk';
import { useState } from 'react';

function TransactionSimulator() {
  const { shield3Client } = useShield3Context();
  const [result, setResult] = useState(null);

  const simulateTransaction = async (transaction) => {
    const policyResults = await shield3Client.getPolicyResults(transaction, 'your_account_address');
    setResult(policyResults);
  };

  // Your UI logic here

  return (
    <div>
      {/* Your UI components */}
    </div>
  );
}

export default TransactionSimulator;

3. Simulating Transactions

To simulate a transaction, call getPolicyResults with the transaction object and the sender's address. This method returns policy simulation results, which can be used to determine whether a transaction complies with the set policies.

const transaction = {
  to: '0x...',
  value: '0x...',
  data: '0x...',
  // Other transaction fields
};

simulateTransaction(transaction);

4. Handling Policy Results

The policy results returned by getPolicyResults include the following fields:

  • decision (string): The decision of the policy engine (e.g., 'Allow', 'Block').
  • transaction (object): The transaction object that was simulated with granular policy decision results.

Support

For issues, questions, or contributions, please refer to the GitHub repository or contact support through the Shield3 support channels.


This README provides a basic overview of integrating the Shield3 React SDK into your applications. For more detailed documentation, including API references and advanced configurations, please refer to the official documentation.