Python NEAR contract build/deploy tool
Project description
Minimal build/deploy tool for Python NEAR smart contracts
This is a work-in-progress build/deploy tool for Python NEAR smart contracts.
Python source files are compiled into the WASM binary via MicroPython and Emscripten and then deployed via near-cli-rs tool.
near-py-tool CLI is modelled after cargo-near with most of the
command-line options compatible (not all are implemented yet).
Dependencies
near-py-tool expects the following dependencies installed:
- Python>=3.9
- essential build tools like
makeand C compiler - Emscripten for compiling Python into WASM via MicroPython
- near-cli-rs for NEAR Protocol interactions
Platform support
Currenly Linux (including WSL) and MacOS are supported with more platforms planned for the future.
Python library support
Most of the MicroPython standard library is included and should be functional where applicable to WASM runtime environment.
External Python package are supported as long as they don't require native compiled code to work. near-py-tool will download any packages referenced
via pyproject.toml and will try to compile them into the WASM binary alongside the main contract.py file.
NEAR ABI support
Currenly a minimal version of NEAR WASM ABI is implemented via near module:
near.input(index)retrieves the specified contract input asbytesnear.value_return(value)returns a value (strorbytes) from the contractnear.log_utf8(message)logs a message (str)
Contract methods to be exported from the WASM binary should be decorated with @near.export.
See the near-py-tool new-generated project for more details.
Getting started
- install
near-py-toolviapip install near-py-tool - run
near-py-tool new test-projectto create a minimal Python smart contract project cd ./test-project- run
near-py-tool buildto produce a standalone WASM file - run
near-py-tool create-dev-accountto create a testnet account if you don't have one already - run
near-py-tool deployto deploy the smart contract
TODO
- Proper Python exception support (currently any thrown exception will log the exception message and terminate the contract execution)
- Tests and CI
- NEAR ABI metadata generation
- More platform support & automatic dependency installation
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file near_py_tool-0.1.13.tar.gz.
File metadata
- Download URL: near_py_tool-0.1.13.tar.gz
- Upload date:
- Size: 8.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e523519a89b69c92cc83b47aa51d52bd5ef731fdecb6f595baa866eac251e1a3
|
|
| MD5 |
404f96d0ebccde887396aff0e4b6eb9f
|
|
| BLAKE2b-256 |
98f2e5cd3d6bc118717875e620f605963eae46de0d3030709ba387e5e37fdc9e
|
File details
Details for the file near_py_tool-0.1.13-py3-none-any.whl.
File metadata
- Download URL: near_py_tool-0.1.13-py3-none-any.whl
- Upload date:
- Size: 11.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
796a58241bf65f92ad192f6819278b5de5a1214586cce202dde30953c0cd608e
|
|
| MD5 |
09b98e67f8eb0d4988c64931b632aa50
|
|
| BLAKE2b-256 |
7e0dd4b9d42adcc36ac5278f4e4a88424522467a7203e152880df508618669e9
|