@thruputchain/client
    Preparing search index...

    Function defineSignedOperation

    • 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::SignedOpReplayCache and checks the operation with consume::<Payload> against the key it holds; this is the client half, producing the Operation and signature that contract expects.

      Type Parameters

      • TBody

      Parameters

      Returns SignedOperationType<TBody>

      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,
      });

      If typeName selects none, or more than one, of typeDefs.