Near async rpc client
Project description
Near async rpc client
JsonProvider
Use JsonProvider to process api calls to NEAR rpc node
rpc_url
varies by network:
-
mainnet https://rpc.mainnet.near.org
-
testnet https://rpc.testnet.near.org
-
betanet https://rpc.betanet.near.org (may be unstable)
-
localnet http://localhost:3030
from async_near.providers import JsonProvider
jp = JsonProvider(rpc_url)
res = jp.view_call(account_id, method_name, args, finality="optimistic")
Signer
Use Signer to sign or request to rpc node
from async_near.signer import Signer, KeyPair
key = KeyPair(private_key) # create key pair (private-publish)
signer = Signer(
signer_account_id,
key,
)
signer.sign(message)
Signer
Use Account to create and execute transactions
from async_near.signer import Signer, KeyPair
from async_near.providers import JsonProvider
from async_near.account import Account
acc = Account(
JsonProvider("https://rpc.testnet.near.org"),
Signer(
"example.testnet",
KeyPair("ed25519:5sn12Kwd2TZn4A3...7979"),
),
)
await acc.startup()
Make contract calls
btc_amount = (await acc.view_function("btc_contract_id", "available_btc", {}))["result"]
await acc.function_call(
"btc_contract_id",
"ft_transfer_call",
{"target_btc_address": "..."},
)
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.
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
async_near-0.1.1.2.tar.gz
(7.9 kB
view hashes)
Built Distribution
Close
Hashes for async_near-0.1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fcf459a12c7a096b9ea078a3200d1efee4c1476c99954c7dd6481eaeb7def30 |
|
MD5 | ba95b5ffa0576f4e787c332fea6d5a1f |
|
BLAKE2b-256 | 0a687379f4634747a2d682587feee7eba8aa13212c3eb1322aaf196f03d80d84 |