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

@kitzen/wallet-core-essentials

v1.1.48

Published

Kitzen Wallet Core Essentials is an open-source library, provides reusable components and core cryptographic wallet functionality for a different blockchains. It is a core part of Kitzen Wallet.

Downloads

101

Readme

wallet-core-essentials

npm version from kitzen with Love test Known Vulnerabilities

Kitzen Wallet Core Essentials is an open-source library, provides reusable components and core cryptographic wallet functionality for a different blockchains. It is a core part of Kitzen Wallet.

Installation

Modify package.json with

{  
  "scripts": {
    "postinstall": "patch-package"
  }
}

Copy patches

mkdir ./patches
cp ./node_modules/@tronscan/client/patches/* ./patches

Install the package

yarn add @kitzen/wallet-core-essentials

React-native installation

Create initialize.ts file and import it somewhere on the main entry, e.g. onm the react-native index.js

import {Buffer} from "buffer";
import {CryptoFactory} from "@kitzen/wallet-core-essentials";
import * as bip39 from "@kitzen/react-native-bip39";

global.Buffer = Buffer;
CryptoFactory.setBip39(bip39);

Web installation

Initialize factory, before using it:

import {Buffer} from "buffer";
import {CryptoFactory} from "@kitzen/wallet-core-essentials";
import {
  mnemonicToSeedSync,
  generateMnemonic
} from "bip39";

global.Buffer = Buffer;
CryptoFactory.setBip39({
  mnemonicToSeed: mnemonicToSeedSync,
  generateMnemonic: async(...args) => generateMnemonic(...args),
});

Library usage

You can access docs by themes here:

Testing

Library provides whole spectre of tests that occupies majority of cases that could happen or used in development. You can explore tests here

Tron hex message decode

There are 2 types of messages: with signature and without signature. You have to understand how protobuf works and it's structure and nested classes for Tron implementation. Take a look at node_modules/@tronscan/client/protobuf/core/Tron.proto You are interested in Transaction class. As you see it contains 2 fields.

  • raw_data (field number 1, type 'raw')
  • signature (field number 2, type 'repeated bytes')

If you have to parse such a hex message (with signature) you can do the following: With signature:

# pacman -S extra/protobuf
cd ./node_modules/@tronscan/client/protobuf
echo 'long-hex-message-string-like-a30174b6c2223' | xxd -r -p - > message.bin
protoc --decode protocol.Transaction core/Tron.proto < message.bin

You can also use https://protobuf-decoder.netlify.app/ but it won't show you fields names.

Let's say we have to decode a hex transaction without a signature. We clearly see that it's a type of raw by the Tron.proto file, so we do:

protoc --decode protocol.Transaction.raw core/Tron.proto < message.bin

Lets review the hex of Tron network Smart contract. This is a typical hex representation of the message that's being sent to backend api. And it's a binary representation of protobuf format.

| name | # | hex | description | |------------------------------------|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------| | Transaction | | 0a 02 a5 91 22 08 71 30 31 ee 43 e2 4b 93 40 a0 95 dd ad a9 31 5a ae 01 08 1f 12 a9 01 0a 31 74 79 70 65 2e 67 6f 6f 67 6c 65 61 70 69 73 2e 63 6f 6d 2f 70 72 6f 74 6f 63 6f 6c 2e 54 72 69 67 67 65 72 53 6d 61 72 74 43 6f 6e 74 72 61 63 74 12 74 0a 15 41 7a 86 49 ab fa 3d 24 f8 d0 dc 70 d2 b6 d5 0e 4f 8a 6f 76 13 12 15 41 a6 14 f8 03 b6 fd 78 09 86 a4 2c 78 ec 9c 7f 77 e6 de d1 3c 22 44 a9 05 9c bb 00 00 00 00 00 00 00 00 00 00 00 00 1c 00 0d d5 6b 9e 63 4f e6 73 46 b8 90 45 99 0c b7 bb 82 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 70 f4 c3 d9 ad a9 31 | Hex representation of protobuf transaction, which is sent as message to backend API | | transaction.type | 1 | 74 79 70 65 2E 67 6F 6F 67 6C 65 61 70 69 73 2E 63 6F 6D 2F 70 72 6F 74 6F 63 6F 6C 2E 54 72 69 67 67 65 72 53 6D 61 72 74 43 6F 6E 74 72 61 63 74 | type.googleapis.com/protocol.TriggerSmartContract | | transaction.sender_address | 1 | 41 7a 86 49 ab fa 3d 24 f8 d0 dc 70 d2 b6 d5 0e 4f 8a 6f 76 13 | hex(base58("TM94JwXLN33Gw4L8KF1eBPaEEPcdQi6hht")) | | transaction.contract_address | 2 | 41 a6 14 f8 03 b6 fd 78 09 86 a4 2c 78 ec 9c 7f 77 e6 de d1 3c | hex(base58("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t")) // USDT address | | transaction.param | 4 | a9 05 9c bb 00 00 00 00 00 00 00 00 00 00 00 00 1c 00 0d d5 6b 9e 63 4f e6 73 46 b8 90 45 99 0c b7 bb 82 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 | Abi encoded transfer(address,uint256) | | transaction.param.receiver_address | | 1c 00 0d d5 6b 9e 63 4f e6 73 46 b8 90 45 99 0c b7 bb 82 1d | hex(base58("CXFzBg8XjZF2NUjDSzSxXLBxeZxgPpS5o")), first T is dropped |

Contributing

We deeply appreciate the valuable contributions made by our community. To provide feedback or report bugs, kindly open a GitHub issue. For code contributions, explore our "Contributing" guidelines and become part of our open-source community.

Thank you to all the dedicated individuals who contribute; your passion drives our success. Together, we shape the future of web3 industry.