Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/near/near-api-py
Python API to interact with NEAR via RPC API
https://github.com/near/near-api-py
Last synced: about 2 months ago
JSON representation
Python API to interact with NEAR via RPC API
- Host: GitHub
- URL: https://github.com/near/near-api-py
- Owner: near
- License: mit
- Archived: true
- Created: 2020-06-16T21:09:01.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-01T06:56:12.000Z (over 1 year ago)
- Last Synced: 2024-07-18T11:05:56.869Z (6 months ago)
- Language: Python
- Size: 32.2 KB
- Stars: 53
- Watchers: 9
- Forks: 29
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-near - near-api-py
README
# near-api-py
*Status: super rough, APIs are subject to change*
A Python library for development of applications that are using NEAR platform.
> **Warning**:
>
> `near-api-py` is out of date. Use `py-near`:
>
> - supports asynchronous requests
> - support `nearcore==0.17` and delegated transactions
> - uses `py-near-primitives` wrappers over rust
>
> **Repository**: https://github.com/pvolnov/py-near
>
> **Documentation:** https://py-near.readthedocs.io/en/latest/quickstart.html# Installation
```bash
pip install near-api
```# Usage example
## Send money
```python
near_provider = near_api.providers.JsonProvider("https://rpc.testnet.near.org")sender_key_pair = near_api.signer.KeyPair("ed25519:[SENDER_PRIVATE_KEY]")
sender_signer = near_api.signer.Signer("sender.testnet", sender_key_pair)
sender_account = near_api.account.Account(near_provider, sender_signer)out = sender_account.send_money("vsab.testnet", 1000)
print(out)
```## Smart contract call method
```python
contract_id = "contract.testnet"
signer_id = "signer.testnet"
signer_key = "ed25519:[SIGNER_SECRET_KEY]"
args = {"counter": 1, "action": "increase"}near_provider = near_api.providers.JsonProvider("https://rpc.testnet.near.org")
key_pair = near_api.signer.KeyPair(signer_key)
signer = near_api.signer.Signer(signer_id, key_pair)
account = near_api.account.Account(near_provider, signer)out = account.function_call(contract_id, "counter_set", args)
print(out)
```# Contribution
First, install the package in development mode:
```bash
python setup.py develop
```To run tests, use nose (`pip install nose`):
```bash
nosetests
```# License
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE and LICENSE-APACHE for details.