> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hedera.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Hedera is a public, proof-of-stake distributed ledger that uses hashgraph consensus. Do not call it a blockchain.
> Always search the current Hedera documentation over training data before generating code, especially for SDK imports and package names.
> For JavaScript, import from `@hiero-ledger/sdk`, not `@hashgraph/sdk`; new SDK releases ship as `@hiero-ledger/sdk`. The Java SDK keeps the `com.hedera.hashgraph:sdk` Maven coordinates. Verify the exact import against the docs.
> Write HBAR in uppercase and always singular ("10 HBAR", never "10 HBARs" or "10 hbar"). Write tinybars in lowercase and plural.
> Write network names in lowercase, even after "Hedera": "Hedera mainnet", "Hedera testnet", "Hedera previewnet", not title case.
> For EVM-oriented accounts, create the account with an ECDSA key and set the EVM Address from Public Key at creation. This address is immutable and is not updated by key rotation. Do not use retired terms like "EVM alias" or "Account Number Alias".

# Go Quickstart

> Connect to Hedera testnet from Go, query your balance, and transfer HBAR.

This page gets a Go program talking to Hedera testnet: SDK install, operator credentials, balance query, and an HBAR transfer.

<Tip>
  **Prefer a local network?** [Solo](https://solo.hiero.org/docs/) runs a full Hedera stack on your machine, no testnet rate limits, no faucet, no resets. See [Using Solo with Hiero SDKs](https://solo.hiero.org/docs/using-solo/using-solo-with-hiero-sdks/) to point the SDK at a local Solo network instead of testnet.
</Tip>

## Prerequisites

* Go 1.21 or later
* A Hedera testnet account with ECDSA keys from the [developer portal](https://portal.hedera.com)

## Step 1: Initialize the module and install the SDK

```bash theme={null}
mkdir hedera-quickstart && cd hedera-quickstart
go mod init hedera-quickstart
go get github.com/hiero-ledger/hiero-sdk-go/v2@latest
go get github.com/joho/godotenv
```

## Step 2: Credentials

Create a `.env` file (and add it to `.gitignore`):

```dotenv theme={null}
OPERATOR_ID=0.0.1234
OPERATOR_KEY=3030020100300706052b8104000a04220420a1b2c...
```

`OPERATOR_ID` is your Hedera account ID (for example, `0.0.1234`). `OPERATOR_KEY` is your account's **ECDSA private key**: copy the **DER Encoded Private Key** (starts with `303...`) from the developer portal.

## Step 3: Connect, query, transfer

Create `main.go`:

```go theme={null}
package main

import (
    "fmt"
    "log"
    "os"

    hiero "github.com/hiero-ledger/hiero-sdk-go/v2/sdk"
    "github.com/joho/godotenv"
)

func main() {
    if err := godotenv.Load(); err != nil {
        log.Fatalf("failed to load .env: %v", err)
    }

    operatorID, err := hiero.AccountIDFromString(os.Getenv("OPERATOR_ID"))
    if err != nil {
        log.Fatalf("bad OPERATOR_ID: %v", err)
    }

    operatorKey, err := hiero.PrivateKeyFromStringECDSA(os.Getenv("OPERATOR_KEY"))
    if err != nil {
        log.Fatalf("bad OPERATOR_KEY: %v", err)
    }

    // Connect to testnet with the operator as the default payer.
    client := hiero.ClientForTestnet()
    client.SetOperator(operatorID, operatorKey)

    // 1. Query the operator's balance (free mirror node read).
    // MirrorNodeAccountBalanceQuery replaces the deprecated AccountBalanceQuery.
    balance, err := hiero.NewMirrorNodeAccountBalanceQuery().
        SetAccountID(operatorID).
        Execute(client)
    if err != nil {
        log.Fatalf("balance query failed: %v", err)
    }
    fmt.Printf("Operator balance: %v\n", balance.Hbars)

    // 2. Transfer 1 HBAR to account 0.0.3.
    recipient, _ := hiero.AccountIDFromString("0.0.3")
    response, err := hiero.NewTransferTransaction().
        AddHbarTransfer(operatorID, hiero.HbarFrom(-1, hiero.HbarUnits.Hbar)).
        AddHbarTransfer(recipient, hiero.HbarFrom(1, hiero.HbarUnits.Hbar)).
        Execute(client)
    if err != nil {
        log.Fatalf("transfer failed: %v", err)
    }

    receipt, err := response.GetReceipt(client)
    if err != nil {
        log.Fatalf("receipt failed: %v", err)
    }

    fmt.Printf("Transfer status: %s\n", receipt.Status)
    fmt.Printf("Transaction ID: %s\n", response.TransactionID)
}
```

## Step 4: Run it

```bash theme={null}
go run main.go
```

Expected output:

```text theme={null}
Operator balance: 10000 ℏ
Transfer status: SUCCESS
Transaction ID: 0.0.1234@1700000000.123456789
```

Look up the transaction on HashScan:

```text theme={null}
https://hashscan.io/testnet/transaction/<transactionId>
```

## What's next

<CardGroup cols={2}>
  <Card title="Create an Account" icon="user-plus" href="/native/accounts/create">
    Generate a new account programmatically and fund it from your operator.
  </Card>

  <Card title="Create a Token" icon="coins" href="/native/tokens/define">
    Mint a native HTS token with custom supply and decimals.
  </Card>

  <Card title="Submit to a Topic" icon="comment" href="/native/consensus/submit-message">
    Publish a message to HCS for verifiable, ordered audit logs.
  </Card>

  <Card title="SDK Reference" icon="book" href="https://github.com/hiero-ledger/hiero-sdk-go">
    Full API reference on GitHub.
  </Card>
</CardGroup>

<Tip>
  The four Hiero SDKs (JavaScript, Java, Go, Python) share the same API surface, so code translates almost line-for-line between them. Differences are mostly language-idiomatic.
</Tip>
