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

@okxweb3/coin-sui

v1.0.8

Published

SUI SDK is used to interact with the SUI blockchain, it contains various functions can be used to web3 wallet.

Downloads

266

Readme

@okxweb3/coin-sui

SUI SDK is used to interact with the SUI blockchain, it contains various functions can be used to web3 wallet.

Installation

Npm

To obtain the latest version, simply require the project using npm :

npm install @okxweb3/coin-sui

Usage

Generate private key

import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
let privateKey = await wallet.getRandomPrivateKey();

Private key derivation

import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
let param = {
    mnemonic: "street media penalty witness hollow cook nose uniform fury lazy mystery stone ",
    hdPath: "m/44'/784'/0'/0'/0'"
};
let privateKey = await wallet.getDerivedPrivateKey(param);

Generate address

import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
let params: NewAddressParams = {
    privateKey: "MQ/Fsgp+UkzF4ITMwDkhVUl9XrEsP/BUseLw9BEVFz4dkFEGZOAzm1y+JdQcUxvzF4yRRJSng5oa+uOMdozpUg=="
};
let address = await wallet.getNewAddress(params);

Verify address

import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
let param: ValidAddressParams = {
    address: "0x936accb491f0facaac668baaedcf4d0cfc6da1120b66f77fa6a43af718669973"
};
let valid = await wallet.validAddress(param);

Sign transaction

import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
let param = {
    privateKey: base.toBase64(secretKey), 
    data: {
        type:'raw',
        data: base.toBase64("data bytes")
    }
}
 let data = await wallet.signTransaction(param)

Transfer SUI

Input coins with 3 fields objectId,version,digest

import {base, signUtil} from '@okxweb3/crypto-lib';
import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
var coins = [{
    digest: "EjsrAaitTHoCxAWuCH5zuEzReSkvPPWst19WA8fxSpyp",
    objectId: "0x359f24668c02f1a1d25abe38e9b01e7c2f05ca86dcefb82ef32938dab2a4214e",
    version: 12
}]
const b64Key = "MQ/Fsgp+UkzF4ITMwDkhVUl9XrEsP/BUseLw9BEVFz4="
const { secretKey } = signUtil.ed25519.fromSeed(base.fromBase64(b64Key))
const d: PaySuiTransaction = { 
    inputCoins: coins,
    recipient: '0x215d3a67d951ebd5b453b440497917b5fac2890fc7f18358322d372e2f13045d',
    amount: 10, 
    gasBudget: 1046,
    gasPrice: 1
}
let param = {
    privateKey: base.toBase64(secretKey), 
    data: {
        type:'paySUI',
        data:d
    }
}
let data = await wallet.signTransaction(param)

Sign the message

note that the message is a string, not the txBytes of the transaction. Do not sign the transaction with this method!!

import {SuiWallet} from "@okxweb3/coin-sui";

let wallet = new SuiWallet()
let param = {
    privateKey: base.toBase64(secretKey), 
    data: "im okxer"
}
let data = await wallet.signMessage(param);

License

Current package is MIT licensed.