Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viem #59

Closed
Tracked by #13
manuelbarbas opened this issue Dec 22, 2023 · 1 comment
Closed
Tracked by #13

Viem #59

manuelbarbas opened this issue Dec 22, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@manuelbarbas
Copy link
Collaborator

manuelbarbas commented Dec 22, 2023

Viem

Viem is a TypeScript interface for Ethereum that provides low-level stateless primitives for interacting with Ethereum.

Some of the main features are:

  • Abstractions over the JSON-RPC API
  • APIs for interacting with Smart Contracts
  • Utilities for working with ABIs

For more information check the View Documentation

Implementation Example

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;
	});
@manuelbarbas manuelbarbas added enhancement New feature or request and removed enhancement New feature or request labels Dec 22, 2023
@manuelbarbas
Copy link
Collaborator Author

What is: Library
Language: Typescript
Target: Web

@manuelbarbas manuelbarbas added the documentation Improvements or additions to documentation label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant