New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@bandada/utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bandada/utils

General Bandada utility functions.


Version published
Weekly downloads
85
decreased by-73.27%
Maintainers
3
Weekly downloads
 
Created

Bandada utils

General Bandada utility functions.

Github license NPM version Downloads Linter eslint Code style prettier

This package provides simple utility functions that can be used by Bandada itself or externals.

🛠 Install

npm or yarn

Install the @bandada/utils package with npm:

npm i @bandada/utils

or yarn:

yarn add @bandada/utils

📜 Usage

# request(url: string, config?: AxiosRequestConfig): Promise<any>

Makes a request using Axios.

import { request } from "@bandada/utils"

const url = "https://api.bandada.pse.dev/groups"
const config = {
    headers: {
        "Content-Type": "application/json"
    },
    baseURL: "https://api.bandada.pse.dev"
}
const group = await request(url, config)

# shortenAddress(address: string, chars: number): string

Returns a shorter address.

import { shortenAddress } from "@bandada/utils"

const address = shortenAddress("0x1234567890123456789012345678901234567890")

# getProvider(network: Network, apiKey?: string): JsonRpcProvider

Returns the provider to communicate with the blockchain.

import { getProvider } from "@bandada/utils"

const provider = getProvider("localhost")

# getContract(contractName: ContractName, network: Network, privateKeyOrSigner?: string | Signer, apiKey?: string): Contract

Returns an Ethers contract.

import { getContract } from "@bandada/utils"

const contractName = "Semaphore"
const network = "localhost"
const contract = getContract(contractName, network)

# getSemaphoreContract(network: Network, privateKeyOrSigner?: string | Signer, apiKey?: string): SemaphoreContract

Returns a new instance of the SemaphoreContract class.

import { getSemaphoreContract } from "@bandada/utils"

const semaphore = getSemaphoreContract("localhost")

# getBandadaContract(network: Network, privateKeyOrSigner?: string | Signer, apiKey?: string): BandadaContract

Returns a new instance of the BandadaContract class.

import { getBandadaContract } from "@bandada/utils"

const bandada = getBandadaContract("localhost")

# getWallet(privateKey: string, network?: Network, apiKey?: string): JsonRpcProvider

Returns an Ethers wallet.

import { getWallet } from "@bandada/utils"

const privateKey =
    "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
const wallet = getWallet(privateKey)

# getContractAddresses(networkName: Network): { Bandada: string, Semaphore: string, BandadaSemaphore: string }

Returns the contract addresses for the Bandada, Semaphore and BandadaSemaphore smart contracts.

import { getContractAddresses } from "@bandada/utils"

const addresses = getContractAddresses("sepolia")

FAQs

Package last updated on 09 Apr 2024

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