Closed manuelbarbas closed 4 months ago
Viem is a TypeScript interface for Ethereum that provides low-level stateless primitives for interacting with Ethereum.
Some of the main features are:
For more information check the View Documentation
Package Install
npm i viem
Send Transaction
import {createPublicClient, http,parseGwei } from "viem"; import { privateKeyToAccount } from 'viem/accounts' import { skaleChaosTestnet } from "viem/chains"; import {contract_abi,contract_adress} from "./contract"; import dotenv from 'dotenv'; dotenv.config(); async function main() { const client = createPublicClient({ chain: skaleChaosTestnet, transport: http() }); const pk = "0x"; const account=privateKeyToAccount(pk); const signature = await account.signTransaction({ to:contract_adress, gas:parseGwei('0.0005'), gasPrice:parseGwei('0.0001'), nonce: await client.getTransactionCount({address:account.address}), data: '0xeefa7dfd0000000000000000000000002b3937fe6ef38cd4be0d9ceb05823087b716d689' }) const hash = await client.sendRawTransaction({serializedTransaction:signature}); console.log(hash); } main() .catch((err) => { console.error(err); process.exitCode = 1; });
What is: Library Language: Typescript Target: Web
Viem
Viem is a TypeScript interface for Ethereum that provides low-level stateless primitives for interacting with Ethereum.
Some of the main features are:
For more information check the View Documentation
Implementation Example
Package Install
Send Transaction