Skip to content

FAQ ​

Are there integration examples? ​

Each API page includes code examples. Contact us if an example is missing.

What if I run into an integration issue? ​

Read the integration documentation first. If the issue remains unresolved, contact customer support.

How can I tell whether Energy has been delegated after placing an order? ​

When sufficient Energy is available, it is usually delegated to the receiving address within 1–3 seconds. A status of 4 means the order was placed successfully, 6 means the Energy has been delegated, and 14 means the order was refunded because Energy was insufficient. For other statuses, poll the order details endpoint. Thanks to @miya0v0 for the following Go example.

Go ​

go
// Create a buffered channel for the result.
resultCh := make(chan *utils.OrderQueryResponse, 1)
var wg sync.WaitGroup
wg.Add(1)
// Create a context with a timeout.
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
// Start a goroutine to poll the order details.
go func() {
  defer wg.Done()
  for {
    select {
    case <-ctx.Done():
      log.Println("Timeout, stopping to fetch order details.")
      return
    default:
      result, err := utils.GetOrderDetail(sendRentEnergy.OrderNo)
      if err != nil {
        log.Println("Error getting order detail:", err)
        return
      }
      // A non-empty FrozenTxID confirms the delegation transaction.
      if result.Status == 6 && result.FrozenTxID != "" {
        resultCh <- result
        return
      } else {
        log.Println(result.Status, result.FrozenTxID)
      }
      time.Sleep(1 * time.Second)
    }
  }
}()
wg.Wait()
// Receive the result or handle the timeout.
select {
case <-resultCh:
  cancel()
case <-ctx.Done():
  log.Println("Timeout: Failed to receive result from the goroutine.")
}