A python wrapper for the Molaris REST API
Project description
Introduction
A simple Python wrapper for the Molaris REST API. Useful for getting ERC-20 token prices, getting general token information and getting information about all tokens in a wallet.
Molaris
Use requires a Molaris API key which is currently available with the free Molaris service tier.
- https://moralis.io/
- https://deep-index.moralis.io/api-docs/#/
- https://docs.moralis.io/moralis-server/web3-sdk/moralis-web3-api-rest
Usage
Setup
Replace YOUR_API_KEY with the Moralis API Key.
from MoralisPy import MoralisPy
moralis = MoralisPy()
moralis.set_api_key("YOUR_API_KEY")
ERC-20 Tokens
Get Token Metadata
from pprint import pprint as pp
token_address = "0x8430146cFd6F29c2B580c1004787b7d3c9F9F3b8"
pp(moralis.get_token_metadata(token_address, "avalanche"))
{'address': '0x8430146cfd6f29c2b580c1004787b7d3c9f9f3b8',
'block_number': '8540191',
'decimals': '18',
'logo': None,
'logo_hash': None,
'name': 'VaporNodes',
'symbol': 'VPND',
'thumbnail': None,
'validated': 1 }
Get Token Price
pp(moralis.get_token_price(token_address,"avalanche"))
{'exchangeAddress': '0x9ad6c38be94206ca50bb0d90783181662f0cfa10',
'exchangeName': 'TraderJoe',
'nativePrice': {'decimals': 18,
'name': 'Avalanche',
'symbol': 'AVAX',
'value': '151093980928143'},
'usdPrice': 0.017792376973093486}
Wallets
Get information about all the ERC-20 tokens in a wallet, get the price of those tokens and calculate the total value of the wallet.
Native token prices (e.g. Eth, Avalanche etc.) are not provided by the Molaris API so aren't included in the sum
import pandas as pd
wallet = "YOUR_WALLET_ADDRESS"
erc20_assets, native_token_assets, erc20_token_assets = moralis.get_total_token_assets(wallet, ['eth','avalanche'])
erc20_df = pd.DataFrame(erc20_token_assets)
erc20_df.to_csv("erc20.csv")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file MoralisPy-1.0.1.tar.gz
.
File metadata
- Download URL: MoralisPy-1.0.1.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de048bcad69c19db0e18beb585e8c4d8a01769fd03ed7fe3a2481ffa13c93c19 |
|
MD5 | d5cb06ccdce0563d5dc03f5d6ad36e49 |
|
BLAKE2b-256 | b5c2dac8806b7e78438f0637a6b07dd4d18ffb1d2fb8570313080a55e2dd18a5 |
File details
Details for the file MoralisPy-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: MoralisPy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 108923e8652a9e7db6a69cdb6aa2fe3402dfb9a78de5e8dccaaaa5875d79b623 |
|
MD5 | 22f6527bd56bae2de3ee5be234a14e33 |
|
BLAKE2b-256 | af2793e11f9cd5d072559ac025be1f0da39ce99d1cea2d2424de9b820e60065a |