From 7362ccc3ec17230e1adb2b571a085803a52a5bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Thu, 13 Nov 2025 16:36:10 +0100 Subject: [PATCH 1/4] feat(bindings): add examples using the releases --- .gitignore | 1 + bindings/kotlin/examples/full/README.md | 5 +++++ .../kotlin/examples/full/build.gradle.kts | 19 +++++++++++++++++++ .../kotlin/examples/full/settings.gradle.kts | 1 + .../examples/full/src/main/kotlin/Main.kt | 13 +++++++++++++ bindings/python/examples/full/README.md | 14 ++++++++++++++ bindings/python/examples/full/example.py | 17 +++++++++++++++++ .../python/examples/full/requirements.txt | 2 ++ 8 files changed, 72 insertions(+) create mode 100644 bindings/kotlin/examples/full/README.md create mode 100644 bindings/kotlin/examples/full/build.gradle.kts create mode 100644 bindings/kotlin/examples/full/settings.gradle.kts create mode 100644 bindings/kotlin/examples/full/src/main/kotlin/Main.kt create mode 100644 bindings/python/examples/full/README.md create mode 100644 bindings/python/examples/full/example.py create mode 100644 bindings/python/examples/full/requirements.txt diff --git a/.gitignore b/.gitignore index 0015a5476..6b392e126 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ Cargo.lock __pycache__ build .vscode +.kotlin diff --git a/bindings/kotlin/examples/full/README.md b/bindings/kotlin/examples/full/README.md new file mode 100644 index 000000000..acdebd9cc --- /dev/null +++ b/bindings/kotlin/examples/full/README.md @@ -0,0 +1,5 @@ +Full project example using the released package. + +```bash +gradle run +``` diff --git a/bindings/kotlin/examples/full/build.gradle.kts b/bindings/kotlin/examples/full/build.gradle.kts new file mode 100644 index 000000000..7fcfe7b88 --- /dev/null +++ b/bindings/kotlin/examples/full/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + kotlin("jvm") version "2.2.20" + application +} + +group = "com.example" + +version = "1.0-SNAPSHOT" + +repositories { mavenCentral() } + +dependencies { + implementation("org.iota:iota-sdk:0.0.1-alpha.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") +} + +kotlin { jvmToolchain(21) } + +application { mainClass.set("MainKt") } diff --git a/bindings/kotlin/examples/full/settings.gradle.kts b/bindings/kotlin/examples/full/settings.gradle.kts new file mode 100644 index 000000000..7af2cc835 --- /dev/null +++ b/bindings/kotlin/examples/full/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "kotlintest" diff --git a/bindings/kotlin/examples/full/src/main/kotlin/Main.kt b/bindings/kotlin/examples/full/src/main/kotlin/Main.kt new file mode 100644 index 000000000..b6abbc726 --- /dev/null +++ b/bindings/kotlin/examples/full/src/main/kotlin/Main.kt @@ -0,0 +1,13 @@ +import iota_sdk.GraphQlClient +import kotlinx.coroutines.runBlocking + +fun main() = runBlocking { + try { + val client = GraphQlClient.newDevnet() + val chainId = client.chainId() + println("Chain ID: $chainId") + } catch (e: Exception) { + e.printStackTrace() + kotlin.system.exitProcess(1) + } +} diff --git a/bindings/python/examples/full/README.md b/bindings/python/examples/full/README.md new file mode 100644 index 000000000..4bb37fcf5 --- /dev/null +++ b/bindings/python/examples/full/README.md @@ -0,0 +1,14 @@ +Full project example using the released package. + +To set up the environment: + +```bash +uv venv +uv pip install -r requirements.txt +``` + +Then run: + +```bash +uv run python example.py +``` diff --git a/bindings/python/examples/full/example.py b/bindings/python/examples/full/example.py new file mode 100644 index 000000000..51c95dcd0 --- /dev/null +++ b/bindings/python/examples/full/example.py @@ -0,0 +1,17 @@ +# Copyright (c) 2025 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 + +from iota_sdk import * + +import asyncio + + +async def main(): + client = GraphQlClient.new_devnet() + + chain_id = await client.chain_id() + print("Chain ID:", chain_id) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/bindings/python/examples/full/requirements.txt b/bindings/python/examples/full/requirements.txt new file mode 100644 index 000000000..fdd6af948 --- /dev/null +++ b/bindings/python/examples/full/requirements.txt @@ -0,0 +1,2 @@ +--index-url https://test.pypi.org/simple/ +iota-sdk==3.0.0a1.dev7 From d49c1e47f8d40af02dd267afaaf4e6d4daf8cf8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Thu, 13 Nov 2025 16:48:30 +0100 Subject: [PATCH 2/4] add Rust example --- .gitignore | 2 +- crates/iota-sdk/examples/full/Cargo.toml | 10 ++++++++++ crates/iota-sdk/examples/full/src/main.rs | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 crates/iota-sdk/examples/full/Cargo.toml create mode 100644 crates/iota-sdk/examples/full/src/main.rs diff --git a/.gitignore b/.gitignore index 6b392e126..0c249bd8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/target +target/ Cargo.lock .idea *.dylib diff --git a/crates/iota-sdk/examples/full/Cargo.toml b/crates/iota-sdk/examples/full/Cargo.toml new file mode 100644 index 000000000..94af9ff10 --- /dev/null +++ b/crates/iota-sdk/examples/full/Cargo.toml @@ -0,0 +1,10 @@ +[workspace] +[package] +name = "full" +version = "0.1.0" +edition = "2024" + +[dependencies] +eyre = "0.6" +iota-sdk = "=3.0.0-alpha.1" +tokio = "1.40.0" diff --git a/crates/iota-sdk/examples/full/src/main.rs b/crates/iota-sdk/examples/full/src/main.rs new file mode 100644 index 000000000..12d97d22f --- /dev/null +++ b/crates/iota-sdk/examples/full/src/main.rs @@ -0,0 +1,11 @@ +use iota_sdk::graphql_client::{Client, error::Result}; + +#[tokio::main] +async fn main() -> Result<()> { + let client = Client::new_devnet(); + + let chain_id = client.chain_id().await?; + println!("Chain ID: {chain_id}"); + + Ok(()) +} From 50cc06e8c7b360f7c2ded96a8a3e831ba01045d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Thu, 13 Nov 2025 16:49:34 +0100 Subject: [PATCH 3/4] remove unused dependency --- crates/iota-sdk/examples/full/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/iota-sdk/examples/full/Cargo.toml b/crates/iota-sdk/examples/full/Cargo.toml index 94af9ff10..555b1eeef 100644 --- a/crates/iota-sdk/examples/full/Cargo.toml +++ b/crates/iota-sdk/examples/full/Cargo.toml @@ -5,6 +5,5 @@ version = "0.1.0" edition = "2024" [dependencies] -eyre = "0.6" iota-sdk = "=3.0.0-alpha.1" tokio = "1.40.0" From d420c7568b1a3618b4089d9d20e672d584cc4b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Mon, 17 Nov 2025 15:25:31 +0100 Subject: [PATCH 4/4] add go example --- bindings/go/examples/full/README.md | 7 +++++++ bindings/go/examples/full/main.go | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 bindings/go/examples/full/README.md create mode 100644 bindings/go/examples/full/main.go diff --git a/bindings/go/examples/full/README.md b/bindings/go/examples/full/README.md new file mode 100644 index 000000000..aec7406e9 --- /dev/null +++ b/bindings/go/examples/full/README.md @@ -0,0 +1,7 @@ +```bash +go get github.com/iotaledger/iota-sdk-go +``` + +```bash +go run main.go +``` diff --git a/bindings/go/examples/full/main.go b/bindings/go/examples/full/main.go new file mode 100644 index 000000000..4f2bb93c8 --- /dev/null +++ b/bindings/go/examples/full/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "log" + + "github.com/iotaledger/iota-sdk-go" +) + +func main() { + client := iota_sdk.GraphQlClientNewDevnet() + + chainID, err := client.ChainId() + if err.(*iota_sdk.SdkFfiError) != nil { + log.Fatalf("Failed to get chain ID: %v", err) + } + fmt.Println("Chain ID:", chainID) +} \ No newline at end of file