Signs an SVM transaction using the wallet identified by the supplied walletMetadata. The SDK is stateless — every call requires walletMetadata. Accepts a Transaction, VersionedTransaction, or hex string. Optionally requests gas sponsorship from Dynamic before signing.
When you pass externalServerKeyShares (the caller-supplied path), walletMetadata.externalServerKeySharesBackupInfo must also be present — signTransaction throws if shares are supplied but backup metadata is missing. The full walletMetadata returned from createWalletAccount / importPrivateKey already includes it; identity-only metadata from fetchWalletMetadata will be rejected.
walletMetadata (WalletMetadata) - Non-sensitive wallet metadata persisted from createWalletAccount() / importPrivateKey(). The signer address comes from walletMetadata.accountAddress.
transaction (VersionedTransaction | Transaction | string) - The transaction to sign
Calling VersionedTransaction.deserialize() on the decoded bytes will throw “Reached end of buffer unexpectedly” — confirming the 64 bytes are a signature, not a serialized transaction.To broadcast: decode the signature and add it back to the transaction using decodeBase58 and addSignatureToTransaction from @dynamic-labs-wallet/node-svm, then call connection.sendRawTransaction(signedTx.serialize()). See the example below.Passing the string directly to connection.sendRawTransaction() or the SDK’s sendTransaction() will fail — Buffer.from(base58string) interprets the characters as UTF-8 bytes (not the decoded signature), producing a garbled payload.