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

@spherity/trusted-hint-controller

v1.1.1

Published

A controller library for handling ERC-7506 compliant Trusted Hints

Downloads

8

Readme

Trusted Hint Controller

This repository contains a TypeScript library for creating and managing trusted hints in accordance to ERC-7506. A hint refers to a small piece of information that provides insights, aiding in the interpretation, reliability, or verifiability of decentralized ecosystem data. This library is a light wrapper around the Viem API to make it easier to create and manage trusted hints.

Installation

npm i @spherity/trusted-hint-controller

Development

To build the library, run:

npm run build

This will create a dist folder with the compiled JavaScript for CommonJS and ES modules.

To run the tests, run:

npm run test
npm run test:integration

Usage

If you just want to read data from the Trusted Hint Registry, you only need to initialize the TrustedHintController with a read client. On how to create and use the clients, please refer to the Viem documentation.

import {TrustedHintController} from '@spherity/trusted-hint-controller';
import {createPublicClient, createWalletClient} from "viem";

const aliceAccount = privateKeyToAccount('0x...')
const bobAccount  = privateKeyToAccount('0x...')

const readClient = createPublicClient({
  chain: mainnet,
  transport: http()
})

const controller = new TrustedHintController({ readClient })

const namespace = '0x...' // address of namespace owner
const list = '0x...' // bytes32 list
const key = '0x...' // bytes32 key
const hintValue = await controller.getHint(namespace, list, key)

If you actually want to create or update hints, you need to initialize the TrustedHintController with a write client.

import {TrustedHintController} from '@spherity/trusted-hint-controller';
import {createWalletClient} from "viem";

const aliceAccount = privateKeyToAccount('0x...')

const writeClient = createWalletClient({
  account: aliceAccount,
  chain: mainnet,
  transport: http()
})

const controller = new TrustedHintController({
  writeClient
})

const namespace = aliceAccount.address
const list = '0x...' // bytes32 list
const key = '0x...' // bytes32 key
const hintValue = '0x...' // bytes32 value

await controller.setHint(namespace, list, key, hintValue)

If you want to use meta transactions, you can use the TrustedHintController with a wallet and meta transaction client.

import {TrustedHintController} from '@spherity/trusted-hint-controller';
import {createWalletClient} from "viem";

const aliceAccount = privateKeyToAccount('0x...')
const bobAccount = privateKeyToAccount('0x...')

const walletClient = createWalletClient({
  account: aliceAccount,
  chain: mainnet,
  transport: http()
})

const metaTransactionClient = createMetaTransactionClient({
  account: bobAccount,
  chain: mainnet,
  transport: http()
})

const controller = new TrustedHintController({
  walletClient,
  metaTransactionClient
})

const namespace = bobAccount.address
const list = '0x...' // bytes32 list
const key = '0x...' // bytes32 key
const hintValue = '0x...' // bytes32 value

// Bob signs a payload that allows alice to set a hint for him
await controller.setHintSigned(namespace, list, key, hintValue)