@moon-x/solana-adapter
v0.3.3
Published
Chain-aware Solana signing helpers for MoonX ephemeral signers. Serializes the message bytes and assembles ready-to-broadcast transactions/signatures so integrators never hand-roll payload construction.
Readme
@moon-x/solana-adapter
Chain-aware Solana signing helpers for MoonX ephemeral signers.
The low-level signWithEphemeralSigner primitive in @moon-x/core signs
arbitrary raw bytes for an ed25519 key — which means the integrator is
responsible for producing the exact bytes (serializing the transaction
message) and for attaching the returned signature to the transaction. This
adapter does both: you pass intent and get back a ready-to-broadcast
artifact.
Solana differs from EVM: ed25519 signs the raw message bytes directly — there is no keccak / pre-hashing step. The adapter handles that correctly so you don't have to think about it.
Install
pnpm add @moon-x/solana-adapter @solana/web3.js@solana/web3.js is a peer dependency, so your app's single instance is the
one used.
Usage
import { createSolanaSigner } from "@moon-x/solana-adapter";
const signer = createSolanaSigner({
apiPubHex, // from provisioning
apiPrivHex, // never leaves your backend
walletId, // the Solana wallet the agent was provisioned for
address, // base58 wallet pubkey (needed to attach the signature)
baseUrl, // wallets backend URL
secretKey, // moon_sk_* (server-only; the sign routes are secret-key-only)
});
// Arbitrary message → 64-byte ed25519 signature
const sig = await signer.signMessage("gm");
// Transaction (legacy or versioned) → wire-ready serialized bytes
const raw = await signer.signTransaction(transaction);
await connection.sendRawTransaction(raw);Scheme safety
The adapter enforces that the target wallet is ed25519. Pointing it at a
secp256k1 (EVM) wallet throws SolanaSchemeMismatchError instead of producing
a valid-but-wrong signature — use @moon-x/evm-adapter for those.
Escape hatch
For signing flows this adapter doesn't model, drop down to
signWithEphemeralSigner from @moon-x/core/sdk and build the payload
yourself.
