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

@4ire-labs/near-sdk

v1.0.0-beta.9-rc.3

Published

SDK for NEAR Protocol

Downloads

9

Readme

Coverage Status

Install

npm install @4ire-labs/near-sdk

Use

TL;DR run example

NEAR_ENV=testnet
NEAR_SENDER_ID=name.testnet
NEAR_SENDER_PRIVATE_KEY=ed25519:data
import * as near from '@4ire-labs/near-sdk'
import 'dotenv/config'

NFT

class NFTBasic extends near.NEP4Standard {
    mintToken(owner_id: string, token_id: number): Promise<near.Outcome<void>> {
        return this.callRaw({
            methodName: 'mint_token',
            args: {owner_id, token_id},
        })
    }
}

async function token() {
    const ownerContract = near.custodianAccount(near.accountIdBySlug('nep4'))
    const NFTContract = await near.Contract.connect(
        NFTBasic,
        near.accountIdBySlug('nep4'),
        ownerContract,
    )
    const tokenId = +new Date
    const mintTrx = await NFTContract.mintToken(ownerContract.accountId, tokenId)
    console.log(`Minted NFT #${tokenId}:`, {
        accountId: await NFTContract.getTokenOwner(tokenId),
        transactionId: mintTrx.transactionId,
    })
}
Minted NFT #1622990248520: {
  accountId: 'nep4.local',
  transactionId: 'nep4.local:5d5o65nfmWWdbXXwtfM9mdqyR6E7X2VEPt586JeSHQK4'
}

Account

async function account() {
    const deposit = '0.05'
    const entropy = Buffer.from('0123456789ABCDEF')
    const mnemonic = near.generateMnemonic(entropy)
    console.log('mnemonic:', mnemonic)

    // Implicit Account
    // https://docs.near.org/docs/roles/integrator/implicit-accounts
    const newImplicitAccount = near.mnemonicToAccount(mnemonic)
    console.log('Implicit Account:', {
        accountId: newImplicitAccount.accountId,
        publicKey: newImplicitAccount.keyPair.publicKey.toString(),
    })
    await near.writeUnencryptedFileSystemKeyStore(newImplicitAccount)

    // Getting Sender Account
    const sender = near.parseAccountNetwork()
    console.log('Sender Account:', {
        accountId: sender.accountId,
        publicKey: sender.keyPair.publicKey.toString(),
    })
    let trx: near.Outcome<boolean>
    let newAccount: near.AccountNetwork

    // Normal Account
    newAccount = near.mnemonicToAccount(mnemonic, near.accountIdBySlug(`sample${+new Date}`))
    await near.writeUnencryptedFileSystemKeyStore(newAccount)
    trx = await near.createAccount(sender, newAccount, deposit)
    console.log('Created normal account:', {
        accountId: newAccount.accountId,
        publicKey: newAccount.keyPair.publicKey.toString(),
        transactionId: trx.transactionId,
    })
    trx = await near.deleteAccount(newAccount)
    console.log('Deleted transactionId:', trx.transactionId)

    // Custodial Account
    newAccount = near.custodianAccount(near.accountIdBySlug(`sample${+new Date}`), sender)
    trx = await near.createAccount(sender, newAccount, deposit)
    await near.writeUnencryptedFileSystemKeyStore(newAccount)
    console.log('Created custodial account:', {
        accountId: newAccount.accountId,
        publicKey: newAccount.keyPair.publicKey.toString(),
        transactionId: trx.transactionId,
    })
    trx = await near.deleteAccount(newAccount)
    console.log('Deleted transactionId:', trx.transactionId)
}
mnemonic: coral maze mimic half fat breeze thought choice drastic boss bacon middle
Implicit Account: {
  accountId: '47d322f48bf873ad10c1b6ed2253518d3d3e0cad9a1a72a9c62b311400b72c7a',
  publicKey: 'ed25519:5qNgFf7z5huxn11jgPJBnX2RGdmcmYodhLWnd71oozgH'
}
Sender Account: {
  accountId: 'local',
  publicKey: 'ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX'
}
Created normal account: {
  accountId: 'sample1622990251089.local',
  publicKey: 'ed25519:5qNgFf7z5huxn11jgPJBnX2RGdmcmYodhLWnd71oozgH',
  transactionId: 'local:EpGPDCgKUbdGZQsx517bMSfiYSbCEqa49xrw1J6Voobk'
}
Deleted transactionId: sample1622990251089.local:CLnDXM7JAZqiWLWdthdrAB6SdBNmW9S9SFZvPKP8JmNn
Created custodial account: {
  accountId: 'sample1622990256631.local',
  publicKey: 'ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX',
  transactionId: 'local:2TCrKv62VeViFdnQB9AknYpVXRuxVp4zA8rccAgNmctq'
}
Deleted transactionId: sample1622990256631.local:3gwSA1hEiZ3rWja3tPifZPbWhr7ok39FTfaNg4VrqNbP

🧙‍♂ Docs for develop 🧝‍♀️