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.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

nekoton-0.1.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

nekoton-0.1.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

nekoton-0.1.16-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.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nekoton-0.1.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db625214cf3c8acde5be0b5b4a621e8dc879604c1eed57e39242c52b94ecb162
MD5 2f29598b1432fbc4b47313f149bf3da1
BLAKE2b-256 ab2a5db60fb72553b72b53102aa3595a0316ad20dcf83bdd11ae3cdcb6c50793

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nekoton-0.1.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7519fa7ffa61904fdd9bda7c299b5537d92771da7f81190ddc9b0e11dad0606
MD5 bdf61cdbed7ff2b6d3bedad5746f4523
BLAKE2b-256 fb36e4354e573fa211d9409f13923488405a1541ccd9d049ae1d22bce21331eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nekoton-0.1.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f2b804ae8f320ca884b1dd82ebc57e018901e3f0a2fd8e407cc36dc69099cd6
MD5 afaf4f6301b7889367c40a55215bffcb
BLAKE2b-256 5d261679b41c763ddfc49950ed9727ada7fa36caa9193a829666877255c5ecd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nekoton-0.1.16-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03027fae07ec5e01e62a2abd44ee4ebc6e49eb239d0d9675df160eb01464f921
MD5 6a921e70c11103ea1647de437dbf74b7
BLAKE2b-256 5b2c160c1326c284daca8f094bf008b026acfaa2ab75f0c2b71ab9b930de7fc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nekoton-0.1.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c6fd15af422aba27edafec8b2bb7e1465c88551d6bd5c530b3ea97698cba583
MD5 8af49b24aef0d1b1bfbfe74f74f24d8d
BLAKE2b-256 8e6ab3676353329651b02fd51bed47534572c5a475aa513fc855540f47cf02c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nekoton-0.1.16-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c48373dbde6c7a90889fae4bf9b250d38e750af3f3395d049ac0d0a50dc8d92
MD5 3c782b2a2e513d3e4497c74f4ae863ce
BLAKE2b-256 e61777d1120a39eec7592f89db94fe51d8092538c16405d99a917a5565c606e6

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