# optimism_outputAtBlock

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

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

Returns the output root at a specific block.

Reference: https://www.alchemy.com/docs/chains/world-chain/world-chain-api-endpoints/optimism-output-at-block

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| blockNumber | string | Yes | The block number to get the output root for. |

## Result

**Output root** (object): The output root at the specified block.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "optimism_outputAtBlock",
  "params": [
    "0x6DAA86C"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "version": 0,
    "outputRoot": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://worldchain-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "optimism_outputAtBlock",
  "params": [
    "0x6DAA86C"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'optimism_outputAtBlock', params: ['0x6DAA86C']})
};

fetch('https://worldchain-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://worldchain-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "optimism_outputAtBlock",
    "params": ["0x6DAA86C"]
}
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://worldchain-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"optimism_outputAtBlock\",\n  \"params\": [\n    \"0x6DAA86C\"\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://worldchain-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"optimism_outputAtBlock\",\n  \"params\": [\n    \"0x6DAA86C\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://worldchain-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\": \"optimism_outputAtBlock\",\n  \"params\": [\n    \"0x6DAA86C\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: optimism_outputAtBlock
description: Returns the output root at a specific block.
x-compute-units: 10
params:
  - name: blockNumber
    required: true
    description: The block number to get the output root for.
    schema:
      title: hex encoded unsigned integer
      type: string
      pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
result:
  name: Output root
  description: The output root at the specified block.
  schema:
    type: object
    properties:
      version:
        type: integer
        description: The output root version number, beginning with 0
      outputRoot:
        type: string
        description: The output root
      blockRef:
        type: object
        description: The block reference object
        properties:
          hash:
            type: string
            description: The hash of the referenced block
          number:
            type: string
            description: The block number of the referenced block
          parentHash:
            type: string
            description: The hash of the parent block
          timestamp:
            type: string
            description: The timestamp associated with the referenced block
      l1origin:
        type: object
        description: The L1 origin information
        properties:
          hash:
            type: string
            description: The hash of the L1 origin block
          number:
            type: string
            description: The block number of the L1 origin
          sequenceNumber:
            type: string
            description: The sequence number of the queued unsafe L2
      withdrawalStorageRoot:
        type: string
        description: The root hash of the withdrawal storage data at the specified block
      stateRoot:
        type: string
        description: The root hash of the state data at the specified block
      syncStatus:
        type: object
        description: The synchronization status information
        properties:
          current_l1:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the current L1 synchronization status
              number:
                type: string
                description: The block number of the current L1 synchronization status
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the current L1 synchronization status
          current_l1_finalized:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the finalized state of the current L1
              number:
                type: string
                description: The block number of the finalized state of the current L1
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the finalized state of the current L1
          head_l1:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the head L1
              number:
                type: string
                description: The block number of the head L1
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the head L1
          safe_l1:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the safe L1
              number:
                type: string
                description: The block number of the safe L1
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the safe L1
          finalized_l1:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the finalized L1
              number:
                type: string
                description: The block number of the finalized L1
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the finalized L1
          unsafe_l2:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the unsafe L2
              number:
                type: string
                description: The block number of the unsafe L2
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the unsafe L2
              l1origin:
                type: object
                properties:
                  hash:
                    type: string
                    description: The hash of the L1 origin block
                  number:
                    type: string
                    description: The block number of the L1 origin
                  sequenceNumber:
                    type: string
                    description: The sequence number of the unsafe L2
          safe_l2:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the safe L2
              number:
                type: string
                description: The block number of the safe L2
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the safe L2
              l1origin:
                type: object
                properties:
                  hash:
                    type: string
                    description: The hash of the L1 origin block
                  number:
                    type: string
                    description: The block number of the L1 origin
                  sequenceNumber:
                    type: string
                    description: The sequence number of the safe L2
          finalized_l2:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the finalized L2
              number:
                type: string
                description: The block number of the finalized L2
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the finalized L2
              l1origin:
                type: object
                properties:
                  hash:
                    type: string
                    description: The hash of the L1 origin block
                  number:
                    type: string
                    description: The block number of the L1 origin
                  sequenceNumber:
                    type: string
                    description: The sequence number of the finalized L2
          queued_unsafe_l2:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the queued unsafe L2
              number:
                type: string
                description: The block number of the queued unsafe L2
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the queued unsafe L2
              l1origin:
                type: object
                properties:
                  hash:
                    type: string
                    description: The hash of the L1 origin block
                  number:
                    type: string
                    description: The block number of the L1 origin
                  sequenceNumber:
                    type: string
                    description: The sequence number of the queued unsafe L2
          engine_sync_target:
            type: object
            properties:
              hash:
                type: string
                description: The hash of the synchronization target for the engine
              number:
                type: string
                description: The block number of the synchronization target for the engine
              parentHash:
                type: string
                description: The hash of the parent block
              timestamp:
                type: string
                description: The timestamp of the synchronization target for the engine
              l1origin:
                type: object
                properties:
                  hash:
                    type: string
                    description: The hash of the L1 origin block
                  number:
                    type: string
                    description: The block number of the L1 origin
                  sequenceNumber:
                    type: string
                    description: The sequence number of the synchronization target for the engine
examples:
  - name: optimism_outputAtBlock example
    params:
      - name: blockNumber
        value: '0x6DAA86C'
    result:
      name: Output root
      value:
        version: 0
        outputRoot: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
```
