• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python high-level framework for NEAR Protocol

py-near

Financial Contributors on Open Collective PyPi Package Version Supported python versions Documentation Status Github issues MIT License Twitter

py-near is a pretty simple and fully asynchronous framework for working with NEAR blockchain.

Examples

πŸ“š Click to see some basic examples

Few steps before getting started...

  • Install the latest stable version of py-near, simply running pip install py-near
  • Create NEAR account and get your private key wallet

Simple money transfer

from py_near.account import Account
import asyncio
from py_near.dapps.core import NEAR

ACCOUNT_ID = "bob.near"
PRIVATE_KEY = "ed25519:..."


async def main():
   acc = Account(ACCOUNT_ID, PRIVATE_KEY)

   await acc.startup()
   print(await acc.get_balance() / NEAR)
   print(await acc.get_balance("bob.near") / NEAR)

   tr = await acc.send_money("bob.near", NEAR * 2)
   print(tr.transaction.hash)
   print(tr.logs)


asyncio.run(main())

Transfer money by phone number

from py_near.account import Account
import asyncio
from py_near.dapps.core import NEAR

ACCOUNT_ID = "bob.near"
PRIVATE_KEY = "ed25519:..."


async def main():
   acc = Account(ACCOUNT_ID, PRIVATE_KEY)

   await acc.startup()
   tr = await acc.phone.send_near_to_phone("+15626200911", NEAR // 10)
   print(tr.transaction.hash)


asyncio.run(main())

Parallel requests

Only one parallel request can be made from one private key. All transaction calls execute sequentially. To make several parallel calls you need to use several private keys

acc = Account("bob.near", private_key1)

for i in range(2):
  signer = InMemorySigner.from_random(AccountId("bob.near"), KeyType.ED25519)
  await acc.add_full_access_public_key(str(signer.public_key))
  print(signer.secret_key)

Now we can call transactions in parallel

acc = Account("bob.near", [private_key1, private_key2, private_key3])
# request time = count transactions / count public keys
tasks = [
  asyncio.create_task(acc.send_money("alisa.near", 1)),
  asyncio.create_task(acc.send_money("alisa.near", 1)),
  asyncio.create_task(acc.send_money("alisa.near", 1)),
]
for t in task:
  await t

Official py-near resources:

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Code of conduct].

More Repositories

1

ipfs-cache-server

Simple cache server for NFTs on IPFS
Python
74
star
2

Fonbet-1xBet-parser

ΠŸΠ°Ρ€ΡΠ΅Ρ€ появлСния Π½ΠΎΠ²Ρ‹Ρ… ΠΌΠ°Ρ‚Ρ‡Π΅ΠΉ Π½Π° сайтах букмСкСрских ΠΊΠΎΠ½Ρ‚ΠΎΡ€ (Π½Π°ΠΏΡ€. для поиска Π²ΠΈΠ»ΠΎΠΊ)
Jupyter Notebook
16
star
3

true-p2p

Eth Global NYC winner πŸ†. Protocol for P2P swaps based on onchain wire transfer confirmation
JavaScript
8
star
4

okx-hackaton

Crosschain bridge for small transactions start from 0.1$ β€’ 1st place at the OKX hackathon πŸ†
TypeScript
6
star
5

Merbobot

Π‘ΠΎΡ‚ для контроля качСства Π²Ρ‹ΠΊΠ»Π°Π΄ΠΊΠΈ Ρ‚ΠΎΠ²Π°Ρ€ΠΎΠ² Π½Π° ΠΏΠΎΠ»ΠΊΠ°Ρ… c ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ CV для ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ ЭЀКА, Ρ…Π°ΠΊΠ°Ρ‚ΠΎΠ½ URBAN TECH CHALLENGE
JavaScript
3
star
6

crosschain-kyc

Web app and smart contract bundle for cross-chain KYC DAO verification - 1st place at Superhack 2023 (LayerZero) πŸ†
Solidity
3
star
7

neafiol.github.io

About me
HTML
2
star
8

MasterBotKit

БСрвис для сборки ΠΌΠ½ΠΎΠ³ΠΎΡ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½Ρ‹Ρ… telegram Π±ΠΎΡ‚ΠΎΠ², занявший ΠΏΠ΅Ρ€Π²ΠΎΠ΅ мСсто Π½Π° Selectel Hackaton
Python
2
star
9

PACARS

ΠŸΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π½Π° Android, производящСС Π°Π²Ρ‚ΠΎΡ€Π΅Π³Π΅ΡΡ‚Ρ€Π°Ρ†ΠΈΡŽ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ Π½Π° Ρ€ΠΎΠ·Ρ‹Π³Ρ€Ρ‹ΡˆΠΈ Π±Ρ€Π΅Π΄ΠΎΠ²Ρ‹Ρ… Π²Π΅Ρ‰Π΅ΠΉ.
Java
2
star
10

Supreme-Dragon-Bot

КонсольноС ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π½Π° ваш ПК, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ΅ ΠΏΠΎΠ·Π²ΠΎΠ»ΠΈΡ‚ ΠΊΡƒΠΏΠΈΡ‚ΡŒ Π²Π΅Ρ‰ΠΈ ΠΈΠ· Π»ΠΈΠΌΠΈΡ‚ΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Ρ… ΠΊΠΎΠ»Π»Π΅ΠΊΡ†ΠΈΠΉ supreme Π·Π° считанныС сСкунды
HTML
2
star
11

Avito-Bot

Π‘Ρ€ΠΈΠΏΡ‚ Π½Π° python для ΠΏΠΎΠΈΠΌΠΊΠΈ появлСния Π½ΠΎΠ²Ρ‹Ρ… Ρ‚ΠΎΠ²Π°Ρ€ΠΎΠ² Π² Ρ€Π°Π·Π½Ρ‹Ρ… катСгориях Π½Π° avito, пСрСписки с ΠΏΡ€ΠΎΠ΄Π°Π²Ρ†Π°ΠΌΠΈ ΠΈ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΊΠΈ увСдомлСния Π² telegram bot
Python
1
star
12

challengeBot

Π‘ΠΎΡ‚ для Π³Ρ€ΡƒΠΏΠΎΠ²Ρ‹Ρ… Ρ‚Ρ€Π΅Π½ΠΈΡ€ΠΎΠ²ΠΎΠΊ ΠΏΠΎ Ρ„ΠΈΠ·ΠΊΡƒΠ»ΡŒΡ‚ΡƒΡ€Π΅ с ΡΠΊΡΠΏΠΎΠ½Π΅Ρ†ΠΈΠ°Π»ΡŒΠ½Ρ‹ΠΌ ΡˆΡ‚Ρ€Π°Ρ„ΠΎΠΌ Π·Π° пропуски
Python
1
star
13

near-primitives

Python wrapper on Rust near-primitive libr
Rust
1
star
14

SellTreck

API для поиска скидок Π² ΠΌΠ°Π³Π°Π·ΠΈΠ½Π°Ρ… поблизости ΠΈ построСниС ΠΌΠ°Ρ€ΡˆΡ€ΡƒΡ‚Π° ΠΏΠΎ ΠΌΠ°Π³Π°Π·ΠΈΠ½ΠΎΠΌ с минимальной суммой ΠΊΠΎΡ€Π·ΠΈΠ½Ρ‹
Python
1
star
15

Mmulti-Shop-Parser

ΠœΠΎΠ½ΠΈΡ‚ΠΎΡ€ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ Ρ‚ΠΎΠ²Π°Ρ€ΠΎΠ² с сайтов ΠΌΠ°Π³Π°Π·ΠΈΠ½ΠΎΠ² Ozon + Beru + Wilberries с ΡƒΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ Ρ‡Π΅Ρ€Π΅Π· telegram Π±ΠΎΡ‚Π°.
Python
1
star
16

ca-evm-wallet

NEAR dApp implementing Ethereum wallet functionality using Chain Signature
Rust
1
star