Coder Social home page Coder Social logo

many_abis's Introduction

Many Abis

Version Pypi

GitHub Org's stars GitHub forks


Get different DEX abis easily for blockchain developers.


Now we support dex:



Installation

  • Download
pip install many-abis

# pypi
pip install -i https://pypi.org/simple many-abis

# update
pip install -U many-abis
# or
pip install -U -i https://pypi.org/simple many-abis

Usage

import many_abis as ma

# ======================================================================
# get all abi names
print(ma.ALL_ABIS_NAME)

# get all abis
print(ma.ABIS)

# you can access ABI by dot name
print(ma.ABIS.ERC20)


# ======================================================================
# get abi from address using etherscan api
ma.get_abi_from_address(
    "0x0841BD0B734E4F5853f0dD8d7Ea041c241fb0Da6",
    "YOUR API KEY",
    ma.CHAIN_CONTRACT_API.BSC
)

# ======================================================================
# chains
chains = ma.all_chains()
print(chains)
# ['arbitrum', 'avalanche', 'bsc', 'bsc-test', 'cronos', 'eth', 'fantom', 'heco', 'kcc', 'moonriver', 'okx', 'polygon', 'optimism']

# different methods to get chain
bsc = ma.get_chain_by_id(chain_id=56)
bsc = ma.get_chain_by_name(name="bsc")
bsc = ma.get_chain(name="bsc")
bsc = ma.get_chain(chain_id=56)
bsc = ma.chain(name="bsc")
bsc = ma.chain(chain_id=56)
print(bsc)

# use ['key'] or dot key name to access chain info
print(bsc['chain_id'])
# 56
print(bsc.name)
# Binance Smart Chain Mainnet
print(bsc.dex.pancake_v2.router_address)
# 0x10ED43C718714eb63d5aA57B78B54704E256024E

# to get some items from chain
eth_weth = ma.get('eth', 'weth')
print(eth_weth)
# {'address': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 'name': 'Wrapped ETH', 'symbol': 'WETH'}

ds = ma.get('bsc', 'dex', 'pancake_v2')
print(ds)
# {'factory_address': '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73', 'name': 'PancakeSwap v2', 'router_address': '0x10ED43C718714eb63d5aA57B78B54704E256024E', 'website': 'https://pancakeswap.finance/swap'}

# print all dex
ma.print_all_dex()

many_abis's People

Contributors

ackness avatar mraniki avatar soulmachine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

many_abis's Issues

你好,方便优化代码,让它在pycharm等编辑上 的智能提示 更友好吗

你好, 我目前 是这样加载的 (多个 中括号 拼接)

编辑器没办法智能提示, 只能手动拼接,

不知道 未来是否有计划完善智能提示

谢谢

from many_abis import ABIS, CHAINS
 
uniswap_factory_abi = ABIS["UNISWAP_V2_FACTORY"]
uniswap_factory_address = CHAINS["eth"]["dex"]["uniswap_v2"]["factory_address"]

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.