Skip to content

DraconMarius/testnet-tx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alchemy Testnet Transaction

License: MIT

Check out the badges hosted by shields.io

Deployed Heroku Link

Description

A web app for sending testnet tokens for various supported testnet network, with receipt and transaction history (10 inound and 10 outbound)


Table of Contents


Installation

This project is hosted on a heroku eco-dyno, when it is not being actively used it requires a bit extra start up time. This can be mitigated by upgrading to the next tier on heroku.

Deployed Heroku Link

If you would like to host a version of it yourself, please follow these instructions:

to install both the client and server side dependencies: npm i

start the server: npm start

to concurrently start server and client react code w/ hotreload: npm run develop

This deployed project currently uses a wallet address's secret key set in the .env. (this will be for the address where the testnet tokens are from) If hosting a standalone instance, please ensure both Alchemy API key and secret key are availble in .env

If you would like to host a heroku version of it privately, make sure you have heroku CLI installed, and at the root of the project run heroku create app_name. After we confirmed that it has been deployed. Navigate to your heroku project page and ensure that all of your env var is set.

envvar


Usage

Utilizing Alchemy SDK, we are able to query wallet balance, specific transactions and send transactions:

You are able to connect your browser extension wallets that utilizes the EIPS-6963 which helps avoid conflict and improves user experience.

Wallet Balance and History /api/balance alchemy.core.getBalance()

  • network (based on Alchemy SDK instance)
  • address (from env var: SECRET_KEY)

We are first instantiating a new Alchemy SDK instance for each supported network iteratively, then using alchemy.core.getBalance() with our wallet address to return our Ether balance for each network respectively.

within this project, we are using our Secret_Key set in our environment variale, and using Alchemy SDK's Wallet helper to help us access our address hash without hardcoding it

balanceRoute

Sending Transaction /api/send/:net/:to alchemy.core.sendTransaction()

  • network (translated to chainID)
  • receiving address
  • gasLimit
  • maxPriorityFeePerGas & maxFeePerGas from alchemy.core.getFeeData()
  • nonce from alchemy.core.getTransactionCount() optinoal set to pending
  • value

We are first using alchemy.core.getTransactionCount() to get our nonce, and alchemy.core.getFeeData() for our maxFee/PriorityFee per Gas. After we gathered all the required parameters, we then use SDK's Wallet helper signTransaction(tx) to sign our transaction before sending it with alchemy.core.sendTransaction(rawTx).

Once the transaction is sent, it will live in the mempool, it automatically return a transaction hash, but this hash has yet to be mined and will not show up on any of the scanner until it is officially mined.

sendTx

Receipts /api/receipt/:net/:hash alchemy.transact.waitForTransaction()

  • network
  • Transaction Hash

After we received the transaction hash from sendTranasaction we use waitForTransaction to return a receipt response after it had successfully mined.

receipt

Transaction History /api/transactions alchemy.core.getAssetTransfers

  • network
  • toAddress / fromAddressZ
  • excludeZeroValue (true/false)
  • category [external]
  • maxCount
  • withMetadata (true/false)

Since we want to show both inbound and outbound transaction history, we are calling getAssetTransfers twice. Due to ease of displaying info, I had set our maxCount to 10.

params historyFetch



License

License: MIT


Author

Mari Ma

github linkedin

Icon credit @ Anton Kalashnyk


Questions

For any questions, please reach out directly or by creating an issue.

About

transactions on testnet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published