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

@levain/wallet-sdk

v34.1.0

Published

![npm downloads per month](https://img.shields.io/npm/dm/%40levain%2Fwallet-sdk)

Downloads

6,199

Readme

Levain TypeScript SDK

npm downloads per month

Levain allows you to start, run and grow your crypto business with enterprise-grade security and self-custody wallet infrastructure.

This is the official Levain SDK for TypeScript. It provides a set of tools to interact with the Levain GraphQL API easily. For the complete Levain GraphQL API documentation, refer to the Levain developer docs.

Installation

We recommend using pnpm to install the package. If you don't have it installed, you can install it by following the instructions here.

To install the Levain TypeScript SDK, run the following command:

pnpm install @levain/wallet-sdk

Examples

For complete examples, refer to the Developer Guides section within the Levain developer docs. You will find examples using Levain SDK, together with using the Levain GraphQL API directly if there isn't a corresponding SDK method.

Creating wallet example

import { generate } from '@levain/levain-client-keygen';

const accessToken = 'lvp_M71B0IVbFyAl5sg6uPkaPP0K9LBOyN4xWRkRhiHXkXcb0fe265';
const orgId = '000000000000';
const organizationNetworkId = '8accb40f-aa7d-483d-b82b-55852cbb321f';
const walletPassword = '<your wallet password here>';

const client = new LevainGraphClient({
  accessToken: 'lvp_ZaWT5JxWACwFBzj5VMSsqZ0Kfxo8BzLxnVYZca28OFb5713bb5',
  url: 'https://app.levain.tech/graphql',
});

// Create gas tank
const gasTank = await client.createGasTank({
  orgId,
});

// Fund gas tank

// Create keys
const mainKey = generate(walletPassword);
const backupKeyPair = generate(walletPassword);

const key1 = await client.createKey({
  orgId,
  type: KeyType.ScalarNeutered,
  publicKey: mainKey.publicKey,
  retrieveIfExists: false,
});
const key2 = await client.createKey({
  orgId,
  type: KeyType.ScalarNeutered,
  publicKey: backupKeyPair.publicKey,
  retrieveIfExists: false,
});
const key3 = await client.createKey({ orgId, type: KeyType.Rsa, retrieveIfExists: false });

// Create wallet
const wallet = await client.createWallet({
  orgId,
  organizationNetworkId,
  type: WalletType.EvmContractSafe, // or WalletType.EvmContractSimpleMultiSig,
  name: 'My new wallet',
  mainKey: {
    keyId: key1.keyId,
    passwordRecoveryKeyId: key3.keyId,
    encryptedPrivateKey: mainKey.encryptedPrivateKey,
  },
  backupKey: {
    keyId: key2.keyId,
  },
});

console.log(wallet); // { walletId: "de96428b-cd1b-4643-b62d-e2dfb2953897" }

Executing transaction example

const accessToken = 'lvp_M71B0IVbFyAl5sg6uPkaPP0K9LBOyN4xWRkRhiHXkXcb0fe265';
const orgId = '000000000000';
const ethNetworkAssetId = '41928452-cf9c-4e53-9bb5-caa5d1d367d5';
const walletId = '12b10782-d3fb-49fe-8cce-872bb7ea8d74';
const walletAddress = '0xf05A37144AcbFCBF3747E1EF4dCA8ee84f960Bad';
const walletPassword = '<your wallet password here>';

const client = new LevainGraphClient({
  accessToken,
  url: '/graphql',
});

// Fund your wallet with sufficient funds and whitelist the destination address first

// Create transaction request
const txRequest = await client.createTransactionRequest({
  walletId,
  networkAssetId: ethNetworkAssetId, // For custom transactions, omit `networkAssetId` and input `data` instead
  destinationAddress: walletAddress,
  amount: '0.1',
  gasLimit: 100_000,
});

// Approve transaction
await client.approveTransactionRequest({
  transactionRequestId: txRequest.requestId,
});

// Create transaction digests after approval quorum has been met
const txDigest = await client.createTransactionDigests({
  orgId,
  walletId,
  requestId: txRequest.requestId,
});

// Execute transaction
const executedTransaction = await client.executeTransaction({
  walletId,
  orgId,
  requestId: txRequest.requestId,
  digests: [
    {
      digest: txDigest.digest,
      digestId: txDigest.digestId,
    },
  ],
  walletPassword,
});

console.log(executedTransaction); // { transactionHash: "0xfdd6039a143e654f0131a1e1baba954ba1258f29675ddaae19e22d00608b45cf" }

Deposit address example

const accessToken = 'lvp_M71B0IVbFyAl5sg6uPkaPP0K9LBOyN4xWRkRhiHXkXcb0fe265';
const walletId = '12b10782-d3fb-49fe-8cce-872bb7ea8d74';
const erc20Address = '0x9aE64687D1ddD9c08aCD3d62A0d2f3af6cC350D4';

const client = new LevainGraphClient({
  accessToken: 'lvp_ZaWT5JxWACwFBzj5VMSsqZ0Kfxo8BzLxnVYZca28OFb5713bb5',
  url: '/graphql',
});

// Create deposit address
const depositAddress = await client.createWalletDepositAddress({
  walletId,
  label: 'My new address',
  toAutoDeploy: false,
});

// Deploy deposit address
await client.deployWalletDepositAddress({
  walletId,
  walletDepositAddressId: depositAddress.walletDepositAddressId,
});

// Wait for minimum network block confirmations

// Flush balance of a single ERC20 token from the deposit address to the main address
await client.flushWalletDepositAddress({
  walletId,
  erc20Address,
  walletDepositAddressId: depositAddress.walletDepositAddressId,
});