Skip to main content

No project description provided

Project description

Logo

nekoton-python   Latest Version

Python bindings for Nekoton

Usage

Install

pip install nekoton

Example

import asyncio
import nekoton as nt

giver_abi = nt.ContractAbi("""{
    "ABI version": 1,
    "functions": [{
        "name": "sendGrams",
        "inputs": [
            {"name": "dest", "type": "address"},
            {"name": "amount", "type": "uint64"}
        ],
        "outputs": []
    }],
    "events": []
}""")

send_grams = giver_abi.get_function("sendGrams")
assert send_grams is not None


class Giver:
    def __init__(self, transport: nt.Transport, address: nt.Address):
        self._transport = transport
        self._address = address

    @property
    def address(self) -> nt.Address:
        return self._address

    async def give(self, target: nt.Address, amount: nt.Tokens):
        # Prepare external message
        message = send_grams.encode_external_message(
            self._address,
            input={
                "dest": target,
                "amount": amount,
            },
            public_key=None
        ).without_signature()

        # Send external message
        tx = await self._transport.send_external_message(message)
        if tx is None:
            raise RuntimeError("Message expired")

        # Wait until all transactions are produced
        await self._transport.trace_transaction(tx).wait()


async def main():
    transport = nt.JrpcTransport('https://jrpc-broxustestnet.everwallet.net')
    await transport.check_connection()

    giver = Giver(transport, Address('-1:1111111111111111111111111111111111111111111111111111111111111111'))

    await giver.give(giver.address, nt.Tokens(10))


asyncio.run(main())

Local development

  • Install maturin.
  • Configure virtual env:
    python -m venv .env
    source .env/bin/activate
    
  • Dev build:
    maturin develop
    
  • Publish
    maturin build --release --zig --strip
    maturin upload path/to/generated/file.whl
    

Contributing

We welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.

License

This project is licensed under the [License Apache].

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nekoton-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

nekoton-0.1.14-cp311-cp311-macosx_11_0_arm64.whl (9.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

nekoton-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

nekoton-0.1.14-cp310-cp310-macosx_11_0_arm64.whl (9.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

nekoton-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

nekoton-0.1.14-cp39-cp39-macosx_11_0_arm64.whl (9.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file nekoton-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 943d0c11c2538df29e9bd0ab3bafa0fe78d546c83a1649f99cf414b2398c2dd5
MD5 e0c739331089f2fe28a709b9f3a42ea0
BLAKE2b-256 e329fe0833e1f2fc65cc609fcd795b33133dd99842c2fb7a194c6612ce91e0d5

See more details on using hashes here.

File details

Details for the file nekoton-0.1.14-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6564e58510a69bb725cf26197669f263ccbb3683e769d6b6304b87175691a784
MD5 aa77ee2939cea7f499d70a28a51b21f8
BLAKE2b-256 636ae5da4b50feb477489948f467f7b66f921b525db75073c14118654650769d

See more details on using hashes here.

File details

Details for the file nekoton-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 78312a0602ff1af4eae4f5f3c6755238dd65f9770104ab7390dadc2bf8a61829
MD5 2168a2f5a7ba8ce30ce11b3d8d73be2c
BLAKE2b-256 8ba8fdd6d9d2810ea2007579d6756039c1026389b178958f33c53d6edf16c7dd

See more details on using hashes here.

File details

Details for the file nekoton-0.1.14-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.14-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 535bc1d6163fdcb863be628371f5dfc2d28ac2c97ddc68ea2ce70a7dc8947847
MD5 f5f03b942eedb2ed827adf98bf2cb014
BLAKE2b-256 927ba78af5ed5ec69d998520fd1d0055b7ff996a6dfca9ec0da641288bddabfb

See more details on using hashes here.

File details

Details for the file nekoton-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be521301010870c4cb69bcaa9a7cbcd03a3718d79569d92af8d09e68238be35a
MD5 a4a542e9b60b2e6849e0bf12480e6537
BLAKE2b-256 eb4577ce04fde282cfbee91dc4d5d6702ca05d33ed7e577b79370be06b954214

See more details on using hashes here.

File details

Details for the file nekoton-0.1.14-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.14-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55a644481f247faee7186a8216518e7c2f18008c4aaca153c31ed65b1bd37960
MD5 b10e649fa1480e2b049b07beb33d5462
BLAKE2b-256 1a1dea571c14ef82e6f919811e417b3eeb8323b7349639b5a740d007abcb1ed7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page