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

partisia-blockchain-applications-crypto

v1.0.22

Published

```bash npm i partisia-blockchain-applications-crypto ```

Downloads

86

Readme

Install

npm i partisia-blockchain-applications-crypto

Wallet

Wallet Mnemonic

import { partisiaCrypto } from 'partisia-blockchain-applications-crypto'

// 24 word mnemonic
const mnemonic = partisiaCrypto.wallet.generateMnemonic(24)
const keyPair = partisiaCrypto.wallet.getKeyPairHD(mnemonic)

// this is you private key pair
const { address, privateKey, publicKey } = keyPair

Wallet Legacy

import { partisiaCrypto } from 'partisia-blockchain-applications-crypto'

// 24 word mnemonic
const mnemonic = partisiaCrypto.wallet.generateMnemonic(24)
const keyPair = partisiaCrypto.wallet.getKeyPairLegacy(mnemonic)

// this is you private key pair
const { address, privateKey, publicKey } = keyPair

If you have a private key

const address = partisiaCrypto.wallet.privateKeyToAccountAddress('<32 bytes private key>')

Transaction

Serialize and Deserialize a Public Contract Transaction

See: https://gitlab.com/partisiablockchain/language/abi-client-ts

Serialize and Deserialize a System Contract Transaction

// Serialize Transaction
const abi = partisiaCrypto.abi_system.Payload_MpcTransferWithMemo
const txSerialized = partisiaCrypto.transaction.serializedTransaction(
  {
    nonce: 1, //'<get from querying address on chain>'
  },
  {
    contract: '01a4082d9d560749ecd0ffa1dcaaaee2c2cb25d881',
  },
  {
    invocationByte: 23,
    recipient: '001122331122331122331122331122331122331122',
    amount: 10000,
    memo: 'Sending MPC',
  },
  abi
)

console.log('txSerialized', txSerialized.toString('hex'))
// 000000000000000100000182f07ec3b6000000000000001401a4082d9d560749ecd0ffa1dcaaaee2c2cb25d8810000002d1700112233112233112233112233112233112233112200000000000027100000000b53656e64696e67204d5043

// Deserialize Transaction
const tx = partisiaCrypto.transaction.deserializeTransactionPayload(txSerialized, false)
console.log('tx', tx)

/* 
{
  signature: '',
  inner: { nonce: '1', validTo: '2022-08-30T20:45:09.493Z', cost: '20' },
  header: {
    contract: '01a4082d9d560749ecd0ffa1dcaaaee2c2cb25d881',
    payload_length: '45'
  },
  payload: '1700112233112233112233112233112233112233112200000000000027100000000b53656e64696e67204d5043',
  deserialized: {
    invocationByte: 23,
    recipient: '001122331122331122331122331122331122331122',
    amount: '10000',
    memo: 'Sending MPC'
  }
} 
*/

Sign

Sign Message

// Send message from Alice to Barry
// Alice encrypts message with Barry's public key
const message = 'hello'
const messageEncrypted = partisiaCrypto.wallet.encryptMessage('<public key of Barry>', message)

// Barry decrypts message with private key
const messageDecrypted = partisiaCrypto.wallet.decryptMessage('<private key>', messageEncrypted).toString('utf8')

assert(message === messageDecrypted)

Sign Transaction

const digest = partisiaCrypto.transaction.deriveDigest(
  'Partisia Blockchain',
  Buffer.from(
    '000000000000000100000182f07ec3b6000000000000001401a4082d9d560749ecd0ffa1dcaaaee2c2cb25d8810000002d1700112233112233112233112233112233112233112200000000000027100000000b53656e64696e67204d5043',
    'hex'
  )
)
partisiaCrypto.wallet.signTransaction(digest, '<private key from wallet>')