> For the complete documentation index, see [llms.txt](https://fastlane-labs.gitbook.io/polygon-fastlane/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fastlane-labs.gitbook.io/polygon-fastlane/key-concepts/transaction-encoding.md).

# Transaction Encoding

Submitting transactions to the PFL Relay is done using a JSON-RPC endpoint similar to `eth_sendRawTransaction` which means that a knowledge of how to encode transactions into hex (the wire format) is necessary.

Transactions are usually constructed and sent using one of the higher-level web3 libraries such as web3py or web3.js, to prepare a transaction for sending we would usually do something like:

```python
pfl_contract = web3.eth.contract(address=PFL_CONTRACT_ADDRESS, abi=SOME_ABI)

example_tx_base = {
    'from': '0x1',
    'nonce': 0,
    'gasPrice' : 45,
    'gas': 500_000,
    'value': 1000,
    'chainId': 137,
}

some_abi_args = {}

example_tx = pfl_contract.functions.submitFlashBid(
  **args
).buildTransaction(example_tx_base)

signed_example_tx = web3.eth.account.sign_transaction(example_tx, PRIVATE_KEY)
```

Under the hood, when we make a web3 call like this the library is first encoding our transaction object into a standardized hex representation before making a JSON-RPC call to the above endpoint using whatever transport mechanism you have your web3 library configued to use (usually HTTP,  WebSockets or IPC).

To simply retrieve the hexadecimal encoded representation of our transaction as is required for creating a PFL bundle instead of sending to the RPC, we can simply do:

```
print('data: ', signed_example_tx.hex())
```

This value could then be used to make a raw JSON-RPC call without your web3 library, like so:

```bash
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{see above}],"id":1}'
// Response
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
```

For more information, see the Ethereum JSON-RPC documentation [here](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://fastlane-labs.gitbook.io/polygon-fastlane/key-concepts/transaction-encoding.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
