GithubHelp home page GithubHelp logo

arjunkotgire / ethereum-transaction-demo-alchemy Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 7 KB

This script configures the Alchemy SDK, initializes a wallet, defines an Ethereum transaction, signs it, and submits it to the blockchain. The resulting transaction hash is then logged for reference.

License: MIT License

JavaScript 100.00%
alchemysdk blockchain ethereum

ethereum-transaction-demo-alchemy's Introduction

Ethereum-Transaction-Demo-Alchemy

This script configures the Alchemy SDK, initializes a wallet, defines an Ethereum transaction, signs it, and submits it to the blockchain. The resulting transaction hash is then logged for reference.

Overview

This repository provides a Node.js example for automating Ethereum transactions using the Alchemy SDK. Alchemy SDK is a powerful blockchain developer platform that simplifies blockchain development tasks. The example demonstrates basic usage of the Alchemy SDK for fetching block information, token balances, NFTs, and listening to pending transactions.

Getting Started

1. Create an App

Visit the Alchemy SDK to create an app. After creating the app, you'll be provided with an API key and necessary details.

2. Install Dependencies

To integrate the Alchemy SDK into your project, follow these steps:

  1. Install the Alchemy SDK Package
 npm install alchemy-sdk

3. Code Example

create the index.js file for the below:

import { Network, Alchemy } from 'alchemy-sdk';

const settings = {
    apiKey: "your Alchemy API-KEY",
    network: Network.your_ref_network,
};

const alchemy = new Alchemy(settings);

// Get the latest block
const latestBlock = alchemy.core.getBlockNumber();

// Get all outbound transfers for a provided address
alchemy.core
    .getTokenBalances('provided address')
    .then(console.log);

// Get all the NFTs owned by an address
const nfts = alchemy.nft.getNftsForOwner("reference eth address");

// Listen to all new pending transactions
alchemy.ws.on(
    { method: "alchemy_pendingTransactions",
    fromAddress: "reference eth address" },
    (res) => console.log(res)
);

Create a .env file in the project root and add your Alchemy API -KEY and your wallet private key

Note: Replace 'your_private_key_here' with your actual private key. Do not share it with anyone!

API_KEY=your_reference_alchemy_API_key
PRIVATE_KEY=your_private_key_here

4. Run Code

node index.js

Documentation

ethereum-transaction-demo-alchemy's People

Contributors

arjunkotgire avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.