JSPM

@lit-protocol/contracts-sdk

8.0.0-alpha.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5322
  • Score
    100M100P100Q125912F
  • License MIT

Package Exports

  • @lit-protocol/contracts-sdk
  • @lit-protocol/contracts-sdk/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lit-protocol/contracts-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Lit Protocol Contracts SDK (Typescript)

ContractsSDK is a bundled package that allows you to make calls to Lit Protocol smart contracts. Some contracts come with additional abstracted functions that can be accessed by appending Util to the contract variable name, for example, pkpNftContract becomes pkpNftContractUtil.

Demo: https://demo-contracts-sdk-react.vercel.app/

Installation

yarn add @lit-protocol/contracts-sdk

Quick Start

Initialize an instance

We provide several ways to initialize an LitContracts instance, you can pass in your private key, ask itself to randomly generate one, your own signer, a PKP signer, etc.

// Most common way. Using your Metamask/Brave or any other third party wallet
const litContracts = new LitContracts();

// use a random private key
const litContracts = new LitContracts({ randomPrivatekey: true });

// use a random private key and store it in the local storage
const litContracts = new LitContracts({
  randomPrivatekey: true,
  options: {
    storeOrUseStorageKey: true,
  },
});

// use private key from local storage
const litContracts = new LitContracts({
  options: {
    storeOrUseStorageKey: true,
  },
});

// use custom private key
const litContracts = new LitContracts({
  privateKey: TEST_FUNDED_PRIVATE_KEY,
});

// custom signer
const privateKey = TEST_FUNDED_PRIVATE_KEY;
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
const signer = new ethers.Wallet(privateKey, provider);

const litContracts = new LitContracts({ signer });

// with a pkp wallet
// see more in https://github.com/LIT-Protocol/pkp-ethers
const pkpWallet = new PKPWallet({
  pkpPubKey: PKP_PUBKEY,
  controllerAuthSig: CONTROLLER_AUTHSIG,
  provider: 'https://rpc-mumbai.maticvigil.com',
});

await pkpWallet.init();

const litContracts = new LitContracts({ signer: pkpWallet });