Name | stellar-contract-bindings JSON |
Version |
0.5.0b0
JSON |
| download |
home_page | None |
Summary | CLI tool designed to generate language bindings for Stellar Soroban smart contracts. |
upload_time | 2025-08-23 03:51:12 |
maintainer | None |
docs_url | None |
author | overcat |
requires_python | >=3.9 |
license | Apache-2.0 |
keywords |
stellar
soroban
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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, Java, Flutter/Dart, PHP, and Swift/iOS. [stellar-cli](https://github.com/stellar/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/](https://stellar-contract-bindings.fly.dev/).
## Installation
You can install `stellar-contract-bindings` using pip:
```shell
pip install stellar-contract-bindings
```
## Usage
Please check the help message for the most up-to-date usage information:
```shell
stellar-contract-bindings --help
```
### Examples
#### Python
```shell
stellar-contract-bindings python --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./bindings
```
#### Java
```shell
stellar-contract-bindings java --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./bindings --package com.example
```
#### Flutter/Dart
```shell
stellar-contract-bindings flutter --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./lib --class-name MyContract
```
#### PHP
```shell
stellar-contract-bindings php --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./generated --namespace MyApp\\Contracts --class-name MyContractClient
```
#### Swift/iOS
```shell
stellar-contract-bindings swift --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./Sources --class-name MyContract
```
These commands will generate language-specific bindings for the specified contract and save them in the respective directories.
### Using the Generated Binding
After generating the binding, you can use it to interact with your Soroban contract. Here's an example:
#### Python
```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
```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);
}
}
```
#### Flutter/Dart
```dart
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';
import 'lib/my_contract_client.dart'; // Import the generated bindings
void main() async {
final sourceKeyPair = KeyPair.fromAccountId("GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF");
// or: final sourceKeyPair = KeyPair.fromSecretSeed("S...");
// Create client instance
final client = await MyContractClient.forContractId(
sourceAccountKeyPair: sourceKeyPair,
contractId: "CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF",
network: Network.PUBLIC,
rpcUrl: "https://mainnet.sorobanrpc.com",
);
// Call contract method directly
try {
final result = await client.hello(input: "World");
print("Contract response: $result");
} catch (e) {
print("Error calling contract: $e");
}
// Or build an assembled transaction for more control
final assembledTx = await client.buildHelloTx(
input: "World",
methodOptions: MethodOptions(),
);
}
```
#### PHP
```php
<?php
use Soneso\StellarSDK\Crypto\KeyPair;
use Soneso\StellarSDK\Network;
use Soneso\StellarSDK\Soroban\Contract\ClientOptions;
use Soneso\StellarSDK\Soroban\Contract\MethodOptions;
use MyApp\Contracts\MyContractClient; // Import the generated bindings
// Initialize
$sourceKeyPair = KeyPair::fromAccountId("GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF");
// or: $sourceKeyPair = KeyPair::fromSeed("S...")
// Create client instance
$options = new ClientOptions(
sourceAccountKeyPair: $sourceKeyPair,
contractId: "CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF",
network: Network::public(),
rpcUrl: "https://mainnet.sorobanrpc.com"
);
$client = MyContractClient::forClientOptions($options);
// Call contract method directly
try {
$result = $client->hello("World");
echo "Contract response: " . $result . "\n";
} catch (Exception $e) {
echo "Error calling contract: " . $e->getMessage() . "\n";
}
// Or build an assembled transaction for more control
$methodOptions = new MethodOptions();
$assembledTx = $client->buildHelloTx("World", $methodOptions);
```
#### Swift/iOS
```swift
import stellarsdk
import Foundation
// Import the generated bindings
// Assuming the generated file is named MyContract.swift
// Initialize
let sourceKeyPair = try! KeyPair.init(accountId: "GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF")
// or: let sourceKeyPair = try! KeyPair.init(secretSeed: "S...")
// Create client instance
let options = ClientOptions(
sourceAccountKeyPair: sourceKeyPair,
contractId: "CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF",
network: .public,
rpcUrl: "https://mainnet.sorobanrpc.com"
)
Task {
do {
let client = try await MyContract.forClientOptions(options: options)
// Call contract method directly
let result = try await client.hello(
to: "World",
methodOptions: nil,
force: false
)
print("Contract response: \(result)")
// Or build an assembled transaction for more control
let methodOptions = MethodOptions()
let assembledTx = try await client.buildHelloTx(
to: "World",
methodOptions: methodOptions
)
} catch {
print("Error calling contract: \(error)")
}
}
```
## License
This project is licensed under the Apache-2.0 License. See the [LICENSE](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.
Raw data
{
"_id": null,
"home_page": null,
"name": "stellar-contract-bindings",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "stellar, soroban",
"author": "overcat",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/bb/05/4cd5829a0547ab3ce7fb4849049d7f5458432aa1a4750479446c61e1ed85/stellar_contract_bindings-0.5.0b0.tar.gz",
"platform": null,
"description": "# stellar-contract-bindings\n\n`stellar-contract-bindings` is a CLI tool designed to generate language bindings for Stellar Soroban smart contracts.\n\nThis tool simplifies the process of interacting with Soroban contracts by generating the necessary code to call contract\nmethods directly from your preferred programming language. Currently, it supports\nPython, Java, Flutter/Dart, PHP, and Swift/iOS. [stellar-cli](https://github.com/stellar/stellar-cli) provides support for TypeScript and Rust.\n\n## Web Interface\nWe have a web interface for generating bindings. You can access via [https://stellar-contract-bindings.fly.dev/](https://stellar-contract-bindings.fly.dev/).\n\n## Installation\n\nYou can install `stellar-contract-bindings` using pip:\n\n```shell\npip install stellar-contract-bindings\n```\n\n## Usage\n\nPlease check the help message for the most up-to-date usage information:\n\n```shell\nstellar-contract-bindings --help\n```\n\n### Examples\n\n#### Python\n```shell\nstellar-contract-bindings python --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./bindings\n```\n\n#### Java\n```shell\nstellar-contract-bindings java --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./bindings --package com.example\n```\n\n#### Flutter/Dart\n```shell\nstellar-contract-bindings flutter --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./lib --class-name MyContract\n```\n\n#### PHP\n```shell\nstellar-contract-bindings php --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./generated --namespace MyApp\\\\Contracts --class-name MyContractClient\n```\n\n#### Swift/iOS\n```shell\nstellar-contract-bindings swift --contract-id CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF --rpc-url https://mainnet.sorobanrpc.com --output ./Sources --class-name MyContract\n```\n\nThese commands will generate language-specific bindings for the specified contract and save them in the respective directories.\n\n### Using the Generated Binding\n\nAfter generating the binding, you can use it to interact with your Soroban contract. Here's an example:\n\n#### Python\n\n```python\nfrom stellar_sdk import Network\nfrom bindings import Client # Import the generated bindings\n\ncontract_id = \"CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF\"\nrpc_url = \"https://mainnet.sorobanrpc.com\"\nnetwork_passphrase = Network.PUBLIC_NETWORK_PASSPHRASE\n\nclient = Client(contract_id, rpc_url, network_passphrase)\nassembled_tx = client.hello(b\"world\")\nprint(assembled_tx.result())\n# assembled_tx.sign_and_submit()\n```\n\n#### Java\n```java\npublic class Example extends ContractClient {\n public static void main(String[] args) {\n KeyPair kp = KeyPair.fromAccountId(\"GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF\");\n Client client = new Client(\"CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF\", \"https://mainnet.sorobanrpc.com\", Network.PUBLIC);\n AssembledTransaction<List<byte[]>> tx = client.hello(\"World\".getBytes(), kp.getAccountId(), kp, 100);\n }\n}\n```\n\n#### Flutter/Dart\n```dart\nimport 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';\nimport 'lib/my_contract_client.dart'; // Import the generated bindings\n\nvoid main() async {\n final sourceKeyPair = KeyPair.fromAccountId(\"GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF\");\n // or: final sourceKeyPair = KeyPair.fromSecretSeed(\"S...\");\n \n // Create client instance\n final client = await MyContractClient.forContractId(\n sourceAccountKeyPair: sourceKeyPair,\n contractId: \"CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF\",\n network: Network.PUBLIC,\n rpcUrl: \"https://mainnet.sorobanrpc.com\",\n );\n \n // Call contract method directly\n try {\n final result = await client.hello(input: \"World\");\n print(\"Contract response: $result\");\n } catch (e) {\n print(\"Error calling contract: $e\");\n }\n \n // Or build an assembled transaction for more control\n final assembledTx = await client.buildHelloTx(\n input: \"World\",\n methodOptions: MethodOptions(),\n );\n}\n```\n\n#### PHP\n```php\n<?php\n\nuse Soneso\\StellarSDK\\Crypto\\KeyPair;\nuse Soneso\\StellarSDK\\Network;\nuse Soneso\\StellarSDK\\Soroban\\Contract\\ClientOptions;\nuse Soneso\\StellarSDK\\Soroban\\Contract\\MethodOptions;\nuse MyApp\\Contracts\\MyContractClient; // Import the generated bindings\n\n// Initialize\n$sourceKeyPair = KeyPair::fromAccountId(\"GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF\");\n// or: $sourceKeyPair = KeyPair::fromSeed(\"S...\")\n\n// Create client instance\n$options = new ClientOptions(\n sourceAccountKeyPair: $sourceKeyPair,\n contractId: \"CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF\",\n network: Network::public(),\n rpcUrl: \"https://mainnet.sorobanrpc.com\"\n);\n\n$client = MyContractClient::forClientOptions($options);\n\n// Call contract method directly\ntry {\n $result = $client->hello(\"World\");\n echo \"Contract response: \" . $result . \"\\n\";\n} catch (Exception $e) {\n echo \"Error calling contract: \" . $e->getMessage() . \"\\n\";\n}\n\n// Or build an assembled transaction for more control\n$methodOptions = new MethodOptions();\n$assembledTx = $client->buildHelloTx(\"World\", $methodOptions);\n```\n\n#### Swift/iOS\n```swift\nimport stellarsdk\nimport Foundation\n\n// Import the generated bindings\n// Assuming the generated file is named MyContract.swift\n\n// Initialize\nlet sourceKeyPair = try! KeyPair.init(accountId: \"GD5KKP3LHUDXLDCGKP55NLEOEHMS3Z4BS6IDDZFCYU3BDXUZTBWL7JNF\")\n// or: let sourceKeyPair = try! KeyPair.init(secretSeed: \"S...\")\n\n// Create client instance\nlet options = ClientOptions(\n sourceAccountKeyPair: sourceKeyPair,\n contractId: \"CDOAW6D7NXAPOCO7TFAWZNJHK62E3IYRGNRVX3VOXNKNVOXCLLPJXQCF\",\n network: .public,\n rpcUrl: \"https://mainnet.sorobanrpc.com\"\n)\n\nTask {\n do {\n let client = try await MyContract.forClientOptions(options: options)\n \n // Call contract method directly\n let result = try await client.hello(\n to: \"World\",\n methodOptions: nil,\n force: false\n )\n print(\"Contract response: \\(result)\")\n \n // Or build an assembled transaction for more control\n let methodOptions = MethodOptions()\n let assembledTx = try await client.buildHelloTx(\n to: \"World\",\n methodOptions: methodOptions\n )\n \n } catch {\n print(\"Error calling contract: \\(error)\")\n }\n}\n```\n\n## License\n\nThis project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! The project is designed to be easy to add support for other languages, please open an issue\nor submit a pull request for any improvements or bug fixes.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "CLI tool designed to generate language bindings for Stellar Soroban smart contracts.",
"version": "0.5.0b0",
"project_urls": {
"CI": "https://github.com/lightsail-network/stellar-contract-bindings/actions",
"Changelog": "https://github.com/lightsail-network/stellar-contract-bindings/releases",
"Homepage": "https://github.com/lightsail-network/stellar-contract-bindings",
"Issues": "https://github.com/lightsail-network/stellar-contract-bindings/issues"
},
"split_keywords": [
"stellar",
" soroban"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9e02f71fd3e21fe5da6498ae89ad9bbf8e080c7d832888be82b0b56297dda5ba",
"md5": "17db4695311e236e65aa5afd5cd75cd3",
"sha256": "08a06ba2024abe5465bed368f20e3aae0d4ceaa5f9e916a75c2d8296bb0b5c62"
},
"downloads": -1,
"filename": "stellar_contract_bindings-0.5.0b0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "17db4695311e236e65aa5afd5cd75cd3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 46426,
"upload_time": "2025-08-23T03:51:11",
"upload_time_iso_8601": "2025-08-23T03:51:11.272330Z",
"url": "https://files.pythonhosted.org/packages/9e/02/f71fd3e21fe5da6498ae89ad9bbf8e080c7d832888be82b0b56297dda5ba/stellar_contract_bindings-0.5.0b0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bb054cd5829a0547ab3ce7fb4849049d7f5458432aa1a4750479446c61e1ed85",
"md5": "cd794048c1e86068433e29a622b07cad",
"sha256": "53447cbdfc781a39e9637d06434ac1dabc38f0ccfe822996fc9839716cdced08"
},
"downloads": -1,
"filename": "stellar_contract_bindings-0.5.0b0.tar.gz",
"has_sig": false,
"md5_digest": "cd794048c1e86068433e29a622b07cad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 53455,
"upload_time": "2025-08-23T03:51:12",
"upload_time_iso_8601": "2025-08-23T03:51:12.722245Z",
"url": "https://files.pythonhosted.org/packages/bb/05/4cd5829a0547ab3ce7fb4849049d7f5458432aa1a4750479446c61e1ed85/stellar_contract_bindings-0.5.0b0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-23 03:51:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lightsail-network",
"github_project": "stellar-contract-bindings",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "stellar-contract-bindings"
}