# eth_fillTransaction

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://rise-mainnet.g.alchemy.com/v2/{apiKey}

Fills in default values for a transaction object. This method populates missing fields such as `gas`, `gasPrice`, `nonce`, and `chainId` based on the current network state and transaction parameters. It returns both the filled transaction object and the RLP-encoded raw transaction data.

This is useful for preparing transactions before signing, as it ensures all required fields are present with appropriate values.


Reference: https://www.alchemy.com/docs/chains/rise/rise-api-endpoints/eth-fill-transaction

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Transaction | object | Yes | The transaction object with optional fields to be filled. Fields like `gas`, `gasPrice`, `nonce`, and `chainId` will be populated if not provided. |

## Result

**Filled transaction** (object): An object containing the filled transaction and its RLP-encoded form.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_fillTransaction",
  "params": [
    {
      "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
      "to": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
      "value": "0x1"
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "raw": "0xf86c808504a817c80082520894627306090abab3a6e1400e9345bc60c78a8bef570180808080",
    "tx": {
      "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
      "to": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
      "value": "0x1",
      "gas": "0x5208",
      "gasPrice": "0x4a817c800",
      "nonce": "0x0",
      "chainId": "0x1",
      "input": "0x"
    }
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://rise-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_fillTransaction",
  "params": [
    {
      "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
      "to": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
      "value": "0x1"
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_fillTransaction',
    params: [
      {
        from: '0xfe3b557e8fb62b89f4916b721be55ceb828dbd73',
        to: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
        value: '0x1'
      }
    ]
  })
};

fetch('https://rise-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://rise-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_fillTransaction",
    "params": [
        {
            "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
            "to": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
            "value": "0x1"
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://rise-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_fillTransaction\",\n  \"params\": [\n    {\n      \"from\": \"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73\",\n      \"to\": \"0x627306090abab3a6e1400e9345bc60c78a8bef57\",\n      \"value\": \"0x1\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://rise-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_fillTransaction\",\n  \"params\": [\n    {\n      \"from\": \"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73\",\n      \"to\": \"0x627306090abab3a6e1400e9345bc60c78a8bef57\",\n      \"value\": \"0x1\"\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://rise-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_fillTransaction\",\n  \"params\": [\n    {\n      \"from\": \"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73\",\n      \"to\": \"0x627306090abab3a6e1400e9345bc60c78a8bef57\",\n      \"value\": \"0x1\"\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: eth_fillTransaction
description: |
  Fills in default values for a transaction object. This method populates missing fields such as `gas`, `gasPrice`, `nonce`, and `chainId` based on the current network state and transaction parameters. It returns both the filled transaction object and the RLP-encoded raw transaction data.

  This is useful for preparing transactions before signing, as it ensures all required fields are present with appropriate values.
params:
  - name: Transaction
    required: true
    description: The transaction object with optional fields to be filled. Fields like `gas`, `gasPrice`, `nonce`, and `chainId` will be populated if not provided.
    schema:
      type: object
      title: Transaction object generic to all types
      description: Parameters describing a transaction/message call.
      additionalProperties: false
      properties:
        type:
          title: type
          description: Transaction type byte (per EIP-2718), e.g., 0x0 (legacy), 0x1 (EIP-2930), 0x2 (EIP-1559), 0x3 (EIP-4844).
          type: string
          pattern: ^0x([0-9a-fA-F]?){1,2}$
        nonce:
          title: nonce
          description: Number of prior transactions sent from the sender account.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        to:
          title: to address
          description: Recipient of the call. Use null to indicate contract creation.
          oneOf:
            - title: Contract Creation (null)
              description: Null to create a contract; the address is derived from sender and nonce.
              type: 'null'
            - title: Address
              description: 20-byte address of the recipient account or contract.
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
        from:
          title: from address
          description: 20-byte address of the sender (msg.sender).
          type: string
          pattern: ^0x[0-9a-fA-F]{40}$
        gas:
          title: gas limit
          description: Maximum gas provided for execution.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        value:
          title: value
          description: Amount of Ether to transfer with the call, in wei.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        input:
          title: input data
          type: string
          pattern: ^0x[0-9a-f]*$
          description: Calldata for the call (hex-encoded bytes).
        gasPrice:
          title: gas price
          description: The gas price willing to be paid by the sender in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxPriorityFeePerGas:
          title: max priority fee per gas
          description: Maximum fee per gas the sender is willing to pay to miners in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxFeePerGas:
          title: max fee per gas
          description: The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxFeePerBlobGas:
          title: max fee per blob gas
          description: The maximum total fee per gas the sender is willing to pay for blob gas in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        accessList:
          title: accessList
          description: EIP-2930 access list of pre-touched addresses and storage keys.
          type: array
          items:
            title: Access list entry
            type: object
            additionalProperties: false
            properties:
              address:
                title: hex encoded address
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
              storageKeys:
                type: array
                items:
                  title: 32 byte hex value
                  type: string
                  pattern: ^0x[0-9a-f]{64}$
        blobVersionedHashes:
          title: blobVersionedHashes
          description: List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.
          type: array
          items:
            title: 32 byte hex value
            type: string
            pattern: ^0x[0-9a-f]{64}$
        blobs:
          title: blobs
          description: Raw EIP-4844 blob data (each item is a binary-encoded blob).
          type: array
          items:
            title: hex encoded bytes
            type: string
            pattern: ^0x[0-9a-f]*$
        chainId:
          title: chainId
          description: Chain ID that this transaction is valid on.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
result:
  name: Filled transaction
  description: An object containing the filled transaction and its RLP-encoded form.
  schema:
    type: object
    required:
      - raw
      - tx
    additionalProperties: false
    properties:
      raw:
        title: hex encoded bytes
        type: string
        pattern: ^0x[0-9a-f]*$
        description: The RLP-encoded transaction data as a hexadecimal string.
      tx:
        type: object
        title: Transaction object generic to all types
        description: The filled transaction object with all fields populated.
        additionalProperties: false
        properties:
          type:
            title: type
            description: Transaction type byte (per EIP-2718), e.g., 0x0 (legacy), 0x1 (EIP-2930), 0x2 (EIP-1559), 0x3 (EIP-4844).
            type: string
            pattern: ^0x([0-9a-fA-F]?){1,2}$
          nonce:
            title: nonce
            description: Number of prior transactions sent from the sender account.
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          to:
            title: to address
            description: Recipient of the call. Use null to indicate contract creation.
            oneOf:
              - title: Contract Creation (null)
                description: Null to create a contract; the address is derived from sender and nonce.
                type: 'null'
              - title: Address
                description: 20-byte address of the recipient account or contract.
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
          from:
            title: from address
            description: 20-byte address of the sender (msg.sender).
            type: string
            pattern: ^0x[0-9a-fA-F]{40}$
          gas:
            title: gas limit
            description: Maximum gas provided for execution.
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          value:
            title: value
            description: Amount of Ether to transfer with the call, in wei.
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          input:
            title: input data
            type: string
            pattern: ^0x[0-9a-f]*$
            description: Calldata for the call (hex-encoded bytes).
          gasPrice:
            title: gas price
            description: The gas price willing to be paid by the sender in wei
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          maxPriorityFeePerGas:
            title: max priority fee per gas
            description: Maximum fee per gas the sender is willing to pay to miners in wei
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          maxFeePerGas:
            title: max fee per gas
            description: The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          maxFeePerBlobGas:
            title: max fee per blob gas
            description: The maximum total fee per gas the sender is willing to pay for blob gas in wei
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          accessList:
            title: accessList
            description: EIP-2930 access list of pre-touched addresses and storage keys.
            type: array
            items:
              title: Access list entry
              type: object
              additionalProperties: false
              properties:
                address:
                  title: hex encoded address
                  type: string
                  pattern: ^0x[0-9a-fA-F]{40}$
                storageKeys:
                  type: array
                  items:
                    title: 32 byte hex value
                    type: string
                    pattern: ^0x[0-9a-f]{64}$
          blobVersionedHashes:
            title: blobVersionedHashes
            description: List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.
            type: array
            items:
              title: 32 byte hex value
              type: string
              pattern: ^0x[0-9a-f]{64}$
          blobs:
            title: blobs
            description: Raw EIP-4844 blob data (each item is a binary-encoded blob).
            type: array
            items:
              title: hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]*$
          chainId:
            title: chainId
            description: Chain ID that this transaction is valid on.
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
examples:
  - name: eth_fillTransaction example
    params:
      - name: Transaction
        value:
          from: '0xfe3b557e8fb62b89f4916b721be55ceb828dbd73'
          to: '0x627306090abab3a6e1400e9345bc60c78a8bef57'
          value: '0x1'
    result:
      name: Filled transaction
      value:
        raw: '0xf86c808504a817c80082520894627306090abab3a6e1400e9345bc60c78a8bef570180808080'
        tx:
          from: '0xfe3b557e8fb62b89f4916b721be55ceb828dbd73'
          to: '0x627306090abab3a6e1400e9345bc60c78a8bef57'
          value: '0x1'
          gas: '0x5208'
          gasPrice: '0x4a817c800'
          nonce: '0x0'
          chainId: '0x1'
          input: 0x
```
