Socket
Socket
Sign inDemoInstall

viem

Package Overview
Dependencies
14
Maintainers
2
Versions
2027
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    viem

TypeScript Interface for Ethereum


Version published
Weekly downloads
594K
increased by1.21%
Maintainers
2
Created
Weekly downloads
 

Package description

What is viem?

The 'viem' npm package is a versatile library designed for interacting with Ethereum blockchain networks. It provides a range of functionalities including connecting to Ethereum nodes, sending transactions, interacting with smart contracts, and more.

What are viem's main functionalities?

Connecting to Ethereum Nodes

This feature allows you to create a client that connects to an Ethereum node using a specified URL. In this example, the client connects to the Infura mainnet node.

const { createClient } = require('viem');
const client = createClient({
  url: 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID'
});

Sending Transactions

This feature allows you to send transactions on the Ethereum network. The example demonstrates sending 1 ETH from one address to another.

const { sendTransaction } = require('viem');
const tx = await sendTransaction(client, {
  from: '0xYourAddress',
  to: '0xRecipientAddress',
  value: '1000000000000000000' // 1 ETH in wei
});

Interacting with Smart Contracts

This feature allows you to interact with smart contracts by calling their functions. The example shows how to call a function of a smart contract using its ABI and function name.

const { callContractFunction } = require('viem');
const result = await callContractFunction(client, {
  contractAddress: '0xContractAddress',
  abi: [
    // ABI of the contract
  ],
  functionName: 'functionName',
  args: [/* function arguments */]
});

Other packages similar to viem

Readme

Source

viem logo

TypeScript Interface for Ethereum

Version Code coverage MIT License Downloads per month Best of JS


Features

  • Abstractions over the JSON-RPC API to make your life easier
  • First-class APIs for interacting with Smart Contracts
  • Language closely aligned to official Ethereum terminology
  • Import your Browser Extension, WalletConnect or Private Key Wallet
  • Browser native BigInt, instead of large BigNumber libraries
  • Utilities for working with ABIs (encoding/decoding/inspection)
  • TypeScript ready (infer types from ABIs and EIP-712 Typed Data)
  • First-class support for Anvil, Hardhat & Ganache
  • Test suite running against forked Ethereum network

... and a lot lot more.

Overview

// 1. Import modules.
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

// 2. Set up your client with desired chain & transport.
const client = createPublicClient({
  chain: mainnet,
  transport: http(),
});

// 3. Consume an action!
const blockNumber = await client.getBlockNumber();

Documentation

Head to the documentation to read and learn more about viem.

Community

Check out the following places for more viem-related content:

Support

Sponsors

paradigm logo
family logo context logo WalletConnect logo zksync logo PartyDAO logo Dynamic logo Sushi logo Stripe logo BitKeep logo Privy logo Spruce logo rollup.id logo pancake logo celo logo pimlico logo zora logo lattice logo supa logo

Contributing

If you're interested in contributing, please read the contributing docs before submitting a pull request.

Authors

License

MIT License

Keywords

FAQs

Last updated on 13 Feb 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc