GithubHelp home page GithubHelp logo

moralis-python-sdk's Introduction

Moralis JS SDK

Moralis Python SDK

Join the Moralis DAO on Discord Check the docs Discourse posts
pypi

A library that gives you access to the powerful Moralis Server backend from your Python app.


Features:

  • Web3 authentication
  • Make Evm api and Solana api calls
  • Stream realtime blockchain data

... and much more. Check the official Moralis docs for more details.

๐Ÿš€ Quick start

If you're new to Moralis, check the quickstart guide in the official docs on how to get started.

If you're already familiar with Moralis and have your account registered. Then follow along to connect your SDK:

1. Install Moralis

pip install moralis

2. Call your methods

Import the correct module from the SDK and call the method you need. For a full reference of all the methods available, check the references section.

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e", 
    "chain": "eth", 
    "to_block": 1.2, 
}

result = evm_api.balance.get_native_balance(
    api_key=api_key,
    params=params,
)

print(result)

๐Ÿงญ Table of Contents

โญ๏ธ Star us

If this JS SDK helps you build your dapps faster - please star this project, every star makes us very happy!

๐Ÿค Need help

If you need help with setting up the boilerplate or have other questions - don't hesitate to write in our community forum and we will check asap. Forum link. The best thing about this SDK is the super active community ready to help at any time! We help each other.

๐Ÿ‘€ Examples

Example getting native balance of an address via the EVM balance API

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e", 
    "chain": "eth", 
    "to_block": 1.2, 
}

result = evm_api.balance.get_native_balance(
    api_key=api_key,
    params=params,
)

print(result)

Example getting native balance of an address via the SOL account API

from moralis import sol_api

api_key = "YOUR_API_KEY"
params = {
    "network": "", 
    "address": "", 
}

result = sol_api.account.balance(
    api_key=api_key,
    params=params,
)

print(result)

Example getting authentication message via the Auth API

from moralis import auth

api_key = "YOUR_API_KEY"
body = {
    "domain": "defi.finance", 
    "chainId": "1", 
    "address": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B", 
    "statement": "Please confirm", 
    "uri": "https://defi.finance/", 
    "expirationTime": "2020-01-01T00:00:00.000Z", 
    "notBefore": "2020-01-01T00:00:00.000Z", 
    "resources": ['https://docs.moralis.io/'], 
    "timeout": 15, 
}

result = auth.challenge.request_challenge_evm(
    api_key=api_key,
    body=body,
)

print(result)

Example getting stream via the Streams API

from moralis import streams

api_key = "YOUR_API_KEY"
params = {
    "limit": 1.2, 
    "cursor": "", 
}

result = streams.evm_streams.get_streams(
    api_key=api_key,
    params=params,
)

print(result)

๐Ÿ“š References

For more info see the live docs, or the docs pages

evm_api

sol_api

auth

streams

๐Ÿง™โ€โ™‚๏ธ Community

moralis-python-sdk's People

Contributors

b4rtaz avatar ernow avatar github-actions[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

moralis-python-sdk's Issues

JSON decode error when calling sync_nft_contract

New Bug Report

Checklist

Issue Description

Exception:

Traceback (most recent call last):
  File "/home/paul/repos/early-exploration/contract-names/source_moralis.py", line 25, in <module>
    evm_api.nft.sync_nft_contract(
  File "/home/paul/.cache/pypoetry/virtualenvs/contract-names-AXv8L-X6-py3.10/lib/python3.10/site-packages/moralis/evm_api/nft/sync_nft_contract.py", line 25, in sync_nft_contract
    return json.loads(api_response.response.data)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Steps + code to reproduce

from moralis import evm_api
evm_api.nft.sync_nft_contract(
          api_key="...",
          params={"chain": "eth", "address": "0x046dac4d647e1d2b026ec54be819fe2ee59de8fd"},
)

Actual Outcome

The above exception

Expected Outcome

An "ok" from the api. The api instead returns an empty string, but the SDK doesn't accept that

Environment

Server

  • Moralis server version: latest (not self hosted)

Client

  • Moralis SDK version: 0.1.36
  • Operating system: Linux
  • Browser: None

Update version of dependent , or use looser range of version.

Version solving failed in poetry.

Because no versions of moralis match >0.1.41,<0.2.0
 and moralis (0.1.41) depends on typing-extensions (>=4.3.0,<4.4.0), moralis (>=0.1.41,<0.2.0) requires typing-extensions (>=4.3.0,<4.4.0).
And because redis-om (0.2.1) depends on typing-extensions (>=4.4.0,<5.0.0)
 and no versions of redis-om match >0.2.1,<0.3.0, moralis (>=0.1.41,<0.2.0) is incompatible with redis-om (>=0.2.1,<0.3.0).
So, because betdog-backend depends on both redis-om (^0.2.1) and moralis (^0.1.41), version solving failed.

[REQ] for feedback on the python client

Request

Hi there. I am the author of the openapi-generator python client which has now moved to https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
Your repo uses this client.
I want to make sure that I understand what is important to the end users of the python client. If you have some time can you provide some feedback on what features you value in the generator, any pain points, and what you would like improved?
If you could provide your feedback here it would help with future improvements. Thank you!

Checklist

Current Limitation

Feature / Enhancement Description

Example Use Case

Alternatives / Workarounds

3rd Party References

Pinned versions in requirements.txt are too restrictive

New Feature Request

Checklist

Current Limitation

The requirements in the requirements.txt file are too restrictive, because they pin exact package versions. They make it impossible to install moralis in my environment together with other packages.

Feature / Enhancement Description

Please don't make such restrictive dependency requirements, I don't think they are necessary for proper operation. For example only specify a minimum version.

Alternatives / Workarounds

Currently I need to bypass the dependency checks and install dependencies manually to get it work.

AttributeError: module 'moralis.evm_api.transaction.transaction' has no attribute 'get_wallet_active_chains'

New Bug Report

Checklist

Issue Description

Trying to get the multi-chain activity of an address but getting AttributeError for the given method in documentation.
In the API Reference page it is using a different module but same thing AttributeError

Steps + code to reproduce

from moralis import evm_api

api_key = "YOUR_API_KEY"

params = {
    "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
    "chains": ["eth", "bsc", "polygon"],
}

result = evm_api.transaction.get_wallet_active_chains(
    api_key=api_key,
    params=params,
)

print(result)

AND

from moralis import evm_api

api_key = "YOUR_API_KEY"

params = {
  "chains": [
    "eth"
  ],
  "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
}

result = evm_api.wallets.get_wallet_active_chains(
  api_key=api_key,
  params=params,
)

print(result)

Actual Outcome

AttributeError: module 'moralis.evm_api.transaction.transaction' has no attribute 'get_wallet_active_chains'

AND

AttributeError: module 'moralis.evm_api.evm_api' has no attribute 'wallets'

Expected Outcome

{
  "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
  "active_chains": {
    "chain": "eth",
    "chain_id": "0x1",
    "first_transaction": {
      "block_number": "123456789",
      "block_timestamp": "2022-08-23T20:58:31.000Z",
      "transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09"
    },
    "last_transaction": {
      "block_number": "123456789",
      "block_timestamp": "2022-08-23T20:58:31.000Z",
      "transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09"
    }
  }
}

Environment

Server

  • Moralis server version: 2.0

Client

  • Moralis SDK version: 0.1.37
  • Operating system: EndeavourOS
  • Browser: Google Chrome

Logs

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.