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

@vennbuild/venn-dapp-sdk

v0.8.3

Published

SDK for interactions with Venn Network

Downloads

141

Readme

TypeScript Jest ESLint

@vennbuild/venn-dapp-sdk

SDK for easy DApp integrations with Venn Security Network. This SDK is framework agnostic and will be compatible with any modern web application.

What is Venn?

Table of Contents

Quick Start

Install the SDK with npm install @vennbuild/venn-dapp-sdk. Initialize a VennClient with a Venn Node URL, policy contract address, and chain ID. Create a transaction request (from, to, data, value), then call approve() to get the signed transaction. Submit the signed transaction on-chain.

import { VennClient } from '@vennbuild/venn-dapp-sdk'
import ethers from 'ethers'

const vennClient = new VennClient({
  vennURL: 'https://api.venn.build/test/url/do/not/use',
  vennPolicyAddress: '0x1234567890123456789012345678901234567890',
})
const transaction = {
  from: '0x1234567890123456789012345678901234567890',
  to: '0x1234567890123456789012345678901234567890',
  data: '0x1234567890123456789012345678901234567890',
  value: '0'
}
const signedTransaction = await vennClient.approve(transaction)

Installation

npm install @vennbuild/venn-dapp-sdk

Usage

Use this SDK to easily interact with protocols protected by the Venn Network Approved Calls Policy. For using this SDK you'll need a Venn Node URL.

Venn Network Signature

Background

Protocols on the Venn Network protected by the Approved Calls Policy, are expecting certain calls to be signed by Venn Network. This SDK allows you to easily sign your transaction data. Once the transaction is approved and signed, you can proceed with executing it on-chain. Unsigned calls to protected protocols will revert.

If you're a protocol owner, and you want to allow your users to interact with your protocol using this SDK, you'll need to set up your contracts:

  • Target contract should inherit from FirewallConsumerBase
  • Target contract firewall should be activated (should have active firewall address set either during deployment or via setFirewall method)
  • Target contract should have ApprovedCallsPolicy deployed and activated (via firewall.addGlobalPolicy)

For more information about setting up your contracts, please refer to Venn Documentation

Getting started

  1. Create a new Venn Client instance with your Venn Node URL. Pass the following parameters:
  • vennURL: String. URL of your Venn Node.
  • vennPolicyAddress: String. Address of the ApprovedCallsPolicy contract.
  • strict: Boolean. If set to true, the SDK will throw an error in case of an error while signing the transaction or if the transaction is not approved by Venn Network. If set to false, the SDK will return a request data in case of an error. Default value is true.
  1. Create a transaction request object.
  • from: String. Address of the sender
  • to: String. Address of the recipient
  • data: String. Encoded data of the transaction
  • value: String. Value of the transaction
  1. Call approve method with the transaction request object.

  2. Returned value is a signed transaction request object:

  • from: String. Address of the sender. Same as the original transaction.
  • to: String. Address of the recipient. Same as the original transaction.
  • data: String. Signed data of the transaction.
  • value: String. Value of the transaction. Same as the original transaction.
  1. Submit the signed transaction request object instead of the original one.

Example - How to use the SDK

import { VennClient } from '@ironblocks/venn-dapp-sdk'

const url = process.env.VENN_NODE_URL
const policyAddress = process.env.VENN_POLICY_ADDRESS

const vennClient = new VennClient({ vennURL: url , vennPolicyAddress: policyAddress})

const transaction= {
    from: '0xfdD055Cf3EaD343AD51f4C7d1F12558c52BaDFA5',
    to: '0x10A88C7001900CE4299f62dA80D1c76121DcbAF6',
    data: '0x88C70010' // encoded data of your transaction
    value: ethers.utils.parseEther('0')
}

const signedTransaction = await vennClient.approve(transaction)

console.log(signedTransaction)
// {
//     from: '0xfdD055Cf3EaD343AD51f4C7d1F12558c52BaDFA5',
//     to: '0x10A88C7001900CE4299f62dA80D1c76121DcbAF6',
//     data: '0xCB45Cf3EaD343AD51f0CE4299f62dA80D1c76121DcbAF6A7', // signed data of the transaction
//     value: 0
// }

/* submit signed transaction instead of original one */

What happens under the hood?

Original transaction data is substituted with the same data, but signed by Venn Network.

  1. Transaction is inspected by Venn Network.
  2. If approved, the transaction is signed by Venn Network, and returned to the user.
  3. User can now submit the signed transaction as is to the network instead of the original one.
  4. If the transaction is not approved, the SDK will throw an error indicating that the transaction was rejected.

This SDK demonstrates how to integrate the Ironblocks Firewall with Venn Network