@moon-x/tron-adapter
v0.1.1
Published
Chain-aware Tron signing helpers for MoonX ephemeral signers. Builds the sha256/TIP-191 digest and assembles ready-to-broadcast signatures/transactions so integrators never hand-roll payload construction.
Readme
@moon-x/tron-adapter
Chain-aware Tron signing for MoonX ephemeral signers (agents). Wraps the
low-level signWithEphemeralSigner primitive with intent-level helpers so
integrators never hash anything by hand:
signMessage(message)- TIP-191 message signature (TronWebsignMessageV2semantics), verifiable withTrx.verifyMessageV2.signTransaction(tx)- signs a TronWeb-built transaction (sha256 ofraw_data_hex) and returns the broadcast-ready object fortronWeb.trx.sendRawTransaction.
Build transactions with TronWeb's TransactionBuilder; this package signs
them. It has no TronWeb runtime dependency - transactions arrive already
protobuf-serialized (raw_data_hex), and the signature is appended exactly
the way TronWeb's own trx.sign() would.
Usage
import { createTronSigner } from "@moon-x/tron-adapter";
const signer = createTronSigner({
apiPubHex, // agent keypair from provisioning
apiPrivHex,
walletId, // Tron (secp256k1) wallet the agent is provisioned for
secretKey, // moon_sk_* - server-only
});
const signature = await signer.signMessage("gm");
const signedTx = await signer.signTransaction(unsignedTx); // from TransactionBuilderFor a custom transport (tests, iframe MPC), construct MoonXTronSigner
with your own EcdsaSignFn instead of a config.
