React wallet sample
Keep simulation and transaction submission inside an EIP-1193 customer wallet boundary.
Developer Preview. Use the React client supplied with your approved application and an allowed browser origin. Torq never receives the customer's private key.
This executable sample proves chain detection, mandatory simulation, and customer-wallet submission through the React EIP-1193 adapter.
Complete source
import assert from "node:assert/strict";
import { eip1193Signer } from "@torq-finance/react";
const account = "0x00000000000000000000000000000000000000aa";
const methods: string[] = [];
const signer = eip1193Signer(
{
async request({ method }) {
methods.push(method);
if (method === "eth_chainId") return "0xaa36a7";
if (method === "eth_sendTransaction") return `0x${"1".repeat(64)}`;
return "0x";
}
},
account
);
assert.equal(await signer.getChainId(), 11155111);
assert.ok(signer.simulate);
await signer.simulate!({
order: 0,
chainId: 11155111,
target: "0x00000000000000000000000000000000000000bb",
calldata: "0x",
value: "0",
label: "External wallet proof",
simulationRequired: true
});
const hash = await signer.sendTransaction({
order: 0,
chainId: 11155111,
target: "0x00000000000000000000000000000000000000bb",
calldata: "0x",
value: "0",
label: "External wallet proof",
simulationRequired: true
});
assert.equal(hash, `0x${"1".repeat(64)}`);
assert.deepEqual(methods, ["eth_chainId", "eth_call", "eth_sendTransaction"]);
console.log("React/wagmi Torq SDK quickstart passed.");In a real integration, pass only a Torq-prepared, user-reviewed transaction to this adapter. Use the wallet provider playbook for the complete product flow.