New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

smartpkg

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartpkg

Client for retrieving Smart Contract ABI

latest
npmnpm
Version
0.2.0
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

SmartPkg

Client to get Smart Contract ABI.

Why use SmartPkg?

We aim to improve developer experience in starting smart contract apps. Some problems we aim to solve:

  • Multi-chain smart contract development
  • Exploring smart contract ABI
  • Decoupling smart contract development from front/back-end development

Installation

npm install smartpkg

Usage

Here is an example of using smartpkg to get ABI.

import { ethers } from "ethers";
import smartpkg from "smartpkg";

const chainId = 1;
const address = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984";

const abi = await smartpkg.getAbi(chainId, address);

// Use Smart Contract
const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
const contract = new ethers.Contract(address, abi, signer);
const symbol = await contract.symbol();
console.log(symbol);

For getting Smart Contract ABI,

const abi = await smartpkg.getAbi(chainId, address);

For directly calling a smart contract (deployed) function without ABI,

const contract = await smartpkg.contract(chainId, address, { signer });
const symbol = await contract.symbol();

For directly calling a smart contract function with ABI only,

const contract = await smartpkg.contract(chainId, address, { abi, signer });
const symbol = await contract.symbol();

SmartPkg Options

OptionsTypeDefaultDescription
debugbooleantrueDebug mode
signerSigner or ProviderundefinedSigner or provider from ethers.js
abiABIundefinedDebug mode
enableDevtoolsbooleantrueEnable devtools or not. Install @smartpkg/devtools
enableLoggingbooleantrueEnable logging or not.

SmartPkg devtools

Devtools help improve understanding smart contract function calls in your DApp.

npm install @smartpkg/devtools

In main.tsx, import devtool and add the component.

// main.tsx
import SmartpkgDevtool from '@smartpkg/devtools';

ReactDOM
  .createRoot(document.getElementById('root') as HTMLElement)
  .render(
    <React.StrictMode>
      <App />
      <SmartpkgDevtool />
    </React.StrictMode>
  );

Devtools

Devtools

Devtools Details

Devtools Details

Keywords

ABI

FAQs

Package last updated on 28 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts