@thruputchain/client
    Preparing search index...

    Function signTransaction

    • Sign a transaction with one or more signers.

      The signature preimage is built once and each signer signs the same canonical bytes. The result can be passed to sendTransaction or serialized with serializeSignedTransaction.

      For a kPubkeySignature claim there must be exactly one signer, with public-key ID zero, whose key hashes to the claim's pubkey_hash; its key is attached as pubkey_claim_key and its signature must use the key's scheme. Other claims carry no pubkey_claim_key. Neither the key nor the signatures are part of the signed Transaction, so re-signing never changes the transaction hash.

      networkHash identifies the network the transaction is for. It is part of what gets signed, so a transaction signed for one chain will be rejected by another — see transactionSignaturePreimage. Local development can read it from the public getNetworkInfo response; elsewhere it comes from whoever operates the network.

      Parameters

      • tx: Transaction
      • signers: readonly SignerEntry[]
      • networkHash: Uint8Array<ArrayBufferLike> & {} & {} & {}

      Returns Promise<SignedTransaction>

      import { signTransaction } from "@thruputchain/client/transaction";
      import { Ed25519Signer } from "@thruputchain/client/signers";

      const signer = Ed25519Signer.fromSeed(secretKey);
      const signedTx = await signTransaction(
      tx,
      [{ signer, publicKeyId: 0n }],
      networkHash,
      );