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-starknet

v1.0.9

Published

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

Downloads

266

Readme

@okxweb3/coin-starknet

Starknet SDK is used to interact with the Starknet 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-starknet

Usage

Generate private key

import {StarknetWallet} from "@okxweb3/coin-starknet";

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

Private key derivation

import {StarknetWallet} from "@okxweb3/coin-starknet";

let wallet = new StarknetWallet()
let param = {
    mnemonic: `gaze supreme human audit aisle entry galaxy shy lock time such auto`,
    hdPath: `m/44'/9004'/0'/0/0`
}
let privateKey = await wallet.getDerivedPrivateKey(param);

Generate address

import {StarknetWallet} from "@okxweb3/coin-starknet";

let wallet = new StarknetWallet()
let param: NewAddressParams = {
    privateKey: '603c85d20500520d4c653352ff6c524f358afeab7e41a511c73733e49c3075e',
}
let data = await wallet.getNewAddress(param)

Verify address

import {StarknetWallet} from "@okxweb3/coin-starknet";

let wallet = new StarknetWallet()
let param1: ValidAddressParams = {
    address: "0x06c3c93eeb1643740a80a338b9346c0c9a06177bfcc098a6d86e353532090ae4"
};
let valid = await wallet.validAddress(param1); // true

let param2: ValidAddressParams = {
    address: "1895a6a77ae14e7987b9cb51329a5adfb17bd8e7c638f92d6892d76e51cebcf"
}
let valid2 = await wallet.validAddress(param2); // false

Transfer STARKNET-ETH

import {StarknetWallet} from "@okxweb3/coin-starknet";

let wallet = new StarknetWallet()
let param: SignTxParams = {
    privateKey: '0x0603c85d20500520d4c653352ff6c524f358afeab7e41a511c73733e49c3075e',
    data: {
        type: "transfer",
        transferData: {
            contractAddress: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
            from: "0x6c3c93eeb1643740a80a338b9346c0c9a06177bfcc098a6d86e353532090ae4",
            to: "0x026e9E8c411056B64B2D044EBCb39FC810D652Cfbe694326651d796BB078320b",
            amount: "1700000000000000"
        },
        nonce: "1",
        maxFee: "14000000000000",
        }
}
let data = await wallet.signTransaction(param)

Contract call

import {StarknetWallet} from "@okxweb3/coin-starknet";

let wallet = new StarknetWallet()
let param: SignTxParams = {
    privateKey: '0x0603c85d20500520d4c653352ff6c524f358afeab7e41a511c73733e49c3075e',
    data: {
        type: "contract_call",
        contractCallData: {
            contractAddress: "0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82",
            from: "0x06c3c93eeb1643740a80a338b9346c0c9a06177bfcc098a6d86e353532090ae4",
            functionName: "initiate_withdraw",
            callData: ["0x62e206b4ddd402056d881ded58c0bd87193d2913", "0x38d7ea4c68000", "0"]
        },
        nonce: "2",
        maxFee: "1864315586779310",
    }
}
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 {StarknetWallet} from "@okxweb3/coin-starknet";

let wallet = new StarknetWallet()
const privateKey = "0x0603c85d20500520d4c653352ff6c524f358afeab7e41a511c73733e49c3075e";
let param: SignTxParams = {
    privateKey: privateKey,
    data: {
        message: "0xec04138ec537328244f24236a84bb72d0fe428f6d4955ca20a5f6420066b5"
    }
}
const sig = await wallet.signMessage(param);

// verify
const verifyParam: VerifyMessageParams = {
    signature: "",
    data: {
        signature: sig.signature,
        hash: sig.hash,
        publicKey: sig.publicKey,
    }
}
const ok = await wallet.verifyMessage(verifyParam);

License

Current package is MIT licensed.