import {
defineSignedOperation,
randomNonce,
} from "@thruputchain/client/signed-op";
import { spec, MyWallet, type my_wallet } from "./generated/my_wallet.js";
const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({
typeDefs: spec.type_defs,
typeName: "Transfer",
});
const { op, signature } = await transfer.sign(signer, {
network: networkHash,
verifyingContract: walletAddress,
blockExpiryHeight: currentHeight + 100n,
nonce: randomNonce(),
body: { to: recipient, amount: 42n },
});
// `op` and `signature` are the arguments of the contract's submit entrypoint.
const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {
op,
signature,
});
Bind signing helpers to a
#[contract_type]payload.A signed operation authorizes an on-chain action off-chain, so the signer need not submit the transaction: the pattern behind permits, session keys, and delegated wallet actions. The verifying contract embeds
thruput_signed_op::SignedOpReplayCacheand checks the operation withconsume::<Payload>against the key it holds; this is the client half, producing theOperationand signature that contract expects.