Docs

Java sample

Prove that arbitrary transaction intent cannot reach a JVM signer through the Torq client.

Developer Preview. Use the JVM client supplied with your approved application. Only a verified, typed Torq workflow may reach your signer boundary.

This executable negative sample confirms that raw caller-created transaction intent fails closed before simulation or signing.

Complete source

import finance.torq.TorqClient;

import java.net.URI;
import java.time.Duration;

public final class Main {
    public static void main(String[] args) throws Exception {
        TorqClient client = new TorqClient(
            new TorqClient.Config(
                URI.create("https://api.example.test"),
                null,
                "torq_test_sk_external_quickstart",
                "torq_ws_external_quickstart",
                null,
                Duration.ofSeconds(5)
            )
        );
        final int[] signerCalls = {0};
        try {
            client.executePreparedTransaction(
                "{\"chainId\":11155111}",
            new TorqClient.Signer() {
                @Override
                public long chainId() {
                    return 11155111L;
                }

                @Override
                public void simulate(String transactionIntentJson) {
                    signerCalls[0] += 1;
                }

                @Override
                public String sendTransaction(String transactionIntentJson) {
                    signerCalls[0] += 1;
                    return "0x" + "1".repeat(64);
                }
            }
            );
            throw new AssertionError("Raw transaction intents must fail closed.");
        } catch (UnsupportedOperationException expected) {
            if (signerCalls[0] != 0) {
                throw new AssertionError("Raw transaction intent reached the signer.");
            }
        }
        System.out.println("Java Torq SDK quickstart passed.");
    }
}

Use typed workflows to prepare the business action before handing the exact reviewed payload to your service signer.

On this page