CLI tool designed to generate language bindings for Stellar Soroban smart contracts.
Project description
stellar-contract-bindings
stellar-contract-bindings is a CLI tool designed to generate language bindings for Stellar Soroban smart contracts.
This tool simplifies the process of interacting with Soroban contracts by generating the necessary code to call contract methods directly from your preferred programming language. Currently, it supports Python. stellar-cli provides support for TypeScript and Rust.
Installation
You can install stellar-contract-bindings using pip:
pip install stellar-contract-bindings
Usage
To generate bindings for a Soroban contract, use the generate command with the required options:
stellar-contract-bindings generate --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF
Options
--contract-id: The contract ID to generate bindings for (required).--rpc-url: The Soroban RPC URL (default: https://mainnet.sorobanrpc.com).--language: The target language for bindings (default: python).--output: Output directory for generated bindings (defaults to the current directory).
Example
stellar-contract-bindings generate --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --language python --output ./bindings
This command will generate Python binding for the specified contract and save it in the ./bindings directory.
Using the Generated Binding
Python
After generating the binding, you can use it to interact with your Soroban contract. Here's an example:
from stellar_sdk import Network
from bindings import Client # Import the generated bindings
contract_id = "CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF"
rpc_url = "https://mainnet.sorobanrpc.com"
network_passphrase = Network.PUBLIC_NETWORK_PASSPHRASE
client = Client(contract_id, rpc_url, network_passphrase)
assembled_tx = client.hello(b"world")
print(assembled_tx.result())
# assembled_tx.sign_and_submit()
License
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
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 stellar_contract_bindings-0.1.0b0.tar.gz.
File metadata
- Download URL: stellar_contract_bindings-0.1.0b0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e17c1e19c795ee97dae16c384bce0520df54354b54fc5caeef7db0a9b3fadd0
|
|
| MD5 |
28a0a6010fdf28641ce54cd96617fd23
|
|
| BLAKE2b-256 |
3d26f46b1dc0dcbc9313b33c85246f7d7c9e95733a18da4be22a6a8f0dd14993
|
File details
Details for the file stellar_contract_bindings-0.1.0b0-py3-none-any.whl.
File metadata
- Download URL: stellar_contract_bindings-0.1.0b0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bace78b3c016fd6d88ce5110cd9d0a43b121e45555ad3b15258d661bf65c30ae
|
|
| MD5 |
da00d83762d257bb7f81e6a6814e6ada
|
|
| BLAKE2b-256 |
bbe80cc21b911ba20855941bfa87194491fd72575f84ddb14ea7dd16b83a6451
|