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

hedera-services

v1.0.40

Published

This microservice is created to connect any frontend or backend application to hedera block chain network.

Downloads

7

Readme

hedera-services

This microservice is created to connect any frontend or backend application to hedera block chain network.

This package will help users to create NFTs in batch & Transfer ownership of NFT to other users.

Note: Creating NFTs in batch saves the GAS amount charged per NFT creation. Currently for each NFT creation hedera charges around 14 HBARs as GAS cost. With batch NFTs creation you can create around 1,000 NFTs with same GAS cost as 1 NFT i.e around 14 HBARs.

Not only NFTs but this package will also help to create custom fungible tokens on hedera network with capability of transferring it to multiple users withing hedera eco system.

This package will also help to swap custom fungible tokens to HBARs & vice versa.

Getting started

  1. Install package using command npm install hedera-services

  2. Initialise and Get the the Client as follow:

     const initClient = async (
         operatorId,
         operatorPvKey,
         maxQueryPayment,
         isMainNet = false
     ) => {
         try {
             const client = await getClient(           
                 operatorId,
                 operatorPvKey,
                 maxQueryPayment,
                 isMainNet
             );  
             global.client;
             global.client = client;
         } catch (error) {
             throw error;
         }
     };
  3. Non Fungible Token:

    A. To create new NFTs:

     createAndMintToken(
         "<token_name>", //string
         "<token_symbol>", //string(max 3 characters)
         "<nft_owner_account_id>", //string
         "<nft_owner_account_private_key>"  //string
         "<nft_meta_data>" //array of buffered string
     );

    B. To create new NFTs with limited supply

     mintFiniteNFTs(
         "<token_name>", //string
         "<token_symbol>", //string(max 3 characters)
         "<nft_owner_account_id>", //string
         "<nft_owner_account_private_key>"  //string
         "<nft_meta_data>", //array of buffered string
         "<max_supply>", //integer
     )

    C. To create non fungible token

     createNonFungibleToken(
         tokenName, 
         "<token_name>", //string
         "<token_symbol>", //string(max 3 characters)
         "<account_id>", //string 
         "<account_private_key>", //string
     )

    D. To mint non fungible token

     mintNonFungibleToken(
         "<token_id>", //string
         "<account_id>", //string 
         "<account_private_key>", //string 
         "<metadata>", //array of buffered string 
     )

    E. To transfer NFT ownership:

     purchaseNFT(
         "<nft_token_id>", //string 
         "<nft_sell_price>", //int (in TinyBars)
         "<new_owner_account_id>", //string
         "<new_owner_private_key>" //string
         "<existing_owner_account_id>" //string
         "<existing_owner_private_key>", //string
         "<serial_no>" //int (to trnasfer specific NFT from batch, provide selected NFT serial number. you can get the serial   number of NFT from hedera mirror nodes api)
     );

    F. To transfer NFT with Royalty:

     purchaseNFT(
         "<nft_token_id>", // string 
         "<nft_sell_price>", // int (in TinyBars)
         "<new_owner_account_id>", // string
         "<new_owner_private_key>" // string
         "<existing_owner_account_id>" // string
         "<existing_owner_private_key>", // string
         "<serial_no>" // int (to trnasfer specific NFT from batch, provide selected NFT serial number. you can get the serial number of NFT from hedera mirror nodes api)
         "<royaltyPercentage>", // int
         "<creatorAccount>" // string
     );

    G: To tansfer NFT using Fungible token

     purchaseNFTUsingToken(
         "<tokenId>", // string
         "<sellPrice>", // int
         "<serialNumber>", // int
         "<fungibleToken>", // string
         "<buyerAccount>", // string
         "<buyerPvKey>", // string
         "<sellerAccount>", // string
         "<sellerPvKey>", // string
     )

    H: To tansfer NFT using fungible token with royalty

     purchaseNFTUsingToken(
         "<tokenId>", // string
         "<sellPrice>", // int
         "<serialNumber>", // int
         "<fungibleToken>", // string
         "<buyerAccount>", // string
         "<buyerPvKey>", // string
         "<sellerAccount>", // string
         "<sellerPvKey>", // string
         "<royaltyPercentage>", // int
         "<creatorAccount>", // string
     )

    I. To transfer multiple NFTs:

     transferMultipleNFTs(
         "<nft_token_id>", //string 
         "<nft_sell_price>", //int (in TinyBars)
         "<new_owner_account_id>", //string
         "<new_owner_private_key>" //string
         "<existing_owner_account_id>" //string
         "<existing_owner_private_key>", //string
         "<array_of_serial_no>" //array of int (to trnasfer specific NFT from batch, provide selected NFT serial number. you can get the serial   number of NFT from hedera mirror nodes api)
     )

    J. Burn NFT Serial Number:

     burnNonFungibleToken(
         "<account_id>", // string 
         "<account_private_key>", // string
         "<token_id>", // string
         "<serial_number>" // array of int
     )
  4. Fungible Token:

    A. To create Fungible Token

     createFungibleToken(
         "<token_name>", // string
         "<token_symbol>", // string
         "<token_owner_account_id>", // string
         "<token_owner_account_key>", // string
         "<initial_supply>", // int
         "<decimals>", // int
     );

    B. To transfer fungible tokens to other hedera account

     transferFungibleToken(
         "<token_id>", // string
         "<token_sender_account_id>", // string
         "<token_sender_private_key>", // string
         "<token_reciver_account_id>", // string
         "<token_reciver_private_key>", // string
         "<token_quntity>" // int
     )

    C. To swap Fungible Token with Hbar

     swapFungibleToken(
         "<token_buyer_account_id>", // string
         "<token_buyer_private_key>", // string
         "<token_provider_account_id>", // string
         "<token_provider_private_key>", // string
         "<token_id>", // string
         "<quntity_of_token>", // int
         "<conversion_rate_with_Hbar>", // float
     )
     note: Here token buyer is who want to buy token with exchange of Hbar.

    D. To update Fungible Token Supply

     updateFungibleTokenSupply(
         "<token_id>", // string
         "<user_id>", // string
         "<user_key>", // string
         "<amount>", // int
     )
  5. Files:

    A. Create File

     createFile(
         "<account_id>", // string 
         "<account_private_key>", // string 
         "<content>", // string 
     );

    B. Read File

     getFileContent(
         "<account_id>", // string 
         "<account_private_key>", // string 
         "<content>", // string 
     );

    C. Update File

     updateFile(
         <account_id> // string,
         <account_private_key> //string,
         <file_id> // string,
         <file_key> // string,
         <content> // string,
     );

    D. Append File

     appendFile(
         <account_id> // string,
         <account_private_key> //string,
         <file_id> // string,
         <file_key> // string,
         <content> // string,
     )

    E. Delete File

     appendFile(
         <account_id> // string,
         <account_private_key> //string,
         <file_id> // string,
         <file_key> // string,
     )

Create new hedera account:

A. Create Hedera Acount using Private Key

createHederaAccount(<initial_balance_in_tinybars>)

B. Create Hedera Acount using 24 word Phrases

createAccountUsingPhrases(
    <initial_balance_in_tinybars> // int
    <array_of_24_phrases> // array of string
)

Transfer HBars

transferHBar(
    <sender_account_id>, // string
    <sender_private_key>, // string
    <reciver_account_id>, // string
    <amount> // float
)

Notes:

  1. We are not saving any private keys of users for security reasons.
  2. NFTs created through this package can be validated from hedera mirror node apis. (https://testnet.mirrornode.hedera.com/api/v1/tokens/{token_id}/nfts https://mainnet.mirrornode.hedera.com/api/v1/tokens/{token_id}/nfts)