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.

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.3.0b0.tar.gz (25.4 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.3.0b0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for stellar_contract_bindings-0.3.0b0.tar.gz
Algorithm Hash digest
SHA256 a47a0f26cd081748a950a628319297b47dd9246730e89a8236ac70bf5c881b8c
MD5 4a4dc6ef034bc067a81c9deb6a6aff23
BLAKE2b-256 9f0ba761f2e38166c01ba6de93cc36d55ea81e263ef643c077b0b1ad736bf664

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellar_contract_bindings-0.3.0b0.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.3.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for stellar_contract_bindings-0.3.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 677578309a35de1a4c6a8b8c83ec52fc1f9e2e5cad8672506f192c42d3386dc2
MD5 a0140cd31afbb6686d940a6fe1c54277
BLAKE2b-256 7fd89727a038e15710ea9d8847719fe0faa8c1ddbcc09ba276f1976a337f0629

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellar_contract_bindings-0.3.0b0-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