Skip to content

React App demoing the capability of Alchemy's Core/Assets API SDK

License

Notifications You must be signed in to change notification settings

DraconMarius/tokenapi-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alchemy Token API - Demo

License: MIT

Check out the badges hosted by shields.io

Deployed Heroku Link

Description

A GUI demo-ing the capability of Alchemy's Token API SDK


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

if you run into any issue with conflicting dependency with the split-flap display, you can include --legacy-peer-deps tag in your npm i / install script in your package.json.

if you are indeed hosting your own version, please ensure that there is a .env file with your Alchemy API Key set up correctly in your project!

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

To query blockchain token data using the Alchemy SDK requires the follow params:

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

gif0

Owned Tokens and metaData /api/balance/:net/:address alchemy.core.getTokenForOwner()

  • network (for SDK config)
  • wallet address
  • pageKey (optional)

With Alchemy's SDK, once we instantiate our config, we do not require network as a param. All operation using that config would be for a specific network only. We only need our wallet address hash to query tokens owned.

For this demo's purpose, I had filtered out any token with zero balances, and som eadditional filter on our React side to filter any spam like token names.

Also we have a functional pagination on our React side, which store new and subsequent pageKeys from our API call, allowing us to easily page through large amount of tokens in a wallet.

gif1

filter

pagination

Transactions related to focused Token /api/tokentx/:net/:wallet/:token alchemy.core.getAssetTransfers()

  • network (for SDK config)
  • to/from-Address
  • contract address
  • excludeZeroValue (true/false)
  • category ["erc20", "erc721", "erc1155"]
  • withMetadata (true/false)

From our token owned page, we utilize the token contract address to query all of the transactions between the current address and current focused token.

Before passing our response to the frontend, we are using alchemy.core.getTokenMetadata() to add additional information such as token logo to our result (if applicable).

gif2

filter

All in/out bound transactions associated from a Contract on specific Network /api/transactions/:net/:address alchemy.core.getAssetTransfers()

  • network (for SDK config)
  • wallet address
  • pageKey (optional)
  • sorting direction (optional)
  • exclude Zero value (optional)
  • type of transactions [external, erc20, erc721, erc1155, specialnft]
  • maxCount (50)

To get all assets transfer for a specific address, we would have to account for the direction of the transaction. Here we are calling getAssetTransfers twice, once with our wallet set to fromAddress and the other as toAddress

gif3

Transaction Receipts /api/receipt/:net/:hash alchemy.core.getTransactionReceipt()

  • network (for SDK config)
  • Transaction Hash

From our list of transactions, we are utilizing the transaction hash to look up additional informations associated to that tx.

gif5


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

React App demoing the capability of Alchemy's Core/Assets API SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published