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

@openzeppelin/defender-kvstore-client

v1.54.1

Published

The [Defender Autotasks](https://docs.openzeppelin.com/defender/autotasks) service allows you to run small code snippets on a regular basis or via webhooks that can make calls to the Ethereum network or to external APIs. Thanks to tight integration to Def

Downloads

201

Readme

Defender Key-Value Store Client for Autotasks

The Defender Autotasks service allows you to run small code snippets on a regular basis or via webhooks that can make calls to the Ethereum network or to external APIs. Thanks to tight integration to Defender Relayers, you can use Autotasks to automate regular actions on your contracts.

This client allows you to access a simple key-value data store from your Autotasks code, so you can persist data throughout executions and across different Autotasks.

Note that this package will not work outisde the Autotasks environment.

Installation

This package is included in the Autotask runtime environment, so you do not need to bundle it in your code. To install it for local development and typescript type completion, run:

npm install @openzeppelin/defender-kvstore-client
yarn add @openzeppelin/defender-kvstore-client

Usage

You can interact with your key-value store through an instance of the KeyValueStoreClient, which is initialized with the payload injected in the your Autotask handler function. Once initialized, you can get, put, or del key-value pairs from the store.

const { KeyValueStoreClient } = require('@openzeppelin/defender-kvstore-client');

exports.handler = async function (event) {
  // Creates an instance of the key-value store client
  const store = new KeyValueStoreClient(event);

  // Associates myValue to myKey
  await store.put('myKey', 'myValue');

  // Returns myValue associated to myKey
  const value = await store.get('myKey');

  // Deletes the entry for myKey
  await store.del('myKey');
};

Local development

The Defender key-value store is only accessible from within an Autotask. To simplify local development, you can create an instance of a KeyValueStoreClient providing an object with a path property. The client will use a local json file at that path for all operations.

const { KeyValueStoreClient } = require('@openzeppelin/defender-kvstore-client');

async function local() {
  // Creates an instance of the client that will write to a local file
  const store = new KeyValueStoreClient({ path: '/tmp/foo/store.json' });

  // The store.json file will contain { myKey: myValue }
  await store.put('myKey', 'myValue');
}

Considerations

  • All data in the key-value store is persisted as strings, both keys and values.
  • Keys are limited to 1kb in size, and values to 300kb.
  • The data store is shared across all your Autotasks; consider prefixing the keys with a namespace if you want to have different data buckets.
  • A key-value entry is expired after 90 days of the last time it was put into the store.
  • The total number of key-value records in your store is determined by your Defender plan.