# Freeze balance using FreezeBalanceV2

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

POST https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/freezebalancev2

Freezes TRX tokens in an account to gain ENERGY resources using the newer FreezeBalanceV2 mechanism.   This version omits the `frozen_duration` parameter and is considered an improved alternative to `/freezebalance`.


Reference: https://www.alchemy.com/docs/chains/tron/tron-http-api-endpoints/tron-http-api-endpoints/freeze-balance-using-freeze-balance-v-2

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/freezebalancev2 \
  --header 'Content-Type: application/json' \
  --data '{
  "owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
  "frozen_balance": 10000000,
  "resource": "ENERGY",
  "visible": true
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    owner_address: 'TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g',
    frozen_balance: 10000000,
    resource: 'ENERGY',
    visible: true
  })
};

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

payload = {
    "owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
    "frozen_balance": 10000000,
    "resource": "ENERGY",
    "visible": True
}
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/wallet/freezebalancev2"

	payload := strings.NewReader("{\n  \"owner_address\": \"TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g\",\n  \"frozen_balance\": 10000000,\n  \"resource\": \"ENERGY\",\n  \"visible\": true\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/wallet/freezebalancev2")
  .header("Content-Type", "application/json")
  .body("{\n  \"owner_address\": \"TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g\",\n  \"frozen_balance\": 10000000,\n  \"resource\": \"ENERGY\",\n  \"visible\": true\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/freezebalancev2");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"owner_address\": \"TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g\",\n  \"frozen_balance\": 10000000,\n  \"resource\": \"ENERGY\",\n  \"visible\": true\n}", false);
var response = await client.PostAsync(request);

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

```


## Operation Specification

```yaml
path: /wallet/freezebalancev2
method: POST
operation:
  summary: Freeze balance using FreezeBalanceV2
  description: |
    Freezes TRX tokens in an account to gain ENERGY resources using the newer FreezeBalanceV2 mechanism.   This version omits the `frozen_duration` parameter and is considered an improved alternative to `/freezebalance`.
  tags:
    - Tron HTTP API Endpoints
  security:
    - apiKey: []
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          required:
            - owner_address
            - frozen_balance
            - resource
          properties:
            owner_address:
              type: string
              description: Base58 address of the account to freeze TRX from.
              example: TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g
            frozen_balance:
              type: integer
              description: Amount to freeze, in SUN (1 TRX = 1,000,000 SUN).
              example: 10000000
            resource:
              type: string
              enum:
                - BANDWIDTH
                - ENERGY
              description: Type of resource to gain from freezing.
              example: ENERGY
            visible:
              type: boolean
              description: Indicates if the address is base58 (true) or hex (false).
              example: true
  responses:
    '200':
      description: Unsigned transaction object for FreezeBalanceV2 operation.
      content:
        application/json:
          schema:
            type: object
            properties:
              visible:
                type: boolean
              txID:
                type: string
              raw_data:
                type: object
                properties:
                  contract:
                    type: array
                    items:
                      type: object
                      properties:
                        parameter:
                          type: object
                          properties:
                            value:
                              type: object
                              properties:
                                owner_address:
                                  type: string
                                frozen_balance:
                                  type: integer
                                resource:
                                  type: string
                            type_url:
                              type: string
                        type:
                          type: string
                  ref_block_bytes:
                    type: string
                  ref_block_hash:
                    type: string
                  expiration:
                    type: integer
                  timestamp:
                    type: integer
              raw_data_hex:
                type: string
                description: Hex-encoded raw transaction.
          examples:
            response:
              value:
                visible: true
                txID: 63b44752122878519d28fa39215c073442d111205b93c7841d1cec92de6bd3c5
                raw_data:
                  contract:
                    - parameter:
                        value:
                          resource: ENERGY
                          frozen_balance: 10000000
                          owner_address: TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g
                        type_url: type.googleapis.com/protocol.FreezeBalanceV2Contract
                      type: FreezeBalanceV2Contract
                  ref_block_bytes: 41ab
                  ref_block_hash: 6e4741b021c6afe5
                  expiration: 1762275138000
                  timestamp: 1762275080550
                raw_data_hex: 0a0241ab22086e4741b021c6afe540d0b3a2fea4335a5a083612560a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121e0a1541fd49eda0f23ff7ec1d03b52c3a45991c24cd440e1080ade204180170e6f29efea433
```
