Skip to main content

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 and Java. stellar-cli provides support for TypeScript and Rust.

Web Interface

We have a web interface for generating bindings. You can access via https://stellar-contract-bindings.fly.dev/.

Installation

You can install stellar-contract-bindings using pip:

pip install stellar-contract-bindings

Usage

Please check the help message for the most up-to-date usage information:

stellar-contract-bindings --help

Example

stellar-contract-bindings python --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./bindings

This command will generate Python binding for the specified contract and save it in the ./bindings directory.

Using the Generated Binding

After generating the binding, you can use it to interact with your Soroban contract. Here's an example:

Python

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()

Java

public class Example extends ContractClient {
    public static void main(String[] args) {
        KeyPair kp = KeyPair.fromAccountId("GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF");
        Client client = new Client("CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF", "https://mainnet.sorobanrpc.com", Network.PUBLIC);
        AssembledTransaction<List<byte[]>> tx = client.hello("World".getBytes(), kp.getAccountId(), kp, 100);
    }
}

License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

Contributing

Contributions are welcome! The project is designed to be easy to add support for other languages, please open an issue or submit a pull request for any improvements or bug fixes.

Project details


Download files

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

Source Distribution

stellar_contract_bindings-0.4.1b0.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

stellar_contract_bindings-0.4.1b0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file stellar_contract_bindings-0.4.1b0.tar.gz.

File metadata

File hashes

Hashes for stellar_contract_bindings-0.4.1b0.tar.gz
Algorithm Hash digest
SHA256 53bea68ba163537a20187aced8ea148edc673146813a0fa77780ff94fb01f153
MD5 3a8477f524ae924e6b0ec76409c295cb
BLAKE2b-256 c7a6b2f054175b91b7d27b9776a850fad9ac532ef2fa82c06712900149bd5804

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellar_contract_bindings-0.4.1b0.tar.gz:

Publisher: continuous-integration-workflow.yml on lightsail-network/stellar-contract-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stellar_contract_bindings-0.4.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for stellar_contract_bindings-0.4.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 d03af3133cf1b4cfa6bb8b10f928987a84cbab724be4d30c1db64310612cc2d9
MD5 08587b09412f528cc3559b32b945907e
BLAKE2b-256 11c98128d86986ce5940c750630b6ee9743f9767d2a2d066b6d47a94623f3320

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellar_contract_bindings-0.4.1b0-py3-none-any.whl:

Publisher: continuous-integration-workflow.yml on lightsail-network/stellar-contract-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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