forked from blocto/solana-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (41 loc) · 1.48 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"context"
"log"
"github.com/doesnotcommit/solana-go-sdk/client"
"github.com/doesnotcommit/solana-go-sdk/common"
"github.com/doesnotcommit/solana-go-sdk/program/address_lookup_table"
"github.com/doesnotcommit/solana-go-sdk/rpc"
"github.com/doesnotcommit/solana-go-sdk/types"
)
// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
if err != nil {
log.Fatalf("failed to get latest blockhash, err: %v", err)
}
lookupTablePubkey := common.PublicKeyFromString("3LZbwptsCkv5R5uu1GNZKiX9SoC6egNG8NXg9zH5ZVM9")
tx, err := types.NewTransaction(types.NewTransactionParam{
Signers: []types.Account{feePayer},
Message: types.NewMessage(types.NewMessageParam{
FeePayer: feePayer.PublicKey,
RecentBlockhash: recentBlockhashResponse.Blockhash,
Instructions: []types.Instruction{
address_lookup_table.FreezeLookupTable(address_lookup_table.FreezeLookupTableParams{
LookupTable: lookupTablePubkey,
Authority: feePayer.PublicKey,
}),
},
}),
})
if err != nil {
log.Fatalf("failed to new a transaction, err: %v", err)
}
txhash, err := c.SendTransaction(context.Background(), tx)
if err != nil {
log.Fatalf("failed to send tx, err: %v", err)
}
log.Println("txhash:", txhash)
}