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

@web3sdkio/sdk

v1.0.14

Published

The main web3sdkio SDK.

Downloads

6

Readme

Installation

Install the latest version of the SDK with npm:

npm install @web3sdkio/sdk ethers

or with yarn:

yarn add @web3sdkio/sdk ethers

Quick start

1. Deploy & customize your contracts

2. Reading data from your contracts

The quickest way to get started is to use the SDK as read only (no transactions). This will allow you to query data from any contract with no additional setup.

// my_script.js
import { Web3sdkioSDK } from "@web3sdkio/sdk";

// instantiate the SDK in read-only mode (our example is running on `polygon` here)
// all major chains and testnets are supported (e.g. `mainnet`, 'optimism`, 'arbitrum', 'polygon', `goerli`, 'mumbai', etc.)
const sdk = new Web3sdkioSDK("polygon");

// access your deployed contracts
const contract = await sdk.getContract("0x...");

// Read data using direct calls to your contract
const myData = await contract.call("myFunction");

// Or Using the extensions API matching to your contract extensions
const allNFTs = await contract.erc721.getAll();
const tokenSupply = await contract.erc20.totalSupply();

You can execute this code as a node script by executing:

node my_script.js

Note that you can also access any deployed contract using its ABI, using sdk.getContractFromAbi(address, abi) and get the same functionality. For contracts deployed via web3sdkio, we handle the ABI for you.

3. Executing transactions on your contracts

In order to execute transactions on your contract, the SDK needs to know which wallet is executing those transactions. This can be done two ways:

  • Using your own private key (typically used in the backend or scripts)
  • By connecting to a user wallet (typically used in the frontend)

3.1 Backend / Scripting usage

Here's how to provide your own private key to the SDK to perform transactions with your account from scripts or from a node.js backend:

// my_script.js
import { Web3sdkioSDK } from "@web3sdkio/sdk";

// Learn more about securely accessing your private key: https://docs.web3sdk.io/web3-sdk/set-up-the-sdk/securing-your-private-key
const privateKey = "<your-private-key-here>";
// instantiate the SDK based on your private key, with the desired chain to connect to
const sdk = Web3sdkioSDK.fromPrivateKey(privateKey, "polygon");

// deploy existing contracts, or your own using the web3sdkio CLI
const deployedAddress = sdk.deployer.deployNFTCollection({
  name: "My NFT Collection",
  primary_sale_recipient: "0x...",
});

// access your deployed contracts
const contract = await sdk.getContract(deployedAddress);

// Execute any of your functions on your contracts from the connected wallet
await contract.call("myFunction", arg1, arg2);

// Or execute transactions using the extensions API
await contract.erc721.mint({
  name: "Cool NFT",
  description: "Minted NFT from code!",
  image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
});

You can execute this code as a node script by executing:

node my_script.js

3.2 Frontend usage

For frontend applications, head over to our React Github repo which shows you how to connect to a user's wallet like Metamask, and automatically instantiate the web3sdkio SDK for you.

Easiest way to get started on the frontend is using one of our templates in the web3sdkio examples repo.

API Reference & code examples

Build from source

To build the project:

yarn install
yarn build

After building, to run the tests (requires a local hardhat node running):

yarn test:all

OR

If you have make and docker installed you can simply run

make test

Get in touch