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

hardhat-boilerplate-with-typescripted-contracts-artifacts

v0.0.7

Published

Package consists of following artifacts useful for Token contract interaction: - `contracts/` - `json` artifacts of the contracts. Useful contract **abi** are here, - `typechain-types/` - typechain-types of all contracts [optional], - `frontend-clients`

Downloads

21

Readme

hardhat-boilerplate-with-typescripted-contracts-artifacts

Package consists of following artifacts useful for Token contract interaction:

  • contracts/ - json artifacts of the contracts. Useful contract abi are here,
  • typechain-types/ - typechain-types of all contracts [optional],
  • frontend-clients - frontend oriented classes those need only [optional] signer and abi to initiate and then used to interact with contract logic. Kinda API with the contracts in the blockchain.

Install

npm i hardhat-boilerplate-with-typescripted-contracts-artifacts

Example Repo Code

Script code that you may run with ts-node <script.ts> is below:

import {Token} from "hardhat-boilerplate-with-typescripted-contracts-artifacts/dist/typechain-types";
import {ethers} from "ethers";
// For the line below "resolveJsonModule": true policy should be used.
import ZkTurkArtifacts
    from "hardhat-boilerplate-with-typescripted-contracts-artifacts/dist/contracts/ZkTurk.sol/ZkTurk.json";
import {
    TokenContractClient
} from "hardhat-boilerplate-with-typescripted-contracts-artifacts/dist/frontend-clients/TokenContractClient";

// ZkTurk contract deployed address (You should know the address).
const contractAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
// Hardhat network localhost (You should have node available on rpc).
const rpcProviderUrl = "http://localhost:8545"

async function workWithFrontendClientExample() {
    // Bad example of how to use wallet from a private key.
    const privateKeyFoo = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"  // From Hardhat network.
    const provider = new ethers.providers.JsonRpcProvider(rpcProviderUrl)  // harhdat localhost
    const signer = new ethers.Wallet(privateKeyFoo, provider);

    // RM ts-ignore if uses real frontend provider, like commented below:
    // const provider = new ethers.providers.Web3Provider(window.ethereum);
    // const signer = provider.getSigner()
    // @ts-ignore
    const client = new TokenContractClient(signer, ZkTurkArtifacts.abi, contractAddress)

    console.log('client.transfer()', await client.transfer('0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199', 1))
}


async function workWithContractExample() {
    const provider = new ethers.providers.JsonRpcProvider(rpcProviderUrl)
    const contractInstance = new ethers.Contract(contractAddress, ContractArtifacts.abi, provider) as Token;

    // Signer is not needed for contract call
    console.log('await contractInstance.owner()', await contractInstance.owner())
}


async function main() {
    console.log('Starting...')
    await workWithContractExample()
}

main().catch((error) => {
    console.error(error);
    process.exitCode = 1;
});

Example of tsconfig.json

{
  "compilerOptions": {
    "incremental": true,            /* Enable incremental compilation */
    "target": "es5",                /* Specify ECMAScript target version: */
    "module": "commonjs",           /* 'none', 'commonjs', 'amd', 'system', etc */
    "declaration": true,            /* Concatenate & emit output to single file.*/
    "outDir": "dist",                /* Redirect output to the directory. */
    "esModuleInterop": true,        /* Enables intero between CommonJS and ES */
    "skipLibCheck": true,           /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true, /* Disallow inconsistently */
    "resolveJsonModule": true
  }
}

Example of package.json dependency entities

  "dependencies": {
    "ts-node": "^10.9.1",
    "typescript": "^5.1.6"
  },
  "devDependencies": {
    "@types/node": "^20.4.0"
  }