Griptape.js
  • What is Griptape.js?
  • 🛹Getting Started
  • 🚀Bootstrapping Your App
  • 🗞️Interacting with Contracts
    • Contract Definitions
      • More on Definitions
    • Creating Contract Clients
    • Built-In Definitions
    • Extending Contract Definitions
    • Contract Registry
    • Instantiating Contracts
  • 🔑Using Viewing Keys and Permits
    • Using the viewing key manager
    • Using Keplr with Griptape
    • Managing Permits
  • 🕢Handling Events
  • ⚒️Using Utilities
  • 🔀API Reference
    • Bootstrap
    • Contracts
    • Viewing Keys
    • Permits
    • Events
    • Utilities
  • 🐝Tricks Tutorials
    • React Tutorials
      • Hello, Griptape
      • Hello, Contracts
      • Hello, Events
      • Hello, Viewing Keys
      • Hello, Permits
      • Hello, Transactions
      • Hello, Mint
    • Vue Tutorials
      • Hello, Griptape
      • Hello, Contracts
      • Hello, Events
      • Hello, Viewing Keys
      • Hello, Permits
      • Hello, Transactions
      • Hello, Mint
  • 💾Hackathon
    • Welcome Packet
    • Getting Set Up
    • Glossary
Powered by GitBook
On this page
  • Add viewing key
  • Replace viewing key
  • Get viewing key
  • Remove viewing key
  1. Using Viewing Keys and Permits

Using the viewing key manager

A viewing key manager is an object provided by Griptape to manage viewing keys in a centralized way. This is definitely a helper utility and is not necessary for you to manage viewing keys using this API. One advantage of using this API is that it integrates directly with the contracts API.

Here we have some examples to better understand how the API works.

It's important to mention that when interacting with contracts, viewing keys exposed by the Contextshould be registered using the viewingKeyManager in order for queries to have the viewing key available.

Add viewing key

import { viewingKeyManager, ... } from '@stakeordie/griptape.js';
const sefi = refContract<Snip20Contract>('sefi');
viewingKeyManager.add(sefi, 'api_key_J41LMWYXaZqknjcmaex...');

Replace viewing key

viewingKeyManager.set(sefi, 'api_key_J41LMWYXaZqknjcmaex...');

Get viewing key

const key = viewingKeyManager.get(sefi.at); // Either a contract address or the id of the contract client

Remove viewing key

viewingKeyManager.remove(sefi.at) // Either a contract address or the id of the contract client
PreviousUsing Viewing Keys and PermitsNextUsing Keplr with Griptape

Last updated 2 years ago

🔑