> For the complete documentation index, see [llms.txt](https://docs.minervachain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.minervachain.org/build/send-pq-transaction.md). Agents can also search and read this documentation through its [MCP server](https://docs.minervachain.org/~gitbook/mcp).

# Send a PQ transaction

This page goes one level below the SDK: build and sign a `MinervaPQTxV1` with `@minervaquantum/pq-native-tx`, then submit the raw bytes yourself. Use it for backends, signers that keep keys in hardware, or any environment where you want to control submission.

## Sign

```ts
import {
  generateMLDSA65KeyPair,
  deriveMinervaPQAccountAddress,
  signMinervaPQTxV1,
} from "@minervaquantum/pq-native-tx";

const keyPair = generateMLDSA65KeyPair();           // or load an existing seed
const from = deriveMinervaPQAccountAddress(keyPair.publicKey);

const signed = signMinervaPQTxV1({
  chainId: 77139,                                   // 77138 for the testnet
  nonce: 0n,
  gasTipCap: 1_000_000_000n,
  gasFeeCap: 2_000_000_000n,
  gas: 500_000n,
  to: "0x000000000000000000000000000000000000dEaD",
  value: 10n ** 18n,
  data: "0x",
  pqPublicKey: keyPair.publicKey,
  pqPrivateKey: keyPair.privateKey,
});

console.log(from, signed.rawTransaction);           // 0x4d… raw bytes
```

`signed.rawTransaction` is the EIP-2718 envelope: the type byte `0x4d` followed by the RLP payload. The signing hash and the encoding match what the node validates; a cross-repository fixture test pins them.

## Submit

Through any node RPC:

```sh
curl -s -X POST https://mainnet.minervachain.org/rpc \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_sendRawTransaction","params":["0x4d…"]}'
```

Through the public relayer, which is the same thing over a simpler HTTP surface and what the wallets use:

```sh
curl -s -X POST https://mainnet.minervachain.org/pq-dev/send-raw \
  -H 'content-type: application/json' \
  -d '{"rawTransaction":"0x4d…"}'
```

The relayer holds no key and cannot alter the transaction; it forwards the bytes and returns the hash. `GET /pq-dev/account?address=0x…` returns the account's nonce, balance and deployment state as the relayer sees them.

## Nonce, gas and policy version

* **Nonce.** `eth_getTransactionCount(address, "pending")` works for Minerva accounts; the nonce is the account's transaction nonce, whether or not the contract is deployed.
* **Gas.** Estimate with `eth_estimateGas` from the account address and add headroom. The payload is large, so the floor is well above 21,000.
* **Policy version.** A counterfactual account always signs with policy version 0. After deployment and any rotation, read the current version with `minerva_getAccountControl` and pass it, or the node rejects the transaction as stale. The SDK does this for you; at this level it is your responsibility.

## Deploy a contract

Leave `to` empty and put the creation bytecode in `data`. The contract's address is derived from the account address and nonce as on Ethereum; `msg.sender` in the constructor is your Minerva account.

## Deploy the account itself

A counterfactual account can spend without deploying. Deploy when you need the contract's own features (key rotation, device keys, EIP-1271):

```ts
// target: the factory, data: createAccount(bytes32 salt, bytes pqPublicKey)
to: "0x0000000000000000000000000000000000000203",
data: encodeFunctionData({ abi: minervaAccountFactoryAbi, functionName: "createAccount", args: [salt, publicKey] }),
```

The account pays for its own deployment. The `@minerva/evm` package in the wallet repository wraps this as `deployMinervaPQAccountFromAccount`.

## Key handling

Keep the 32-byte seed, not the expanded private key, and keep it out of source control. The packages expose primitives; your application remains responsible for key storage, user consent, transaction simulation and policy checks.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.minervachain.org/build/send-pq-transaction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
