# Vote Witness Account

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

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

Casts votes for Super Representatives (witnesses) using TRX tokens from the voter's account.

Reference: https://www.alchemy.com/docs/chains/tron/tron-http-api-endpoints/tron-http-api-endpoints/vote-witness-account

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/votewitnessaccount \
  --header 'Content-Type: application/json' \
  --data '{
  "owner_address": "string",
  "votes": [
    {
      "vote_address": "string",
      "vote_count": 1
    }
  ],
  "visible": false
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    owner_address: 'string',
    votes: [{vote_address: 'string', vote_count: 1}],
    visible: false
  })
};

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

payload = {
    "owner_address": "string",
    "votes": [
        {
            "vote_address": "string",
            "vote_count": 1
        }
    ],
    "visible": False
}
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/votewitnessaccount"

	payload := strings.NewReader("{\n  \"owner_address\": \"string\",\n  \"votes\": [\n    {\n      \"vote_address\": \"string\",\n      \"vote_count\": 1\n    }\n  ],\n  \"visible\": false\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/votewitnessaccount")
  .header("Content-Type", "application/json")
  .body("{\n  \"owner_address\": \"string\",\n  \"votes\": [\n    {\n      \"vote_address\": \"string\",\n      \"vote_count\": 1\n    }\n  ],\n  \"visible\": false\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/votewitnessaccount");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"owner_address\": \"string\",\n  \"votes\": [\n    {\n      \"vote_address\": \"string\",\n      \"vote_count\": 1\n    }\n  ],\n  \"visible\": false\n}", false);
var response = await client.PostAsync(request);

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

```


## Operation Specification

```yaml
path: /wallet/votewitnessaccount
method: POST
operation:
  summary: Vote Witness Account
  description: Casts votes for Super Representatives (witnesses) using TRX tokens from the voter's account.
  tags:
    - Tron HTTP API Endpoints
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          properties:
            owner_address:
              type: string
              description: The address of the account voting for witnesses (Base58 or hex, depending on `visible` flag).
            votes:
              type: array
              description: A list of votes containing witness addresses and the number of votes.
              items:
                type: object
                properties:
                  vote_address:
                    type: string
                    description: The address of the witness to vote for.
                  vote_count:
                    type: integer
                    description: The number of votes to cast for this witness.
            visible:
              type: boolean
              description: Whether the input addresses are in base58 format.
          example:
            owner_address: TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g
            votes:
              - vote_address: TYMwiU7KPcd2ydAYsWb1aDZ9f3o2a1qCHs
                vote_count: 2
            visible: true
  responses:
    '200':
      description: Vote transaction data.
      content:
        application/json:
          example:
            visible: true
            txID: 8a245289f1e36a7a621c9aa7d75e56e58f18cc5e861de99e02aebf04a9cce65a
            raw_data:
              contract:
                - parameter:
                    value:
                      owner_address: 41758be32e9aa19858a7c5f3d8e7dd01f7869ccdbc
                      votes:
                        - vote_address: 41a4ce68cfcdd27884bde52cec653354048e0aa989
                          vote_count: 2
                    type_url: type.googleapis.com/protocol.VoteWitnessContract
                  type: VoteWitnessContract
              ref_block_bytes: f58e
              ref_block_hash: 3a12e8dc94260b7e
              expiration: 1762349250000
              timestamp: 1762349191922
            raw_data_hex: 0a02f58e22083a12e8dc94260b7e40c8dc84a1a5335ad801081e12b6010a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e74726163741280010a1541758be32e9aa19858a7c5f3d8e7dd01f7869ccdbc1a290a1541a4ce68cfcdd27884bde52cec653354048e0aa989108002
```
