1.0.2 • Published 1 year ago

@krypc/web3-sdk v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Table of Contents

  1. Introduction
  2. Features
  3. Supported Chains
  4. Prerequisites
  5. Usage
  6. Suites
  7. Support
  8. Contributing
  9. License

Introduction

This package aims to simplify a developer's experience in building web3 products by providing them with a simple and easy to use suite of tools and methods to accelerate development.

Features

  • Quick and easy setup
  • Ready to use Infrastructure
  • Multiple Protocols Support
  • Different suites for development

Supported Chains

Currently, the SDK supports the following chains. We are working to add more chains. | Chain Name | Chain ID | | :-------- | :------- | | Polygon Mainnet | 137 | | Polygon Mumbai Testnet | 80001 | | Ethereum Mainnet | 1 | | Ethereum Goerli Testnet | 5 |

Prerequisites

The usage of the SDK requires an API key which can be obtained through the KrypC portal after reegistration.

Usage

Install the package from npm registry using the following command:

npm i @krypc/web3-sdk

Once installed, you can use it by following the steps below:

// Import the krypc web3 SDK
const sdk = require("@krypc/web3-sdk")

// Initialize the web3 Engine with your API key
const Web3Engine = new sdk.Web3Engine(<API_KEY>)

Once the Web3Engine is initialized with the API key, you can use all the features of the SDK.

Suites

The SDK offers various methods based on the various suites supported by the SDK. Suites are meant to simplify usage and provide you methods based on particular categories.

Current SDK suites have been listed below.

  • Wallet Suite
  • Storage Suite
  • NFT Suite
  • Utils Suite
  • Marketplace Suite

All of the methods available will be described in the below sections.

Wallet Suite

Method UsageInput ParametersReturnsDescription
Web3Engine.Wallet.getBalanceAddress, ChainIDNative token balance in WeiGet native token balance across supported chains
Web3Engine.Wallet.transferreceiver_address, signer, transfer_amount (in wei)Tx HashTransfer native token to any address across our supported chains
Web3Engine.Wallet.getERC20BalanceUser Address, Contract Address, Chain IDBalance of ERC-20 tokensGet any ERC-20 token balance across our supported chains
Web3Engine.Wallet.transferERC20receiver_address, signer, Contract Address, transfer_amount (in wei)Tx HashTransfer ERC-20 tokens across our supported chains
Web3Engine.Wallet.signMessagemessage, signerECDSA signatureGenerate ECDSA signature of a message from wallet
Web3Engine.Wallet.verifySignatureonChainmessage, ECDSA signature, signer AddressbooleanVerify signature on-chain through a deployed smart contract (gasless)
Web3Engine.Wallet.verifySignatureOffChainmessage, ECDSA signature, signer AddressbooleanVerify signature off-chain
Web3Engine.Wallet.getCurrentChainIdEthers providerChainIDGet chain ID of currently connected network
Web3Engine.Wallet.getCurrentChainNameEthers providerChain NameGet chain name of currently connected network
Web3Engine.Wallet.switchNetworkprovider, chainIDstatusSwitch network

Storage Suite

Method UsageInput ParametersReturnsDescription
Web3Engine.Storage.uploadtoIPFSFileCID HashUpload any file to IPFS and get the CID associated with it.
Web3Engine.Storage.getFileFromIPFSCID Hashfile contentRetrieve a file from IPFS using the CID
Web3Engine.Storage.getGatewayLinkCID HashGateway URLGet the IPFS URL of the file using CID

Utils Suite

Method UsageInput ParametersReturnsDescription
Web3Engine.Utils.connectWalletWallet Array (possible options: coinbase, walletconnect)provider, signerProvide multiple wallet connection options by passing input as array of required wallets. Metamask is supported by default.
Web3Engine.Utils.resolveAddresstoENSAddressENS NameReturns ENS Domain associated with address
Web3Engine.Utils.resolveENStoAddressENS NameAddressReturns address associated with an ENS Domain
Web3Engine.Utils.deployContractsigner, abi, bytecode, constructor argscontract addressReturns address of deployed contract
Web3Engine.Utils.callContractMethodsigner, contractAddress, abi, methodName, argscontract addressAllows you to make a transaction with any deployed contract
Web3Engine.Utils.callContractViewMethodprovider, contractAddress, abi, methodName, argscontract addressAllows you to call any view functions in the contract (no gas)

NFT Suite

Method UsageInput ParametersReturnsDescription
Web3Engine.Nft.createNftCollectionsigner, collectionName, symbolcontract addressCreate an NFT collection across our supported chains
Web3Engine.Nft.mintNfttoCollectionsigner, contractAddress, nftName, nftDescription, nftContentTx HashMint a NFT to your collection across our supported chains

Support

For support, email or join our Discord channel.

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

MIT