# Bundle Sending Sample

```go
package main

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"github.com/gagliardetto/solana-go"
	"github.com/gagliardetto/solana-go/programs/system"
	"github.com/gagliardetto/solana-go/rpc"
	"io"
	"net/http"
	"testing"
)

type Payload struct {
	Transaction TransactionMessage `json:"transaction"`
}

type TransactionMessage struct {
	Content string `json:"content"`
}

func TestSendTx(T *testing.T) {
	cli := http.Client{}
	privateKey := solana.MustPrivateKeyFromBase58("")
	rpcClient := rpc.New("")
	bh, _ := rpcClient.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)
	txBuilder := solana.NewTransactionBuilder()
	txBuilder.SetRecentBlockHash(bh.Value.Blockhash)
	txBuilder.AddInstruction(system.NewTransferInstruction(1000001, privateKey.PublicKey(), solana.MustPublicKeyFromBase58("nEXTBLockYgngeRmRrjDV31mGSekVPqZoMGhQEZtPVG")).Build())

	tx, _ := txBuilder.Build()
	tx.Sign(func(key solana.PublicKey) *solana.PrivateKey {
		return &privateKey
	})
	tx64Str := tx.MustToBase64()

	txMsg := TransactionMessage{
		Content: tx64Str,
	}
	entry := Entry{
		Transaction: txMsg,
	}

	p := BatchPayload{
		Transactions: []Entry{entry},
	}

	fmt.Println("Sending transaction", tx.Signatures[0].String())

	txBuilder = solana.NewTransactionBuilder()
	txBuilder.SetRecentBlockHash(bh.Value.Blockhash)
	txBuilder.AddInstruction(system.NewTransferInstruction(1000002, privateKey.PublicKey(), solana.MustPublicKeyFromBase58("nEXTBLockYgngeRmRrjDV31mGSekVPqZoMGhQEZtPVG")).Build())

	tx, _ = txBuilder.Build()
	tx.Sign(func(key solana.PublicKey) *solana.PrivateKey {
		return &privateKey
	})
	tx64Str = tx.MustToBase64()

	txMsg = TransactionMessage{
		Content: tx64Str,
	}
	entry = Entry{
		Transaction: txMsg,
	}

	p.Transactions = append(p.Transactions, entry)

	t, _ := json.Marshal(p)

	fmt.Println(string(t))
	fmt.Println(privateKey.PublicKey().String())

	req, err := http.NewRequest("POST", "https://ny.nextblock.io/api/v2/submit-batch", bytes.NewBuffer(t))
	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("authorization", "advanced123456789-ABCD%2FyfHouQJyiWObY1ntyFSBI3G3NNCczaWKRJPvc%3D")
	if err != nil {
		T.Error(err)
		return
	}
	do, err := cli.Do(req)
	if err != nil {
		T.Error(err)
		return
	}
	defer do.Body.Close()
	b, _ := io.ReadAll(do.Body)
	T.Log(string(b))
	if do.StatusCode == 200 {
		T.Log("Sent transaction with signature ", tx.Signatures[0].String())
	} else {
		fmt.Println(do.StatusCode)
		T.Error("Failed to send transaction")
	}
}

```

### CURL Example

`curl -XPOST -H 'authorization: api key' -H 'Content-Type: application/json' 'https://frankfurt.nextblock.io/api/v2/submit-batch' -d '{`"entries": \[ { "transaction": { "content": "ASrTNkPOT...." } } ] }`'`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nextblock.io/getting-started/quickstart/bundle-sending-sample.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
