# Get block by number (alias)

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

POST https://tron-mainnet.g.alchemy.com/v2/docs-demo/walletsolidity/getblockbynum

Retrieves block details by block number using the `getblockbynum` endpoint.

Reference: https://www.alchemy.com/docs/chains/tron/tron-solidity-http-api-endpoints/tron-solidity-http-api-endpoints/get-block-by-number-alias

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://tron-mainnet.g.alchemy.com/v2/docs-demo/walletsolidity/getblockbynum \
  --header 'Content-Type: application/json' \
  --data '{
  "num": 1
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({num: 1})
};

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

### Python

```python
import requests

url = "https://tron-mainnet.g.alchemy.com/v2/docs-demo/walletsolidity/getblockbynum"

payload = { "num": 1 }
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://tron-mainnet.g.alchemy.com/v2/docs-demo/walletsolidity/getblockbynum"

	payload := strings.NewReader("{\n  \"num\": 1\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://tron-mainnet.g.alchemy.com/v2/docs-demo/walletsolidity/getblockbynum")
  .header("Content-Type", "application/json")
  .body("{\n  \"num\": 1\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://tron-mainnet.g.alchemy.com/v2/docs-demo/walletsolidity/getblockbynum");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"num\": 1\n}", false);
var response = await client.PostAsync(request);

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

```


## Operation Specification

```yaml
path: /walletsolidity/getblockbynum
method: POST
operation:
  summary: Get block by number (alias)
  description: Retrieves block details by block number using the `getblockbynum` endpoint.
  tags:
    - Tron Solidity HTTP API Endpoints
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          properties:
            num:
              type: integer
  responses:
    '200':
      description: Successful response with block details
      content:
        application/json:
          schema:
            type: object
            example:
              blockID: 0000000000004e2014d43993f9403af438f8a2ab2470b2f10369b51eec6c64c4
              block_header:
                raw_data:
                  number: 20000
                  txTrieRoot: '0000000000000000000000000000000000000000000000000000000000000000'
                  witness_address: 410694981b116304ed21e05896fb16a6bc2e91c92c
                  parentHash: 0000000000004e1fb1f8ccf17f8cd6f7df753a9d007db21b6f64df474c483f27
                  timestamp: 1529951556000
                witness_signature: afe73dbfaa13e635ba3d5dd50f19bc4f77e7c537a780214e695ee87f4d6d84f96615c26627bcfae1a004c852c4b91bd1234046cbdfd6bea0b13f60a4dfd64f8100
```
