diff --git a/404.html b/404.html new file mode 100644 index 00000000..a8ab2495 --- /dev/null +++ b/404.html @@ -0,0 +1,33 @@ + + + + + + + + + Solana Development With Go + + + + +

404

Looks like we've got some broken links.
Take me home
+ + + diff --git a/advanced/durable-nonce/create-nonce-account.html b/advanced/durable-nonce/create-nonce-account.html new file mode 100644 index 00000000..767f4b9d --- /dev/null +++ b/advanced/durable-nonce/create-nonce-account.html @@ -0,0 +1,104 @@ + + + + + + + + + Create Nonce Account | Solana Development With Go + + + + +

Create Nonce Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// create a new account
+	nonceAccount := types.NewAccount()
+	fmt.Println("nonce account:", nonceAccount.PublicKey)
+
+	// get minimum balance
+	nonceAccountMinimumBalance, err := c.GetMinimumBalanceForRentExemption(context.Background(), system.NonceAccountSize)
+	if err != nil {
+		log.Fatalf("failed to get minimum balance for nonce account, err: %v", err)
+	}
+
+	// recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, nonceAccount},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      nonceAccount.PublicKey,
+					Owner:    common.SystemProgramID,
+					Lamports: nonceAccountMinimumBalance,
+					Space:    system.NonceAccountSize,
+				}),
+				system.InitializeNonceAccount(system.InitializeNonceAccountParam{
+					Nonce: nonceAccount.PublicKey,
+					Auth:  alice.PublicKey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Last Updated:
Contributors: yihau
+ + + diff --git a/advanced/durable-nonce/get-nonce-account-by-owner.html b/advanced/durable-nonce/get-nonce-account-by-owner.html new file mode 100644 index 00000000..c2be18d1 --- /dev/null +++ b/advanced/durable-nonce/get-nonce-account-by-owner.html @@ -0,0 +1,85 @@ + + + + + + + + + Get Nonce Account By Owner | Solana Development With Go + + + + +

Get Nonce Account By Owner

package main
+
+import (
+	"context"
+	"encoding/base64"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.RpcClient.GetProgramAccountsWithConfig(
+		context.Background(),
+		common.SystemProgramID.ToBase58(),
+		rpc.GetProgramAccountsConfig{
+			Encoding: rpc.AccountEncodingBase64,
+			Filters: []rpc.GetProgramAccountsConfigFilter{
+				{
+					DataSize: system.NonceAccountSize,
+				},
+				{
+					MemCmp: &rpc.GetProgramAccountsConfigFilterMemCmp{
+						Offset: 8,
+						Bytes:  "9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde", // owner address
+					},
+				},
+			},
+		},
+	)
+	if err != nil {
+		log.Fatalf("failed to get program accounts, err: %v", err)
+	}
+
+	for _, a := range res.Result {
+		fmt.Println("pubkey", a.Pubkey)
+		data, err := base64.StdEncoding.DecodeString((a.Account.Data.([]any))[0].(string))
+		if err != nil {
+			log.Fatalf("failed to decode data, err: %v", err)
+		}
+		nonceAccount, err := system.NonceAccountDeserialize(data)
+		if err != nil {
+			log.Fatalf("failed to parse nonce account, err: %v", err)
+		}
+		fmt.Printf("%+v\n", nonceAccount)
+	}
+}
+
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
51
52
Last Updated:
Contributors: yihau
+ + + diff --git a/advanced/durable-nonce/get-nonce-account.html b/advanced/durable-nonce/get-nonce-account.html new file mode 100644 index 00000000..610c2d35 --- /dev/null +++ b/advanced/durable-nonce/get-nonce-account.html @@ -0,0 +1,84 @@ + + + + + + + + + Get Nonce Account | Solana Development With Go + + + + +

Get Nonce Account

Nonce Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
+	nonceAccount, err := c.GetNonceAccount(context.Background(), nonceAccountAddr)
+	if err != nil {
+		log.Fatalf("failed to get nonce account, err: %v", err)
+	}
+	fmt.Printf("%+v\n", nonceAccount)
+	/*
+		type NonceAccount struct {
+			Version          uint32
+			State            uint32
+			AuthorizedPubkey common.PublicKey
+			Nonce            common.PublicKey
+			FeeCalculator    FeeCalculator
+		}
+	*/
+}
+
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

Only Nonce

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
+	nonce, err := c.GetNonceFromNonceAccount(context.Background(), nonceAccountAddr)
+	if err != nil {
+		log.Fatalf("failed to get nonce account, err: %v", err)
+	}
+
+	fmt.Println("nonce", nonce)
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Last Updated:
Contributors: yihau
+ + + diff --git a/advanced/durable-nonce/index.html b/advanced/durable-nonce/index.html new file mode 100644 index 00000000..c14f8d69 --- /dev/null +++ b/advanced/durable-nonce/index.html @@ -0,0 +1,33 @@ + + + + + + + + + Durable Nonce | Solana Development With Go + + + + +

Durable Nonce

A transaction includes a recent blockhash. The recent blockhash will expire after 150 blocks. (arpox. 2 min) To get rid of it, you can use durable nonce.

Mechanism

We can trigger the mechanism by

  1. use the nonce which stored in a nonce account as a recent blockhash
  2. make nonce advance instruction is the first instruciton
Last Updated:
Contributors: yihau
+ + + diff --git a/advanced/durable-nonce/upgrade-nonce.html b/advanced/durable-nonce/upgrade-nonce.html new file mode 100644 index 00000000..4944e8b7 --- /dev/null +++ b/advanced/durable-nonce/upgrade-nonce.html @@ -0,0 +1,141 @@ + + + + + + + + + Upgrade Nonce | Solana Development With Go + + + + +

Upgrade Nonce

Due to 2022/06/01 Solana outageopen in new window. All nonce account should be upgraded. You can update it either

  1. Advance Nonce (need origin authority signature)
package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// get nonce account
+	nonceAccountPubkey := common.PublicKeyFromString("5Covh7EB4HtC5ieeP7GwUH9AHySMmNicBmvXo534wEA8")
+
+	// recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.AdvanceNonceAccount(system.AdvanceNonceAccountParam{
+					Nonce: nonceAccountPubkey,
+					Auth:  alice.PublicKey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
52
53
54
55
56
57
  1. Upgrade Nonce (you can use a random fee payer)
package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	nonceAccountPubkey := common.PublicKeyFromString("DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx")
+
+	// recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.UpgradeNonceAccount(system.UpgradeNonceAccountParam{
+					NonceAccountPubkey: nonceAccountPubkey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
Last Updated:
Contributors: yihau
+ + + diff --git a/advanced/durable-nonce/use-nonce.html b/advanced/durable-nonce/use-nonce.html new file mode 100644 index 00000000..a90f779f --- /dev/null +++ b/advanced/durable-nonce/use-nonce.html @@ -0,0 +1,92 @@ + + + + + + + + + Use Nonce | Solana Development With Go + + + + +

Use Nonce

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/memo"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// get nonce account
+	nonceAccountPubkey := common.PublicKeyFromString("DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx")
+	nonceAccount, err := c.GetNonceAccount(context.Background(), nonceAccountPubkey.ToBase58())
+	if err != nil {
+		log.Fatalf("failed to get nonce account, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: nonceAccount.Nonce.ToBase58(),
+			Instructions: []types.Instruction{
+				system.AdvanceNonceAccount(system.AdvanceNonceAccountParam{
+					Nonce: nonceAccountPubkey,
+					Auth:  alice.PublicKey,
+				}),
+				memo.BuildMemo(memo.BuildMemoParam{
+					Memo: []byte("use nonce"),
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
52
53
54
55
56
57
58
59

TIP

You need to query nonce again after you used.

Last Updated:
Contributors: yihau
+ + + diff --git a/advanced/memo.html b/advanced/memo.html new file mode 100644 index 00000000..9b04f23f --- /dev/null +++ b/advanced/memo.html @@ -0,0 +1,88 @@ + + + + + + + + + Add Memo | Solana Development With Go + + + + +

Add Memo

You can add a memo to your transaction by memo instruction

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/memo"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// to fetch recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				// memo instruction
+				memo.BuildMemo(memo.BuildMemoParam{
+					SignerPubkeys: []common.PublicKey{alice.PublicKey},
+					Memo:          []byte("🐳"),
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	// send tx
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
Last Updated:
Contributors: yihau
+ + + diff --git a/assets/404.2fa22a2d.js b/assets/404.2fa22a2d.js new file mode 100644 index 00000000..513df281 --- /dev/null +++ b/assets/404.2fa22a2d.js @@ -0,0 +1 @@ +import{f as i,u as _,g as p,r as f,o as k,c as v,a as o,t as c,b as L,w as g,h as l,d as x}from"./app.aa4fcc9f.js";const B={class:"theme-container"},N={class:"theme-default-content"},T=o("h1",null,"404",-1),V=i({setup(b){var a,s,n;const u=_(),e=p(),t=(a=e.value.notFound)!=null?a:["Not Found"],r=()=>t[Math.floor(Math.random()*t.length)],h=(s=e.value.home)!=null?s:u.value,m=(n=e.value.backToHome)!=null?n:"Back to home";return(C,M)=>{const d=f("RouterLink");return k(),v("div",B,[o("div",N,[T,o("blockquote",null,c(r()),1),L(d,{to:l(h)},{default:g(()=>[x(c(l(m)),1)]),_:1},8,["to"])])])}}});export{V as default}; diff --git a/assets/404.html.ca9a1c30.js b/assets/404.html.ca9a1c30.js new file mode 100644 index 00000000..91796f97 --- /dev/null +++ b/assets/404.html.ca9a1c30.js @@ -0,0 +1 @@ +import{_ as r}from"./app.aa4fcc9f.js";const _={};function e(t,c){return null}var a=r(_,[["render",e]]);export{a as default}; diff --git a/assets/404.html.e275e9a9.js b/assets/404.html.e275e9a9.js new file mode 100644 index 00000000..fa2a247a --- /dev/null +++ b/assets/404.html.e275e9a9.js @@ -0,0 +1 @@ +const t={key:"v-3706649a",path:"/404.html",title:"",lang:"en-US",frontmatter:{layout:"404"},excerpt:"",headers:[],git:{},filePathRelative:null};export{t as data}; diff --git a/assets/Layout.18d821ba.js b/assets/Layout.18d821ba.js new file mode 100644 index 00000000..14ab45db --- /dev/null +++ b/assets/Layout.18d821ba.js @@ -0,0 +1 @@ +var Be=Object.defineProperty,Me=Object.defineProperties;var De=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var Ne=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var ve=(l,t,e)=>t in l?Be(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,X=(l,t)=>{for(var e in t||(t={}))Ne.call(t,e)&&ve(l,e,t[e]);if(de)for(var e of de(t))Ee.call(t,e)&&ve(l,e,t[e]);return l},Y=(l,t)=>Me(l,De(t));import{_ as Ie,r as R,o as a,c,b as $,f as x,i as I,j as p,k as _e,h as n,F as D,l as A,m as w,a as g,t as T,n as G,p as J,q as C,w as B,s as pe,v as y,d as U,x as q,y as Pe,z as Re,A as Ae,B as Q,C as Z,D as V,E as fe,G as me,H as P,u as be,g as M,T as ge,I as O,J as He,K as j,L as K,M as Oe,N as ze,O as ee,P as ke,Q as $e,e as Fe,R as Le,S as We,U as W,V as te,W as Ue,X as Ve,Y as je,Z as Ke}from"./app.aa4fcc9f.js";const Ge={},qe={class:"theme-default-content custom"};function Xe(l,t){const e=R("Content");return a(),c("div",qe,[$(e)])}var Ye=Ie(Ge,[["render",Xe]]);const Je={key:0,class:"features"},Qe=x({setup(l){const t=I(),e=p(()=>_e(t.value.features)?t.value.features:[]);return(i,r)=>n(e).length?(a(),c("div",Je,[(a(!0),c(D,null,A(n(e),_=>(a(),c("div",{key:_.title,class:"feature"},[g("h2",null,T(_.title),1),g("p",null,T(_.details),1)]))),128))])):w("",!0)}}),Ze=["innerHTML"],et=["textContent"],tt=x({setup(l){const t=I(),e=p(()=>t.value.footer),i=p(()=>t.value.footerHtml);return(r,_)=>n(e)?(a(),c(D,{key:0},[n(i)?(a(),c("div",{key:0,class:"footer",innerHTML:n(e)},null,8,Ze)):(a(),c("div",{key:1,class:"footer",textContent:T(n(e))},null,8,et))],64)):w("",!0)}}),nt=["href","rel","target","aria-label"],at=x({inheritAttrs:!1}),E=x(Y(X({},at),{props:{item:{type:Object,required:!0}},setup(l){const t=l,e=G(),i=Ae(),{item:r}=J(t),_=p(()=>q(r.value.link)),f=p(()=>Pe(r.value.link)||Re(r.value.link)),h=p(()=>{if(!f.value){if(r.value.target)return r.value.target;if(_.value)return"_blank"}}),s=p(()=>h.value==="_blank"),o=p(()=>!_.value&&!f.value&&!s.value),u=p(()=>{if(!f.value){if(r.value.rel)return r.value.rel;if(s.value)return"noopener noreferrer"}}),d=p(()=>r.value.ariaLabel||r.value.text),v=p(()=>{const L=Object.keys(i.value.locales);return L.length?!L.some(m=>m===r.value.link):r.value.link!=="/"}),b=p(()=>v.value?e.path.startsWith(r.value.link):!1),k=p(()=>o.value?r.value.activeMatch?new RegExp(r.value.activeMatch).test(e.path):b.value:!1);return(L,m)=>{const S=R("RouterLink"),N=R("ExternalLinkIcon");return n(o)?(a(),C(S,pe({key:0,class:{"router-link-active":n(k)},to:n(r).link,"aria-label":n(d)},L.$attrs),{default:B(()=>[y(L.$slots,"before"),U(" "+T(n(r).text)+" ",1),y(L.$slots,"after")]),_:3},16,["class","to","aria-label"])):(a(),c("a",pe({key:1,class:"external-link",href:n(r).link,rel:n(u),target:n(h),"aria-label":n(d)},L.$attrs),[y(L.$slots,"before"),U(" "+T(n(r).text)+" ",1),n(s)?(a(),C(N,{key:0})):w("",!0),y(L.$slots,"after")],16,nt))}}})),st={class:"hero"},rt={key:0,id:"main-title"},ot={key:1,class:"description"},lt={key:2,class:"actions"},ut=x({setup(l){const t=I(),e=Q(),i=Z(),r=p(()=>i.value&&t.value.heroImageDark!==void 0?t.value.heroImageDark:t.value.heroImage),_=p(()=>t.value.heroText===null?null:t.value.heroText||e.value.title||"Hello"),f=p(()=>t.value.heroAlt||_.value||"hero"),h=p(()=>t.value.tagline===null?null:t.value.tagline||e.value.description||"Welcome to your VuePress site"),s=p(()=>_e(t.value.actions)?t.value.actions.map(({text:u,link:d,type:v="primary"})=>({text:u,link:d,type:v})):[]),o=()=>{if(!r.value)return null;const u=V("img",{src:fe(r.value),alt:f.value});return t.value.heroImageDark===void 0?u:V(me,u)};return(u,d)=>(a(),c("header",st,[$(o),n(_)?(a(),c("h1",rt,T(n(_)),1)):w("",!0),n(h)?(a(),c("p",ot,T(n(h)),1)):w("",!0),n(s).length?(a(),c("p",lt,[(a(!0),c(D,null,A(n(s),v=>(a(),C(E,{key:v.text,class:P(["action-button",[v.type]]),item:v},null,8,["class","item"]))),128))])):w("",!0)]))}}),it={class:"home"},ct=x({setup(l){return(t,e)=>(a(),c("main",it,[$(ut),$(Qe),$(Ye),$(tt)]))}}),dt=x({setup(l){const t=be(),e=Q(),i=M(),r=Z(),_=p(()=>i.value.home||t.value),f=p(()=>e.value.title),h=p(()=>r.value&&i.value.logoDark!==void 0?i.value.logoDark:i.value.logo),s=()=>{if(!h.value)return null;const o=V("img",{class:"logo",src:fe(h.value),alt:f.value});return i.value.logoDark===void 0?o:V(me,o)};return(o,u)=>{const d=R("RouterLink");return a(),C(d,{to:n(_)},{default:B(()=>[$(s),n(f)?(a(),c("span",{key:0,class:P(["site-name",{"can-hide":n(h)}])},T(n(f)),3)):w("",!0)]),_:1},8,["to"])}}}),ye=x({setup(l){const t=i=>{i.style.height=i.scrollHeight+"px"},e=i=>{i.style.height=""};return(i,r)=>(a(),C(ge,{name:"dropdown",onEnter:t,onAfterEnter:e,onBeforeLeave:t},{default:B(()=>[y(i.$slots,"default")]),_:3}))}}),vt=["aria-label"],pt={class:"title"},ht=g("span",{class:"arrow down"},null,-1),_t=["aria-label"],ft={class:"title"},mt={class:"navbar-dropdown"},bt={class:"navbar-dropdown-subtitle"},gt={key:1},kt={class:"navbar-dropdown-subitem-wrapper"},$t=x({props:{item:{type:Object,required:!0}},setup(l){const t=l,{item:e}=J(t),i=p(()=>e.value.ariaLabel||e.value.text),r=O(!1),_=G();He(()=>_.path,()=>{r.value=!1});const f=s=>{s.detail===0?r.value=!r.value:r.value=!1},h=(s,o)=>o[o.length-1]===s;return(s,o)=>(a(),c("div",{class:P(["navbar-dropdown-wrapper",{open:r.value}])},[g("button",{class:"navbar-dropdown-title",type:"button","aria-label":n(i),onClick:f},[g("span",pt,T(n(e).text),1),ht],8,vt),g("button",{class:"navbar-dropdown-title-mobile",type:"button","aria-label":n(i),onClick:o[0]||(o[0]=u=>r.value=!r.value)},[g("span",ft,T(n(e).text),1),g("span",{class:P(["arrow",r.value?"down":"right"])},null,2)],8,_t),$(ye,null,{default:B(()=>[j(g("ul",mt,[(a(!0),c(D,null,A(n(e).children,u=>(a(),c("li",{key:u.text,class:"navbar-dropdown-item"},[u.children?(a(),c(D,{key:0},[g("h4",bt,[u.link?(a(),C(E,{key:0,item:u,onFocusout:d=>h(u,n(e).children)&&u.children.length===0&&(r.value=!1)},null,8,["item","onFocusout"])):(a(),c("span",gt,T(u.text),1))]),g("ul",kt,[(a(!0),c(D,null,A(u.children,d=>(a(),c("li",{key:d.link,class:"navbar-dropdown-subitem"},[$(E,{item:d,onFocusout:v=>h(d,u.children)&&h(u,n(e).children)&&(r.value=!1)},null,8,["item","onFocusout"])]))),128))])],64)):(a(),C(E,{key:1,item:u,onFocusout:d=>h(u,n(e).children)&&(r.value=!1)},null,8,["item","onFocusout"]))]))),128))],512),[[K,r.value]])]),_:1})],2))}}),he=l=>decodeURI(l).replace(/#.*$/,"").replace(/(index)?\.(md|html)$/,""),Lt=(l,t)=>{if(t.hash===l)return!0;const e=he(t.path),i=he(l);return e===i},we=(l,t)=>l.link&&Lt(l.link,t)?!0:l.children?l.children.some(e=>we(e,t)):!1,xe=l=>!q(l)||/github\.com/.test(l)?"GitHub":/bitbucket\.org/.test(l)?"Bitbucket":/gitlab\.com/.test(l)?"GitLab":/gitee\.com/.test(l)?"Gitee":null,yt={GitHub:":repo/edit/:branch/:path",GitLab:":repo/-/edit/:branch/:path",Gitee:":repo/edit/:branch/:path",Bitbucket:":repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default"},wt=({docsRepo:l,editLinkPattern:t})=>{if(t)return t;const e=xe(l);return e!==null?yt[e]:null},xt=({docsRepo:l,docsBranch:t,docsDir:e,filePathRelative:i,editLinkPattern:r})=>{if(!i)return null;const _=wt({docsRepo:l,editLinkPattern:r});return _?_.replace(/:repo/,q(l)?l:`https://github.com/${l}`).replace(/:branch/,t).replace(/:path/,Oe(`${ze(e)}/${i}`)):null},Ct={key:0,class:"navbar-items"},Ce=x({setup(l){const t=()=>{const o=ee(),u=be(),d=Q(),v=M();return p(()=>{var S,N;const b=Object.keys(d.value.locales);if(b.length<2)return[];const k=o.currentRoute.value.path,L=o.currentRoute.value.fullPath;return[{text:(S=v.value.selectLanguageText)!=null?S:"unknown language",ariaLabel:(N=v.value.selectLanguageAriaLabel)!=null?N:"unkown language",children:b.map(H=>{var se,re,oe,le,ue,ie;const z=(re=(se=d.value.locales)==null?void 0:se[H])!=null?re:{},ne=(le=(oe=v.value.locales)==null?void 0:oe[H])!=null?le:{},ae=`${z.lang}`,Te=(ue=ne.selectLanguageName)!=null?ue:ae;let F;if(ae===d.value.lang)F=L;else{const ce=k.replace(u.value,H);o.getRoutes().some(Se=>Se.path===ce)?F=ce:F=(ie=ne.home)!=null?ie:H}return{text:Te,link:F}})}]})},e=()=>{const o=M(),u=p(()=>o.value.repo),d=p(()=>u.value?xe(u.value):null),v=p(()=>u.value&&!q(u.value)?`https://github.com/${u.value}`:u.value),b=p(()=>v.value?o.value.repoLabel?o.value.repoLabel:d.value===null?"Source":d.value:null);return p(()=>!v.value||!b.value?[]:[{text:b.value,link:v.value}])},i=o=>ke(o)?$e(o):o.children?Y(X({},o),{children:o.children.map(i)}):o,_=(()=>{const o=M();return p(()=>(o.value.navbar||[]).map(i))})(),f=t(),h=e(),s=p(()=>[..._.value,...f.value,...h.value]);return(o,u)=>n(s).length?(a(),c("nav",Ct,[(a(!0),c(D,null,A(n(s),d=>(a(),c("div",{key:d.text,class:"navbar-item"},[d.children?(a(),C($t,{key:0,item:d},null,8,["item"])):(a(),C(E,{key:1,item:d},null,8,["item"]))]))),128))])):w("",!0)}}),Tt=["title"],St={class:"icon",focusable:"false",viewBox:"0 0 32 32"},Bt=Fe('',9),Mt=[Bt],Dt={class:"icon",focusable:"false",viewBox:"0 0 32 32"},Nt=g("path",{d:"M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z",fill:"currentColor"},null,-1),Et=[Nt],It=x({setup(l){const t=M(),e=Z(),i=()=>{e.value=!e.value};return(r,_)=>(a(),c("button",{class:"toggle-dark-button",title:n(t).toggleDarkMode,onClick:i},[j((a(),c("svg",St,Mt,512)),[[K,!n(e)]]),j((a(),c("svg",Dt,Et,512)),[[K,n(e)]])],8,Tt))}}),Pt=["title"],Rt=g("div",{class:"icon","aria-hidden":"true"},[g("span"),g("span"),g("span")],-1),At=[Rt],Ht=x({emits:["toggle"],setup(l){const t=M();return(e,i)=>(a(),c("div",{class:"toggle-sidebar-button",title:n(t).toggleSidebar,"aria-expanded":"false",role:"button",tabindex:"0",onClick:i[0]||(i[0]=r=>e.$emit("toggle"))},At,8,Pt))}}),Ot=x({emits:["toggle-sidebar"],setup(l){const t=M(),e=O(null),i=O(null),r=O(0),_=p(()=>r.value?{maxWidth:r.value+"px"}:{}),f=p(()=>t.value.darkMode);Le(()=>{const o=h(e.value,"paddingLeft")+h(e.value,"paddingRight"),u=()=>{var d;window.innerWidth<=719?r.value=0:r.value=e.value.offsetWidth-o-(((d=i.value)==null?void 0:d.offsetWidth)||0)};u(),window.addEventListener("resize",u,!1),window.addEventListener("orientationchange",u,!1)});function h(s,o){var v,b,k;const u=(k=(b=(v=s==null?void 0:s.ownerDocument)==null?void 0:v.defaultView)==null?void 0:b.getComputedStyle(s,null))==null?void 0:k[o],d=Number.parseInt(u,10);return Number.isNaN(d)?0:d}return(s,o)=>{const u=R("NavbarSearch");return a(),c("header",{ref_key:"navbar",ref:e,class:"navbar"},[$(Ht,{onToggle:o[0]||(o[0]=d=>s.$emit("toggle-sidebar"))}),g("span",{ref_key:"navbarBrand",ref:i},[$(dt)],512),g("div",{class:"navbar-items-wrapper",style:We(n(_))},[y(s.$slots,"before"),$(Ce,{class:"can-hide"}),y(s.$slots,"after"),n(f)?(a(),C(It,{key:0})):w("",!0),$(u)],4)],512)}}}),zt={class:"page-meta"},Ft={key:0,class:"meta-item edit-link"},Wt={key:1,class:"meta-item last-updated"},Ut={class:"meta-item-label"},Vt={class:"meta-item-info"},jt={key:2,class:"meta-item contributors"},Kt={class:"meta-item-label"},Gt={class:"meta-item-info"},qt=["title"],Xt=U(", "),Yt=x({setup(l){const t=()=>{const s=M(),o=W(),u=I();return p(()=>{var N,H,z;if(!((H=(N=u.value.editLink)!=null?N:s.value.editLink)!=null?H:!0))return null;const{repo:v,docsRepo:b=v,docsBranch:k="main",docsDir:L="",editLinkText:m}=s.value;if(!b)return null;const S=xt({docsRepo:b,docsBranch:k,docsDir:L,filePathRelative:o.value.filePathRelative,editLinkPattern:(z=u.value.editLinkPattern)!=null?z:s.value.editLinkPattern});return S?{text:m!=null?m:"Edit this page",link:S}:null})},e=()=>{const s=M(),o=W(),u=I();return p(()=>{var b,k,L,m;return!((k=(b=u.value.lastUpdated)!=null?b:s.value.lastUpdated)!=null?k:!0)||!((L=o.value.git)==null?void 0:L.updatedTime)?null:new Date((m=o.value.git)==null?void 0:m.updatedTime).toLocaleString()})},i=()=>{const s=M(),o=W(),u=I();return p(()=>{var v,b,k,L;return((b=(v=u.value.contributors)!=null?v:s.value.contributors)!=null?b:!0)&&(L=(k=o.value.git)==null?void 0:k.contributors)!=null?L:null})},r=M(),_=t(),f=e(),h=i();return(s,o)=>{const u=R("ClientOnly");return a(),c("footer",zt,[n(_)?(a(),c("div",Ft,[$(E,{class:"meta-item-label",item:n(_)},null,8,["item"])])):w("",!0),n(f)?(a(),c("div",Wt,[g("span",Ut,T(n(r).lastUpdatedText)+": ",1),$(u,null,{default:B(()=>[g("span",Vt,T(n(f)),1)]),_:1})])):w("",!0),n(h)&&n(h).length?(a(),c("div",jt,[g("span",Kt,T(n(r).contributorsText)+": ",1),g("span",Gt,[(a(!0),c(D,null,A(n(h),(d,v)=>(a(),c(D,{key:v},[g("span",{class:"contributor",title:`email: ${d.email}`},T(d.name),9,qt),v!==n(h).length-1?(a(),c(D,{key:0},[Xt],64)):w("",!0)],64))),128))])])):w("",!0)])}}}),Jt={key:0,class:"page-nav"},Qt={class:"inner"},Zt={key:0,class:"prev"},en={key:1,class:"next"},tn=x({setup(l){const t=s=>s===!1?null:ke(s)?$e(s):Ue(s)?s:!1,e=(s,o,u)=>{const d=s.findIndex(v=>v.link===o);if(d!==-1){const v=s[d+u];return(v==null?void 0:v.link)?v:null}for(const v of s)if(v.children){const b=e(v.children,o,u);if(b)return b}return null},i=I(),r=te(),_=G(),f=p(()=>{const s=t(i.value.prev);return s!==!1?s:e(r.value,_.path,-1)}),h=p(()=>{const s=t(i.value.next);return s!==!1?s:e(r.value,_.path,1)});return(s,o)=>n(f)||n(h)?(a(),c("nav",Jt,[g("p",Qt,[n(f)?(a(),c("span",Zt,[$(E,{item:n(f)},null,8,["item"])])):w("",!0),n(h)?(a(),c("span",en,[$(E,{item:n(h)},null,8,["item"])])):w("",!0)])])):w("",!0)}}),nn={class:"page"},an={class:"theme-default-content"},sn=x({setup(l){return(t,e)=>{const i=R("Content");return a(),c("main",nn,[y(t.$slots,"top"),g("div",an,[$(i)]),$(Yt),$(tn),y(t.$slots,"bottom")])}}}),rn={class:"sidebar-item-children"},on=x({props:{item:{type:Object,required:!0},depth:{type:Number,required:!1,default:0}},setup(l){const t=l,{item:e,depth:i}=J(t),r=G(),_=ee(),f=p(()=>we(e.value,r)),h=p(()=>({"sidebar-item":!0,"sidebar-heading":i.value===0,active:f.value,collapsible:e.value.collapsible})),s=O(!0),o=O(void 0);return e.value.collapsible&&(s.value=f.value,o.value=()=>{s.value=!s.value},_.afterEach(()=>{s.value=f.value})),(u,d)=>{var b;const v=R("SidebarItem",!0);return a(),c("li",null,[n(e).link?(a(),C(E,{key:0,class:P(n(h)),item:n(e)},null,8,["class","item"])):(a(),c("p",{key:1,tabindex:"0",class:P(n(h)),onClick:d[0]||(d[0]=(...k)=>o.value&&o.value(...k)),onKeydown:d[1]||(d[1]=Ve((...k)=>o.value&&o.value(...k),["enter"]))},[U(T(n(e).text)+" ",1),n(e).collapsible?(a(),c("span",{key:0,class:P(["arrow",s.value?"down":"right"])},null,2)):w("",!0)],34)),((b=n(e).children)==null?void 0:b.length)?(a(),C(ye,{key:2},{default:B(()=>[j(g("ul",rn,[(a(!0),c(D,null,A(n(e).children,k=>(a(),C(v,{key:`${n(i)}${k.text}${k.link}`,item:k,depth:n(i)+1},null,8,["item","depth"]))),128))],512),[[K,s.value]])]),_:1})):w("",!0)])}}}),ln={key:0,class:"sidebar-items"},un=x({setup(l){const t=te();return(e,i)=>n(t).length?(a(),c("ul",ln,[(a(!0),c(D,null,A(n(t),r=>(a(),C(on,{key:r.link||r.text,item:r},null,8,["item"]))),128))])):w("",!0)}}),cn={class:"sidebar"},dn=x({setup(l){return(t,e)=>(a(),c("aside",cn,[$(Ce),y(t.$slots,"top"),$(un),y(t.$slots,"bottom")]))}}),hn=x({setup(l){const t=W(),e=I(),i=M(),r=p(()=>e.value.navbar!==!1&&i.value.navbar!==!1),_=te(),f=O(!1),h=m=>{f.value=typeof m=="boolean"?m:!f.value},s={x:0,y:0},o=m=>{s.x=m.changedTouches[0].clientX,s.y=m.changedTouches[0].clientY},u=m=>{const S=m.changedTouches[0].clientX-s.x,N=m.changedTouches[0].clientY-s.y;Math.abs(S)>Math.abs(N)&&Math.abs(S)>40&&(S>0&&s.x<=80?h(!0):h(!1))},d=p(()=>[{"no-navbar":!r.value,"no-sidebar":!_.value.length,"sidebar-open":f.value},e.value.pageClass]);let v;Le(()=>{v=ee().afterEach(()=>{h(!1)})}),je(()=>{v()});const b=Ke(),k=b.resolve,L=b.pending;return(m,S)=>(a(),c("div",{class:P(["theme-container",n(d)]),onTouchstart:o,onTouchend:u},[y(m.$slots,"navbar",{},()=>[n(r)?(a(),C(Ot,{key:0,onToggleSidebar:h},{before:B(()=>[y(m.$slots,"navbar-before")]),after:B(()=>[y(m.$slots,"navbar-after")]),_:3})):w("",!0)]),g("div",{class:"sidebar-mask",onClick:S[0]||(S[0]=N=>h(!1))}),y(m.$slots,"sidebar",{},()=>[$(dn,null,{top:B(()=>[y(m.$slots,"sidebar-top")]),bottom:B(()=>[y(m.$slots,"sidebar-bottom")]),_:3})]),y(m.$slots,"page",{},()=>[n(e).home?(a(),C(ct,{key:0})):(a(),C(ge,{key:1,name:"fade-slide-y",mode:"out-in",onBeforeEnter:n(k),onBeforeLeave:n(L)},{default:B(()=>[(a(),C(sn,{key:n(t).path},{top:B(()=>[y(m.$slots,"page-top")]),bottom:B(()=>[y(m.$slots,"page-bottom")]),_:3}))]),_:3},8,["onBeforeEnter","onBeforeLeave"]))])],34))}});export{hn as default}; diff --git a/assets/accounts.html.26bf1d29.js b/assets/accounts.html.26bf1d29.js new file mode 100644 index 00000000..95a8911c --- /dev/null +++ b/assets/accounts.html.26bf1d29.js @@ -0,0 +1 @@ +const e={key:"v-da536522",path:"/programs/101/accounts.html",title:"Accounts",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:3,title:"client",slug:"client",children:[]},{level:3,title:"program",slug:"program",children:[]}],git:{updatedTime:1685469006e3,contributors:[{name:"Yihau Chen",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"programs/101/accounts.md"};export{e as data}; diff --git a/assets/accounts.html.4d38c647.js b/assets/accounts.html.4d38c647.js new file mode 100644 index 00000000..23f54b84 --- /dev/null +++ b/assets/accounts.html.4d38c647.js @@ -0,0 +1,115 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Accounts

client

// an account meta list indicates which accounts will be used in a program.
+// we can only read/write accounts in progarms via this list.
+// (except some official vars)
+
+// an account meta includs
+//   - isSigner
+//     when an account is a signer. it needs to sign the tx.
+//   - isWritable
+//     when an account is writable. its data can be modified in this tx.
+
+package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+var programId = common.PublicKeyFromString("CDKLz6tftV4kSD8sPVBD6ACqZpDY4Zuxf8rgSEYzR4M2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get latest blockhash, err: %v\\n", err)
+	}
+
+	firstAccount := types.NewAccount()
+	fmt.Printf("first account: %v\\n", firstAccount.PublicKey)
+
+	secondAccount := types.NewAccount()
+	fmt.Printf("second account: %v\\n", secondAccount.PublicKey)
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, firstAccount},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				{
+					ProgramID: programId,
+					Accounts: []types.AccountMeta{
+						{
+							PubKey:     firstAccount.PublicKey,
+							IsSigner:   true,
+							IsWritable: false,
+						},
+						{
+							PubKey:     secondAccount.PublicKey,
+							IsSigner:   false,
+							IsWritable: true,
+						},
+					},
+					Data: []byte{},
+				},
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send the tx, err: %v", err)
+	}
+
+	// 4jYHKXhZMoDL3HsRuYhFPhCiQJhtNjDzPv8FhSnH6cMi9mwBjgW649uoqvfBjpGbkdFB53NEUux6oq3GUV8e9YQA
+	fmt.Println(sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

program

use solana_program::{
+    account_info::{next_account_info, AccountInfo},
+    entrypoint,
+    entrypoint::ProgramResult,
+    msg,
+    pubkey::Pubkey,
+};
+
+entrypoint!(process_instruction);
+
+fn process_instruction(
+    _program_id: &Pubkey,
+    accounts: &[AccountInfo],
+    _instruction_data: &[u8],
+) -> ProgramResult {
+    let account_info_iter = &mut accounts.iter();
+
+    let first_account_info = next_account_info(account_info_iter)?;
+    msg!(&format!(
+        "first: {} isSigner: {}, isWritable: {}",
+        first_account_info.key.to_string(),
+        first_account_info.is_signer,
+        first_account_info.is_writable,
+    ));
+
+    let second_account_info = next_account_info(account_info_iter)?;
+    msg!(&format!(
+        "second: {} isSigner: {}, isWritable: {}",
+        second_account_info.key.to_string(),
+        second_account_info.is_signer,
+        second_account_info.is_writable,
+    ));
+
+    Ok(())
+}
+
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
`,5);function p(c,o){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/app.aa4fcc9f.js b/assets/app.aa4fcc9f.js new file mode 100644 index 00000000..1adc76a8 --- /dev/null +++ b/assets/app.aa4fcc9f.js @@ -0,0 +1,8 @@ +var dl=Object.defineProperty,pl=Object.defineProperties;var hl=Object.getOwnPropertyDescriptors;var Co=Object.getOwnPropertySymbols;var ml=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable;var Ao=(e,t,n)=>t in e?dl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,We=(e,t)=>{for(var n in t||(t={}))ml.call(t,n)&&Ao(e,n,t[n]);if(Co)for(var n of Co(t))gl.call(t,n)&&Ao(e,n,t[n]);return e},Sn=(e,t)=>pl(e,hl(t));const yo={};function Vr(e,t){const n=Object.create(null),r=e.split(",");for(let o=0;o!!n[o.toLowerCase()]:o=>!!n[o]}const vl="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",_l=Vr(vl);function Ss(e){return!!e||e===""}function $t(e){if(J(e)){const t={};for(let n=0;n{if(n){const r=n.split(yl);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t}function Rt(e){let t="";if(pe(e))t=e;else if(J(e))for(let n=0;npe(e)?e:e==null?"":J(e)||be(e)&&(e.toString===Is||!ee(e.toString))?JSON.stringify(e,Os,2):String(e),Os=(e,t)=>t&&t.__v_isRef?Os(e,t.value):Ft(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[r,o])=>(n[`${r} =>`]=o,n),{})}:ks(t)?{[`Set(${t.size})`]:[...t.values()]}:be(t)&&!J(t)&&!Bs(t)?String(t):t,de={},Ht=[],Ue=()=>{},wl=()=>!1,Tl=/^on[^a-z]/,Tn=e=>Tl.test(e),jr=e=>e.startsWith("onUpdate:"),Ce=Object.assign,Ur=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},Cl=Object.prototype.hasOwnProperty,se=(e,t)=>Cl.call(e,t),J=Array.isArray,Ft=e=>Xn(e)==="[object Map]",ks=e=>Xn(e)==="[object Set]",ee=e=>typeof e=="function",pe=e=>typeof e=="string",qr=e=>typeof e=="symbol",be=e=>e!==null&&typeof e=="object",Ls=e=>be(e)&&ee(e.then)&&ee(e.catch),Is=Object.prototype.toString,Xn=e=>Is.call(e),Al=e=>Xn(e).slice(8,-1),Bs=e=>Xn(e)==="[object Object]",Kr=e=>pe(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,an=Vr(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),er=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},xl=/-(\w)/g,Qe=er(e=>e.replace(xl,(t,n)=>n?n.toUpperCase():"")),Pl=/\B([A-Z])/g,Ot=er(e=>e.replace(Pl,"-$1").toLowerCase()),tr=er(e=>e.charAt(0).toUpperCase()+e.slice(1)),ur=er(e=>e?`on${tr(e)}`:""),gn=(e,t)=>!Object.is(e,t),fr=(e,t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},Ds=e=>{const t=parseFloat(e);return isNaN(t)?e:t};let xo;const Sl=()=>xo||(xo=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{});let Fe;class Rl{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&Fe&&(this.parent=Fe,this.index=(Fe.scopes||(Fe.scopes=[])).push(this)-1)}run(t){if(this.active)try{return Fe=this,t()}finally{Fe=this.parent}}on(){Fe=this}off(){Fe=this.parent}stop(t){if(this.active){let n,r;for(n=0,r=this.effects.length;n{const t=new Set(e);return t.w=0,t.n=0,t},Ms=e=>(e.w&ht)>0,Ns=e=>(e.n&ht)>0,Il=({deps:e})=>{if(e.length)for(let t=0;t{const{deps:t}=e;if(t.length){let n=0;for(let r=0;r{(c==="length"||c>=r)&&l.push(a)});else switch(n!==void 0&&l.push(i.get(n)),t){case"add":J(e)?Kr(n)&&l.push(i.get("length")):(l.push(i.get(Ct)),Ft(e)&&l.push(i.get(Ar)));break;case"delete":J(e)||(l.push(i.get(Ct)),Ft(e)&&l.push(i.get(Ar)));break;case"set":Ft(e)&&l.push(i.get(Ct));break}if(l.length===1)l[0]&&xr(l[0]);else{const a=[];for(const c of l)c&&a.push(...c);xr(Wr(a))}}function xr(e,t){for(const n of J(e)?e:[...e])(n!==Ye||n.allowRecurse)&&(n.scheduler?n.scheduler():n.run())}const Dl=Vr("__proto__,__v_isRef,__isVue"),zs=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(qr)),Ml=Yr(),Nl=Yr(!1,!0),Hl=Yr(!0),So=Fl();function Fl(){const e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...n){const r=ie(this);for(let s=0,i=this.length;s{e[t]=function(...n){Gt();const r=ie(this)[t].apply(this,n);return Yt(),r}}),e}function Yr(e=!1,t=!1){return function(r,o,s){if(o==="__v_isReactive")return!e;if(o==="__v_isReadonly")return e;if(o==="__v_isShallow")return t;if(o==="__v_raw"&&s===(e?t?ta:qs:t?Us:js).get(r))return r;const i=J(r);if(!e&&i&&se(So,o))return Reflect.get(So,o,s);const l=Reflect.get(r,o,s);return(qr(o)?zs.has(o):Dl(o))||(e||De(r,"get",o),t)?l:we(l)?!i||!Kr(o)?l.value:l:be(l)?e?Zr(l):Jt(l):l}}const zl=$s(),$l=$s(!0);function $s(e=!1){return function(n,r,o,s){let i=n[r];if(vn(i)&&we(i)&&!we(o))return!1;if(!e&&!vn(o)&&(Ks(o)||(o=ie(o),i=ie(i)),!J(n)&&we(i)&&!we(o)))return i.value=o,!0;const l=J(n)&&Kr(r)?Number(r)e,nr=e=>Reflect.getPrototypeOf(e);function Rn(e,t,n=!1,r=!1){e=e.__v_raw;const o=ie(e),s=ie(t);t!==s&&!n&&De(o,"get",t),!n&&De(o,"get",s);const{has:i}=nr(o),l=r?Jr:n?eo:_n;if(i.call(o,t))return l(e.get(t));if(i.call(o,s))return l(e.get(s));e!==o&&e.get(t)}function On(e,t=!1){const n=this.__v_raw,r=ie(n),o=ie(e);return e!==o&&!t&&De(r,"has",e),!t&&De(r,"has",o),e===o?n.has(e):n.has(e)||n.has(o)}function kn(e,t=!1){return e=e.__v_raw,!t&&De(ie(e),"iterate",Ct),Reflect.get(e,"size",e)}function Ro(e){e=ie(e);const t=ie(this);return nr(t).has.call(t,e)||(t.add(e),nt(t,"add",e,e)),this}function Oo(e,t){t=ie(t);const n=ie(this),{has:r,get:o}=nr(n);let s=r.call(n,e);s||(e=ie(e),s=r.call(n,e));const i=o.call(n,e);return n.set(e,t),s?gn(t,i)&&nt(n,"set",e,t):nt(n,"add",e,t),this}function ko(e){const t=ie(this),{has:n,get:r}=nr(t);let o=n.call(t,e);o||(e=ie(e),o=n.call(t,e)),r&&r.call(t,e);const s=t.delete(e);return o&&nt(t,"delete",e,void 0),s}function Lo(){const e=ie(this),t=e.size!==0,n=e.clear();return t&&nt(e,"clear",void 0,void 0),n}function Ln(e,t){return function(r,o){const s=this,i=s.__v_raw,l=ie(i),a=t?Jr:e?eo:_n;return!e&&De(l,"iterate",Ct),i.forEach((c,f)=>r.call(o,a(c),a(f),s))}}function In(e,t,n){return function(...r){const o=this.__v_raw,s=ie(o),i=Ft(s),l=e==="entries"||e===Symbol.iterator&&i,a=e==="keys"&&i,c=o[e](...r),f=n?Jr:t?eo:_n;return!t&&De(s,"iterate",a?Ar:Ct),{next(){const{value:m,done:d}=c.next();return d?{value:m,done:d}:{value:l?[f(m[0]),f(m[1])]:f(m),done:d}},[Symbol.iterator](){return this}}}}function ot(e){return function(...t){return e==="delete"?!1:this}}function Wl(){const e={get(s){return Rn(this,s)},get size(){return kn(this)},has:On,add:Ro,set:Oo,delete:ko,clear:Lo,forEach:Ln(!1,!1)},t={get(s){return Rn(this,s,!1,!0)},get size(){return kn(this)},has:On,add:Ro,set:Oo,delete:ko,clear:Lo,forEach:Ln(!1,!0)},n={get(s){return Rn(this,s,!0)},get size(){return kn(this,!0)},has(s){return On.call(this,s,!0)},add:ot("add"),set:ot("set"),delete:ot("delete"),clear:ot("clear"),forEach:Ln(!0,!1)},r={get(s){return Rn(this,s,!0,!0)},get size(){return kn(this,!0)},has(s){return On.call(this,s,!0)},add:ot("add"),set:ot("set"),delete:ot("delete"),clear:ot("clear"),forEach:Ln(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(s=>{e[s]=In(s,!1,!1),n[s]=In(s,!0,!1),t[s]=In(s,!1,!0),r[s]=In(s,!0,!0)}),[e,n,t,r]}const[Gl,Yl,Jl,Ql]=Wl();function Qr(e,t){const n=t?e?Ql:Jl:e?Yl:Gl;return(r,o,s)=>o==="__v_isReactive"?!e:o==="__v_isReadonly"?e:o==="__v_raw"?r:Reflect.get(se(n,o)&&o in r?n:r,o,s)}const Zl={get:Qr(!1,!1)},Xl={get:Qr(!1,!0)},ea={get:Qr(!0,!1)},js=new WeakMap,Us=new WeakMap,qs=new WeakMap,ta=new WeakMap;function na(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function ra(e){return e.__v_skip||!Object.isExtensible(e)?0:na(Al(e))}function Jt(e){return vn(e)?e:Xr(e,!1,Vs,Zl,js)}function oa(e){return Xr(e,!1,Kl,Xl,Us)}function Zr(e){return Xr(e,!0,ql,ea,qs)}function Xr(e,t,n,r,o){if(!be(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const s=o.get(e);if(s)return s;const i=ra(e);if(i===0)return e;const l=new Proxy(e,i===2?r:n);return o.set(e,l),l}function zt(e){return vn(e)?zt(e.__v_raw):!!(e&&e.__v_isReactive)}function vn(e){return!!(e&&e.__v_isReadonly)}function Ks(e){return!!(e&&e.__v_isShallow)}function Ws(e){return zt(e)||vn(e)}function ie(e){const t=e&&e.__v_raw;return t?ie(t):e}function Gs(e){return Fn(e,"__v_skip",!0),e}const _n=e=>be(e)?Jt(e):e,eo=e=>be(e)?Zr(e):e;function Ys(e){dt&&Ye&&(e=ie(e),Fs(e.dep||(e.dep=Wr())))}function Js(e,t){e=ie(e),e.dep&&xr(e.dep)}function we(e){return!!(e&&e.__v_isRef===!0)}function Pe(e){return Zs(e,!1)}function Qs(e){return Zs(e,!0)}function Zs(e,t){return we(e)?e:new sa(e,t)}class sa{constructor(t,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?t:ie(t),this._value=n?t:_n(t)}get value(){return Ys(this),this._value}set value(t){t=this.__v_isShallow?t:ie(t),gn(t,this._rawValue)&&(this._rawValue=t,this._value=this.__v_isShallow?t:_n(t),Js(this))}}function At(e){return we(e)?e.value:e}const ia={get:(e,t,n)=>At(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return we(o)&&!we(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function Xs(e){return zt(e)?e:new Proxy(e,ia)}function np(e){const t=J(e)?new Array(e.length):{};for(const n in e)t[n]=aa(e,n);return t}class la{constructor(t,n,r){this._object=t,this._key=n,this._defaultValue=r,this.__v_isRef=!0}get value(){const t=this._object[this._key];return t===void 0?this._defaultValue:t}set value(t){this._object[this._key]=t}}function aa(e,t,n){const r=e[t];return we(r)?r:new la(e,t,n)}class ca{constructor(t,n,r,o){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this._dirty=!0,this.effect=new Gr(t,()=>{this._dirty||(this._dirty=!0,Js(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!o,this.__v_isReadonly=r}get value(){const t=ie(this);return Ys(t),(t._dirty||!t._cacheable)&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ua(e,t,n=!1){let r,o;const s=ee(e);return s?(r=e,o=Ue):(r=e.get,o=e.set),new ca(r,o,s||!o,n)}Promise.resolve();function pt(e,t,n,r){let o;try{o=r?e(...r):e()}catch(s){Cn(s,t,n)}return o}function ze(e,t,n,r){if(ee(e)){const s=pt(e,t,n,r);return s&&Ls(s)&&s.catch(i=>{Cn(i,t,n)}),s}const o=[];for(let s=0;s>>1;bn(Ie[r])et&&Ie.splice(t,1)}function ni(e,t,n,r){J(e)?n.push(...e):(!t||!t.includes(e,e.allowRecurse?r+1:r))&&n.push(e),ti()}function ha(e){ni(e,ln,cn,Dt)}function ma(e){ni(e,at,un,Mt)}function oo(e,t=null){if(cn.length){for(Sr=t,ln=[...new Set(cn)],cn.length=0,Dt=0;Dtbn(n)-bn(r)),Mt=0;Mte.id==null?1/0:e.id;function ri(e){Pr=!1,zn=!0,oo(e),Ie.sort((n,r)=>bn(n)-bn(r));const t=Ue;try{for(et=0;etE.trim()):m&&(o=n.map(Ds))}let l,a=r[l=ur(t)]||r[l=ur(Qe(t))];!a&&s&&(a=r[l=ur(Ot(t))]),a&&ze(a,e,6,o);const c=r[l+"Once"];if(c){if(!e.emitted)e.emitted={};else if(e.emitted[l])return;e.emitted[l]=!0,ze(c,e,6,o)}}function oi(e,t,n=!1){const r=t.emitsCache,o=r.get(e);if(o!==void 0)return o;const s=e.emits;let i={},l=!1;if(!ee(e)){const a=c=>{const f=oi(c,t,!0);f&&(l=!0,Ce(i,f))};!n&&t.mixins.length&&t.mixins.forEach(a),e.extends&&a(e.extends),e.mixins&&e.mixins.forEach(a)}return!s&&!l?(r.set(e,null),null):(J(s)?s.forEach(a=>i[a]=null):Ce(i,s),r.set(e,i),i)}function so(e,t){return!e||!Tn(t)?!1:(t=t.slice(2).replace(/Once$/,""),se(e,t[0].toLowerCase()+t.slice(1))||se(e,Ot(t))||se(e,t))}let Be=null,rr=null;function Vn(e){const t=Be;return Be=e,rr=e&&e.type.__scopeId||null,t}function va(e){rr=e}function _a(){rr=null}function ba(e,t=Be,n){if(!t||e._n)return e;const r=(...o)=>{r._d&&jo(-1);const s=Vn(t),i=e(...o);return Vn(s),r._d&&jo(1),i};return r._n=!0,r._c=!0,r._d=!0,r}function dr(e){const{type:t,vnode:n,proxy:r,withProxy:o,props:s,propsOptions:[i],slots:l,attrs:a,emit:c,render:f,renderCache:m,data:d,setupState:E,ctx:p,inheritAttrs:b}=e;let g,v;const T=Vn(e);try{if(n.shapeFlag&4){const O=o||r;g=je(f.call(O,O,m,s,E,d,p)),v=a}else{const O=t;g=je(O.length>1?O(s,{attrs:a,slots:l,emit:c}):O(s,null)),v=t.props?a:ya(a)}}catch(O){dn.length=0,Cn(O,e,1),g=_e($e)}let S=g;if(v&&b!==!1){const O=Object.keys(v),{shapeFlag:H}=S;O.length&&H&7&&(i&&O.some(jr)&&(v=Ea(v,i)),S=jt(S,v))}return n.dirs&&(S.dirs=S.dirs?S.dirs.concat(n.dirs):n.dirs),n.transition&&(S.transition=n.transition),g=S,Vn(T),g}const ya=e=>{let t;for(const n in e)(n==="class"||n==="style"||Tn(n))&&((t||(t={}))[n]=e[n]);return t},Ea=(e,t)=>{const n={};for(const r in e)(!jr(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function wa(e,t,n){const{props:r,children:o,component:s}=e,{props:i,children:l,patchFlag:a}=t,c=s.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&a>=0){if(a&1024)return!0;if(a&16)return r?Io(r,i,c):!!i;if(a&8){const f=t.dynamicProps;for(let m=0;me.__isSuspense;function si(e,t){t&&t.pendingBranch?J(e)?t.effects.push(...e):t.effects.push(e):ma(e)}function xt(e,t){if(Ee){let n=Ee.provides;const r=Ee.parent&&Ee.parent.provides;r===n&&(n=Ee.provides=Object.create(r)),n[e]=t}}function Te(e,t,n=!1){const r=Ee||Be;if(r){const o=r.parent==null?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides;if(o&&e in o)return o[e];if(arguments.length>1)return n&&ee(t)?t.call(r.proxy):t}}const Bo={};function Je(e,t,n){return ii(e,t,n)}function ii(e,t,{immediate:n,deep:r,flush:o,onTrack:s,onTrigger:i}=de){const l=Ee;let a,c=!1,f=!1;if(we(e)?(a=()=>e.value,c=Ks(e)):zt(e)?(a=()=>e,r=!0):J(e)?(f=!0,c=e.some(zt),a=()=>e.map(v=>{if(we(v))return v.value;if(zt(v))return Tt(v);if(ee(v))return pt(v,l,2)})):ee(e)?t?a=()=>pt(e,l,2):a=()=>{if(!(l&&l.isUnmounted))return m&&m(),ze(e,l,3,[d])}:a=Ue,t&&r){const v=a;a=()=>Tt(v())}let m,d=v=>{m=g.onStop=()=>{pt(v,l,4)}};if(qt)return d=Ue,t?n&&ze(t,l,3,[a(),f?[]:void 0,d]):a(),Ue;let E=f?[]:Bo;const p=()=>{if(!!g.active)if(t){const v=g.run();(r||c||(f?v.some((T,S)=>gn(T,E[S])):gn(v,E)))&&(m&&m(),ze(t,l,3,[v,E===Bo?void 0:E,d]),E=v)}else g.run()};p.allowRecurse=!!t;let b;o==="sync"?b=p:o==="post"?b=()=>Re(p,l&&l.suspense):b=()=>{!l||l.isMounted?ha(p):p()};const g=new Gr(a,b);return t?n?p():E=g.run():o==="post"?Re(g.run.bind(g),l&&l.suspense):g.run(),()=>{g.stop(),l&&l.scope&&Ur(l.scope.effects,g)}}function Aa(e,t,n){const r=this.proxy,o=pe(e)?e.includes(".")?li(r,e):()=>r[e]:e.bind(r,r);let s;ee(t)?s=t:(s=t.handler,n=t);const i=Ee;Ut(this);const l=ii(o,s.bind(r),n);return i?Ut(i):St(),l}function li(e,t){const n=t.split(".");return()=>{let r=e;for(let o=0;o{Tt(n,t)});else if(Bs(e))for(const n in e)Tt(e[n],t);return e}function xa(){const e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return Ze(()=>{e.isMounted=!0}),sr(()=>{e.isUnmounting=!0}),e}const Ne=[Function,Array],Pa={name:"BaseTransition",props:{mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:Ne,onEnter:Ne,onAfterEnter:Ne,onEnterCancelled:Ne,onBeforeLeave:Ne,onLeave:Ne,onAfterLeave:Ne,onLeaveCancelled:Ne,onBeforeAppear:Ne,onAppear:Ne,onAfterAppear:Ne,onAppearCancelled:Ne},setup(e,{slots:t}){const n=Ri(),r=xa();let o;return()=>{const s=t.default&&ui(t.default(),!0);if(!s||!s.length)return;const i=ie(e),{mode:l}=i,a=s[0];if(r.isLeaving)return pr(a);const c=Do(a);if(!c)return pr(a);const f=Rr(c,i,r,n);Or(c,f);const m=n.subTree,d=m&&Do(m);let E=!1;const{getTransitionKey:p}=c.type;if(p){const b=p();o===void 0?o=b:b!==o&&(o=b,E=!0)}if(d&&d.type!==$e&&(!Et(c,d)||E)){const b=Rr(d,i,r,n);if(Or(d,b),l==="out-in")return r.isLeaving=!0,b.afterLeave=()=>{r.isLeaving=!1,n.update()},pr(a);l==="in-out"&&c.type!==$e&&(b.delayLeave=(g,v,T)=>{const S=ci(r,d);S[String(d.key)]=d,g._leaveCb=()=>{v(),g._leaveCb=void 0,delete f.delayedLeave},f.delayedLeave=T})}return a}}},ai=Pa;function ci(e,t){const{leavingVNodes:n}=e;let r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function Rr(e,t,n,r){const{appear:o,mode:s,persisted:i=!1,onBeforeEnter:l,onEnter:a,onAfterEnter:c,onEnterCancelled:f,onBeforeLeave:m,onLeave:d,onAfterLeave:E,onLeaveCancelled:p,onBeforeAppear:b,onAppear:g,onAfterAppear:v,onAppearCancelled:T}=t,S=String(e.key),O=ci(n,e),H=(x,w)=>{x&&ze(x,r,9,w)},j={mode:s,persisted:i,beforeEnter(x){let w=l;if(!n.isMounted)if(o)w=b||l;else return;x._leaveCb&&x._leaveCb(!0);const G=O[S];G&&Et(e,G)&&G.el._leaveCb&&G.el._leaveCb(),H(w,[x])},enter(x){let w=a,G=c,U=f;if(!n.isMounted)if(o)w=g||a,G=v||c,U=T||f;else return;let Y=!1;const y=x._enterCb=D=>{Y||(Y=!0,D?H(U,[x]):H(G,[x]),j.delayedLeave&&j.delayedLeave(),x._enterCb=void 0)};w?(w(x,y),w.length<=1&&y()):y()},leave(x,w){const G=String(e.key);if(x._enterCb&&x._enterCb(!0),n.isUnmounting)return w();H(m,[x]);let U=!1;const Y=x._leaveCb=y=>{U||(U=!0,w(),y?H(p,[x]):H(E,[x]),x._leaveCb=void 0,O[G]===e&&delete O[G])};O[G]=e,d?(d(x,Y),d.length<=1&&Y()):Y()},clone(x){return Rr(x,t,n,r)}};return j}function pr(e){if(An(e))return e=jt(e),e.children=null,e}function Do(e){return An(e)?e.children?e.children[0]:void 0:e}function Or(e,t){e.shapeFlag&6&&e.component?Or(e.component.subTree,t):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function ui(e,t=!1){let n=[],r=0;for(let o=0;o1)for(let o=0;o!!e.type.__asyncLoader;function oe(e){ee(e)&&(e={loader:e});const{loader:t,loadingComponent:n,errorComponent:r,delay:o=200,timeout:s,suspensible:i=!0,onError:l}=e;let a=null,c,f=0;const m=()=>(f++,a=null,d()),d=()=>{let E;return a||(E=a=t().catch(p=>{if(p=p instanceof Error?p:new Error(String(p)),l)return new Promise((b,g)=>{l(p,()=>b(m()),()=>g(p),f+1)});throw p}).then(p=>E!==a&&a?a:(p&&(p.__esModule||p[Symbol.toStringTag]==="Module")&&(p=p.default),c=p,p)))};return qe({name:"AsyncComponentWrapper",__asyncLoader:d,get __asyncResolved(){return c},setup(){const E=Ee;if(c)return()=>hr(c,E);const p=T=>{a=null,Cn(T,E,13,!r)};if(i&&E.suspense||qt)return d().then(T=>()=>hr(T,E)).catch(T=>(p(T),()=>r?_e(r,{error:T}):null));const b=Pe(!1),g=Pe(),v=Pe(!!o);return o&&setTimeout(()=>{v.value=!1},o),s!=null&&setTimeout(()=>{if(!b.value&&!g.value){const T=new Error(`Async component timed out after ${s}ms.`);p(T),g.value=T}},s),d().then(()=>{b.value=!0,E.parent&&An(E.parent.vnode)&&ro(E.parent.update)}).catch(T=>{p(T),g.value=T}),()=>{if(b.value&&c)return hr(c,E);if(g.value&&r)return _e(r,{error:g.value});if(n&&!v.value)return _e(n)}}})}function hr(e,{vnode:{ref:t,props:n,children:r}}){const o=_e(e,n,r);return o.ref=t,o}const An=e=>e.type.__isKeepAlive;function Sa(e,t){fi(e,"a",t)}function Ra(e,t){fi(e,"da",t)}function fi(e,t,n=Ee){const r=e.__wdc||(e.__wdc=()=>{let o=n;for(;o;){if(o.isDeactivated)return;o=o.parent}return e()});if(or(t,r,n),n){let o=n.parent;for(;o&&o.parent;)An(o.parent.vnode)&&Oa(r,t,n,o),o=o.parent}}function Oa(e,t,n,r){const o=or(t,e,r,!0);io(()=>{Ur(r[t],o)},n)}function or(e,t,n=Ee,r=!1){if(n){const o=n[e]||(n[e]=[]),s=t.__weh||(t.__weh=(...i)=>{if(n.isUnmounted)return;Gt(),Ut(n);const l=ze(t,n,e,i);return St(),Yt(),l});return r?o.unshift(s):o.push(s),s}}const rt=e=>(t,n=Ee)=>(!qt||e==="sp")&&or(e,t,n),ka=rt("bm"),Ze=rt("m"),La=rt("bu"),di=rt("u"),sr=rt("bum"),io=rt("um"),Ia=rt("sp"),Ba=rt("rtg"),Da=rt("rtc");function Ma(e,t=Ee){or("ec",e,t)}let kr=!0;function Na(e){const t=hi(e),n=e.proxy,r=e.ctx;kr=!1,t.beforeCreate&&Mo(t.beforeCreate,e,"bc");const{data:o,computed:s,methods:i,watch:l,provide:a,inject:c,created:f,beforeMount:m,mounted:d,beforeUpdate:E,updated:p,activated:b,deactivated:g,beforeDestroy:v,beforeUnmount:T,destroyed:S,unmounted:O,render:H,renderTracked:j,renderTriggered:x,errorCaptured:w,serverPrefetch:G,expose:U,inheritAttrs:Y,components:y,directives:D,filters:W}=t;if(c&&Ha(c,r,null,e.appContext.config.unwrapInjectedRef),i)for(const X in i){const ne=i[X];ee(ne)&&(r[X]=ne.bind(n))}if(o){const X=o.call(n,n);be(X)&&(e.data=Jt(X))}if(kr=!0,s)for(const X in s){const ne=s[X],ye=ee(ne)?ne.bind(n,n):ee(ne.get)?ne.get.bind(n,n):Ue,Ae=!ee(ne)&&ee(ne.set)?ne.set.bind(n):Ue,ke=ge({get:ye,set:Ae});Object.defineProperty(r,X,{enumerable:!0,configurable:!0,get:()=>ke.value,set:Me=>ke.value=Me})}if(l)for(const X in l)pi(l[X],r,n,X);if(a){const X=ee(a)?a.call(n):a;Reflect.ownKeys(X).forEach(ne=>{xt(ne,X[ne])})}f&&Mo(f,e,"c");function V(X,ne){J(ne)?ne.forEach(ye=>X(ye.bind(n))):ne&&X(ne.bind(n))}if(V(ka,m),V(Ze,d),V(La,E),V(di,p),V(Sa,b),V(Ra,g),V(Ma,w),V(Da,j),V(Ba,x),V(sr,T),V(io,O),V(Ia,G),J(U))if(U.length){const X=e.exposed||(e.exposed={});U.forEach(ne=>{Object.defineProperty(X,ne,{get:()=>n[ne],set:ye=>n[ne]=ye})})}else e.exposed||(e.exposed={});H&&e.render===Ue&&(e.render=H),Y!=null&&(e.inheritAttrs=Y),y&&(e.components=y),D&&(e.directives=D)}function Ha(e,t,n=Ue,r=!1){J(e)&&(e=Lr(e));for(const o in e){const s=e[o];let i;be(s)?"default"in s?i=Te(s.from||o,s.default,!0):i=Te(s.from||o):i=Te(s),we(i)&&r?Object.defineProperty(t,o,{enumerable:!0,configurable:!0,get:()=>i.value,set:l=>i.value=l}):t[o]=i}}function Mo(e,t,n){ze(J(e)?e.map(r=>r.bind(t.proxy)):e.bind(t.proxy),t,n)}function pi(e,t,n,r){const o=r.includes(".")?li(n,r):()=>n[r];if(pe(e)){const s=t[e];ee(s)&&Je(o,s)}else if(ee(e))Je(o,e.bind(n));else if(be(e))if(J(e))e.forEach(s=>pi(s,t,n,r));else{const s=ee(e.handler)?e.handler.bind(n):t[e.handler];ee(s)&&Je(o,s,e)}}function hi(e){const t=e.type,{mixins:n,extends:r}=t,{mixins:o,optionsCache:s,config:{optionMergeStrategies:i}}=e.appContext,l=s.get(t);let a;return l?a=l:!o.length&&!n&&!r?a=t:(a={},o.length&&o.forEach(c=>Un(a,c,i,!0)),Un(a,t,i)),s.set(t,a),a}function Un(e,t,n,r=!1){const{mixins:o,extends:s}=t;s&&Un(e,s,n,!0),o&&o.forEach(i=>Un(e,i,n,!0));for(const i in t)if(!(r&&i==="expose")){const l=Fa[i]||n&&n[i];e[i]=l?l(e[i],t[i]):t[i]}return e}const Fa={data:No,props:_t,emits:_t,methods:_t,computed:_t,beforeCreate:xe,created:xe,beforeMount:xe,mounted:xe,beforeUpdate:xe,updated:xe,beforeDestroy:xe,beforeUnmount:xe,destroyed:xe,unmounted:xe,activated:xe,deactivated:xe,errorCaptured:xe,serverPrefetch:xe,components:_t,directives:_t,watch:$a,provide:No,inject:za};function No(e,t){return t?e?function(){return Ce(ee(e)?e.call(this,this):e,ee(t)?t.call(this,this):t)}:t:e}function za(e,t){return _t(Lr(e),Lr(t))}function Lr(e){if(J(e)){const t={};for(let n=0;n0)&&!(i&16)){if(i&8){const f=e.vnode.dynamicProps;for(let m=0;m{a=!0;const[d,E]=gi(m,t,!0);Ce(i,d),E&&l.push(...E)};!n&&t.mixins.length&&t.mixins.forEach(f),e.extends&&f(e.extends),e.mixins&&e.mixins.forEach(f)}if(!s&&!a)return r.set(e,Ht),Ht;if(J(s))for(let f=0;f-1,E[1]=b<0||p-1||se(E,"default"))&&l.push(m)}}}const c=[i,l];return r.set(e,c),c}function Ho(e){return e[0]!=="$"}function Fo(e){const t=e&&e.toString().match(/^\s*function (\w+)/);return t?t[1]:e===null?"null":""}function zo(e,t){return Fo(e)===Fo(t)}function $o(e,t){return J(t)?t.findIndex(n=>zo(n,e)):ee(t)&&zo(t,e)?0:-1}const vi=e=>e[0]==="_"||e==="$stable",lo=e=>J(e)?e.map(je):[je(e)],Ua=(e,t,n)=>{const r=ba((...o)=>lo(t(...o)),n);return r._c=!1,r},_i=(e,t,n)=>{const r=e._ctx;for(const o in e){if(vi(o))continue;const s=e[o];if(ee(s))t[o]=Ua(o,s,r);else if(s!=null){const i=lo(s);t[o]=()=>i}}},bi=(e,t)=>{const n=lo(t);e.slots.default=()=>n},qa=(e,t)=>{if(e.vnode.shapeFlag&32){const n=t._;n?(e.slots=ie(t),Fn(t,"_",n)):_i(t,e.slots={})}else e.slots={},t&&bi(e,t);Fn(e.slots,ir,1)},Ka=(e,t,n)=>{const{vnode:r,slots:o}=e;let s=!0,i=de;if(r.shapeFlag&32){const l=t._;l?n&&l===1?s=!1:(Ce(o,t),!n&&l===1&&delete o._):(s=!t.$stable,_i(t,o)),i=t}else t&&(bi(e,t),i={default:1});if(s)for(const l in o)!vi(l)&&!(l in i)&&delete o[l]};function rp(e,t){const n=Be;if(n===null)return e;const r=n.proxy,o=e.dirs||(e.dirs=[]);for(let s=0;sqn(d,t&&(J(t)?t[E]:t),n,r,o));return}if(jn(r)&&!o)return;const s=r.shapeFlag&4?uo(r.component)||r.component.proxy:r.el,i=o?null:s,{i:l,r:a}=e,c=t&&t.r,f=l.refs===de?l.refs={}:l.refs,m=l.setupState;if(c!=null&&c!==a&&(pe(c)?(f[c]=null,se(m,c)&&(m[c]=null)):we(c)&&(c.value=null)),ee(a))pt(a,l,12,[i,f]);else{const d=pe(a),E=we(a);if(d||E){const p=()=>{if(e.f){const b=d?f[a]:a.value;o?J(b)&&Ur(b,s):J(b)?b.includes(s)||b.push(s):d?f[a]=[s]:(a.value=[s],e.k&&(f[e.k]=a.value))}else d?(f[a]=i,se(m,a)&&(m[a]=i)):we(a)&&(a.value=i,e.k&&(f[e.k]=i))};i?(p.id=-1,Re(p,n)):p()}}}let st=!1;const Bn=e=>/svg/.test(e.namespaceURI)&&e.tagName!=="foreignObject",mr=e=>e.nodeType===8;function Ya(e){const{mt:t,p:n,o:{patchProp:r,nextSibling:o,parentNode:s,remove:i,insert:l,createComment:a}}=e,c=(g,v)=>{if(!v.hasChildNodes()){n(null,g,v),$n();return}st=!1,f(v.firstChild,g,null,null,null),$n(),st&&console.error("Hydration completed but contains mismatches.")},f=(g,v,T,S,O,H=!1)=>{const j=mr(g)&&g.data==="[",x=()=>p(g,v,T,S,O,j),{type:w,ref:G,shapeFlag:U}=v,Y=g.nodeType;v.el=g;let y=null;switch(w){case yn:Y!==3?y=x():(g.data!==v.children&&(st=!0,g.data=v.children),y=o(g));break;case $e:Y!==8||j?y=x():y=o(g);break;case fn:if(Y!==1)y=x();else{y=g;const D=!v.children.length;for(let W=0;W{H=H||!!v.dynamicChildren;const{type:j,props:x,patchFlag:w,shapeFlag:G,dirs:U}=v,Y=j==="input"&&U||j==="option";if(Y||w!==-1){if(U&&Ge(v,null,T,"created"),x)if(Y||!H||w&48)for(const D in x)(Y&&D.endsWith("value")||Tn(D)&&!an(D))&&r(g,D,null,x[D],!1,void 0,T);else x.onClick&&r(g,"onClick",null,x.onClick,!1,void 0,T);let y;if((y=x&&x.onVnodeBeforeMount)&&He(y,T,v),U&&Ge(v,null,T,"beforeMount"),((y=x&&x.onVnodeMounted)||U)&&si(()=>{y&&He(y,T,v),U&&Ge(v,null,T,"mounted")},S),G&16&&!(x&&(x.innerHTML||x.textContent))){let D=d(g.firstChild,v,g,T,S,O,H);for(;D;){st=!0;const W=D;D=D.nextSibling,i(W)}}else G&8&&g.textContent!==v.children&&(st=!0,g.textContent=v.children)}return g.nextSibling},d=(g,v,T,S,O,H,j)=>{j=j||!!v.dynamicChildren;const x=v.children,w=x.length;for(let G=0;G{const{slotScopeIds:j}=v;j&&(O=O?O.concat(j):j);const x=s(g),w=d(o(g),v,x,T,S,O,H);return w&&mr(w)&&w.data==="]"?o(v.anchor=w):(st=!0,l(v.anchor=a("]"),x,w),w)},p=(g,v,T,S,O,H)=>{if(st=!0,v.el=null,H){const w=b(g);for(;;){const G=o(g);if(G&&G!==w)i(G);else break}}const j=o(g),x=s(g);return i(g),n(null,v,x,j,T,S,Bn(x),O),j},b=g=>{let v=0;for(;g;)if(g=o(g),g&&mr(g)&&(g.data==="["&&v++,g.data==="]")){if(v===0)return o(g);v--}return g};return[c,f]}const Re=si;function Ja(e){return Ei(e)}function Qa(e){return Ei(e,Ya)}function Ei(e,t){const n=Sl();n.__VUE__=!0;const{insert:r,remove:o,patchProp:s,createElement:i,createText:l,createComment:a,setText:c,setElementText:f,parentNode:m,nextSibling:d,setScopeId:E=Ue,cloneNode:p,insertStaticContent:b}=e,g=(u,h,_,P=null,A=null,k=null,M=!1,L=null,B=!!h.dynamicChildren)=>{if(u===h)return;u&&!Et(u,h)&&(P=z(u),Se(u,A,k,!0),u=null),h.patchFlag===-2&&(B=!1,h.dynamicChildren=null);const{type:R,ref:q,shapeFlag:$}=h;switch(R){case yn:v(u,h,_,P);break;case $e:T(u,h,_,P);break;case fn:u==null&&S(h,_,P,M);break;case Oe:D(u,h,_,P,A,k,M,L,B);break;default:$&1?j(u,h,_,P,A,k,M,L,B):$&6?W(u,h,_,P,A,k,M,L,B):($&64||$&128)&&R.process(u,h,_,P,A,k,M,L,B,ce)}q!=null&&A&&qn(q,u&&u.ref,k,h||u,!h)},v=(u,h,_,P)=>{if(u==null)r(h.el=l(h.children),_,P);else{const A=h.el=u.el;h.children!==u.children&&c(A,h.children)}},T=(u,h,_,P)=>{u==null?r(h.el=a(h.children||""),_,P):h.el=u.el},S=(u,h,_,P)=>{[u.el,u.anchor]=b(u.children,h,_,P,u.el,u.anchor)},O=({el:u,anchor:h},_,P)=>{let A;for(;u&&u!==h;)A=d(u),r(u,_,P),u=A;r(h,_,P)},H=({el:u,anchor:h})=>{let _;for(;u&&u!==h;)_=d(u),o(u),u=_;o(h)},j=(u,h,_,P,A,k,M,L,B)=>{M=M||h.type==="svg",u==null?x(h,_,P,A,k,M,L,B):U(u,h,A,k,M,L,B)},x=(u,h,_,P,A,k,M,L)=>{let B,R;const{type:q,props:$,shapeFlag:K,transition:Q,patchFlag:re,dirs:me}=u;if(u.el&&p!==void 0&&re===-1)B=u.el=p(u.el);else{if(B=u.el=i(u.type,k,$&&$.is,$),K&8?f(B,u.children):K&16&&G(u.children,B,null,P,A,k&&q!=="foreignObject",M,L),me&&Ge(u,null,P,"created"),$){for(const he in $)he!=="value"&&!an(he)&&s(B,he,null,$[he],k,u.children,P,A,I);"value"in $&&s(B,"value",null,$.value),(R=$.onVnodeBeforeMount)&&He(R,P,u)}w(B,u,u.scopeId,M,P)}me&&Ge(u,null,P,"beforeMount");const ue=(!A||A&&!A.pendingBranch)&&Q&&!Q.persisted;ue&&Q.beforeEnter(B),r(B,h,_),((R=$&&$.onVnodeMounted)||ue||me)&&Re(()=>{R&&He(R,P,u),ue&&Q.enter(B),me&&Ge(u,null,P,"mounted")},A)},w=(u,h,_,P,A)=>{if(_&&E(u,_),P)for(let k=0;k{for(let R=B;R{const L=h.el=u.el;let{patchFlag:B,dynamicChildren:R,dirs:q}=h;B|=u.patchFlag&16;const $=u.props||de,K=h.props||de;let Q;_&&mt(_,!1),(Q=K.onVnodeBeforeUpdate)&&He(Q,_,h,u),q&&Ge(h,u,_,"beforeUpdate"),_&&mt(_,!0);const re=A&&h.type!=="foreignObject";if(R?Y(u.dynamicChildren,R,L,_,P,re,k):M||ye(u,h,L,null,_,P,re,k,!1),B>0){if(B&16)y(L,h,$,K,_,P,A);else if(B&2&&$.class!==K.class&&s(L,"class",null,K.class,A),B&4&&s(L,"style",$.style,K.style,A),B&8){const me=h.dynamicProps;for(let ue=0;ue{Q&&He(Q,_,h,u),q&&Ge(h,u,_,"updated")},P)},Y=(u,h,_,P,A,k,M)=>{for(let L=0;L{if(_!==P){for(const L in P){if(an(L))continue;const B=P[L],R=_[L];B!==R&&L!=="value"&&s(u,L,R,B,M,h.children,A,k,I)}if(_!==de)for(const L in _)!an(L)&&!(L in P)&&s(u,L,_[L],null,M,h.children,A,k,I);"value"in P&&s(u,"value",_.value,P.value)}},D=(u,h,_,P,A,k,M,L,B)=>{const R=h.el=u?u.el:l(""),q=h.anchor=u?u.anchor:l("");let{patchFlag:$,dynamicChildren:K,slotScopeIds:Q}=h;Q&&(L=L?L.concat(Q):Q),u==null?(r(R,_,P),r(q,_,P),G(h.children,_,q,A,k,M,L,B)):$>0&&$&64&&K&&u.dynamicChildren?(Y(u.dynamicChildren,K,_,A,k,M,L),(h.key!=null||A&&h===A.subTree)&&wi(u,h,!0)):ye(u,h,_,q,A,k,M,L,B)},W=(u,h,_,P,A,k,M,L,B)=>{h.slotScopeIds=L,u==null?h.shapeFlag&512?A.ctx.activate(h,_,P,M,B):le(h,_,P,A,k,M,B):V(u,h,B)},le=(u,h,_,P,A,k,M)=>{const L=u.component=uc(u,P,A);if(An(u)&&(L.ctx.renderer=ce),fc(L),L.asyncDep){if(A&&A.registerDep(L,X),!u.el){const B=L.subTree=_e($e);T(null,B,h,_)}return}X(L,u,h,_,A,k,M)},V=(u,h,_)=>{const P=h.component=u.component;if(wa(u,h,_))if(P.asyncDep&&!P.asyncResolved){ne(P,h,_);return}else P.next=h,pa(P.update),P.update();else h.component=u.component,h.el=u.el,P.vnode=h},X=(u,h,_,P,A,k,M)=>{const L=()=>{if(u.isMounted){let{next:q,bu:$,u:K,parent:Q,vnode:re}=u,me=q,ue;mt(u,!1),q?(q.el=re.el,ne(u,q,M)):q=re,$&&fr($),(ue=q.props&&q.props.onVnodeBeforeUpdate)&&He(ue,Q,q,re),mt(u,!0);const he=dr(u),Ve=u.subTree;u.subTree=he,g(Ve,he,m(Ve.el),z(Ve),u,A,k),q.el=he.el,me===null&&Ta(u,he.el),K&&Re(K,A),(ue=q.props&&q.props.onVnodeUpdated)&&Re(()=>He(ue,Q,q,re),A)}else{let q;const{el:$,props:K}=h,{bm:Q,m:re,parent:me}=u,ue=jn(h);if(mt(u,!1),Q&&fr(Q),!ue&&(q=K&&K.onVnodeBeforeMount)&&He(q,me,h),mt(u,!0),$&&Z){const he=()=>{u.subTree=dr(u),Z($,u.subTree,u,A,null)};ue?h.type.__asyncLoader().then(()=>!u.isUnmounted&&he()):he()}else{const he=u.subTree=dr(u);g(null,he,_,P,u,A,k),h.el=he.el}if(re&&Re(re,A),!ue&&(q=K&&K.onVnodeMounted)){const he=h;Re(()=>He(q,me,he),A)}h.shapeFlag&256&&u.a&&Re(u.a,A),u.isMounted=!0,h=_=P=null}},B=u.effect=new Gr(L,()=>ro(u.update),u.scope),R=u.update=B.run.bind(B);R.id=u.uid,mt(u,!0),R()},ne=(u,h,_)=>{h.component=u;const P=u.vnode.props;u.vnode=h,u.next=null,ja(u,h.props,P,_),Ka(u,h.children,_),Gt(),oo(void 0,u.update),Yt()},ye=(u,h,_,P,A,k,M,L,B=!1)=>{const R=u&&u.children,q=u?u.shapeFlag:0,$=h.children,{patchFlag:K,shapeFlag:Q}=h;if(K>0){if(K&128){ke(R,$,_,P,A,k,M,L,B);return}else if(K&256){Ae(R,$,_,P,A,k,M,L,B);return}}Q&8?(q&16&&I(R,A,k),$!==R&&f(_,$)):q&16?Q&16?ke(R,$,_,P,A,k,M,L,B):I(R,A,k,!0):(q&8&&f(_,""),Q&16&&G($,_,P,A,k,M,L,B))},Ae=(u,h,_,P,A,k,M,L,B)=>{u=u||Ht,h=h||Ht;const R=u.length,q=h.length,$=Math.min(R,q);let K;for(K=0;K<$;K++){const Q=h[K]=B?ct(h[K]):je(h[K]);g(u[K],Q,_,null,A,k,M,L,B)}R>q?I(u,A,k,!0,!1,$):G(h,_,P,A,k,M,L,B,$)},ke=(u,h,_,P,A,k,M,L,B)=>{let R=0;const q=h.length;let $=u.length-1,K=q-1;for(;R<=$&&R<=K;){const Q=u[R],re=h[R]=B?ct(h[R]):je(h[R]);if(Et(Q,re))g(Q,re,_,null,A,k,M,L,B);else break;R++}for(;R<=$&&R<=K;){const Q=u[$],re=h[K]=B?ct(h[K]):je(h[K]);if(Et(Q,re))g(Q,re,_,null,A,k,M,L,B);else break;$--,K--}if(R>$){if(R<=K){const Q=K+1,re=QK)for(;R<=$;)Se(u[R],A,k,!0),R++;else{const Q=R,re=R,me=new Map;for(R=re;R<=K;R++){const Le=h[R]=B?ct(h[R]):je(h[R]);Le.key!=null&&me.set(Le.key,R)}let ue,he=0;const Ve=K-re+1;let kt=!1,Eo=0;const en=new Array(Ve);for(R=0;R=Ve){Se(Le,A,k,!0);continue}let Ke;if(Le.key!=null)Ke=me.get(Le.key);else for(ue=re;ue<=K;ue++)if(en[ue-re]===0&&Et(Le,h[ue])){Ke=ue;break}Ke===void 0?Se(Le,A,k,!0):(en[Ke-re]=R+1,Ke>=Eo?Eo=Ke:kt=!0,g(Le,h[Ke],_,null,A,k,M,L,B),he++)}const wo=kt?Za(en):Ht;for(ue=wo.length-1,R=Ve-1;R>=0;R--){const Le=re+R,Ke=h[Le],To=Le+1{const{el:k,type:M,transition:L,children:B,shapeFlag:R}=u;if(R&6){Me(u.component.subTree,h,_,P);return}if(R&128){u.suspense.move(h,_,P);return}if(R&64){M.move(u,h,_,ce);return}if(M===Oe){r(k,h,_);for(let $=0;$L.enter(k),A);else{const{leave:$,delayLeave:K,afterLeave:Q}=L,re=()=>r(k,h,_),me=()=>{$(k,()=>{re(),Q&&Q()})};K?K(k,re,me):me()}else r(k,h,_)},Se=(u,h,_,P=!1,A=!1)=>{const{type:k,props:M,ref:L,children:B,dynamicChildren:R,shapeFlag:q,patchFlag:$,dirs:K}=u;if(L!=null&&qn(L,null,_,u,!0),q&256){h.ctx.deactivate(u);return}const Q=q&1&&K,re=!jn(u);let me;if(re&&(me=M&&M.onVnodeBeforeUnmount)&&He(me,h,u),q&6)F(u.component,_,P);else{if(q&128){u.suspense.unmount(_,P);return}Q&&Ge(u,null,h,"beforeUnmount"),q&64?u.type.remove(u,h,_,A,ce,P):R&&(k!==Oe||$>0&&$&64)?I(R,h,_,!1,!0):(k===Oe&&$&384||!A&&q&16)&&I(B,h,_),P&&Xt(u)}(re&&(me=M&&M.onVnodeUnmounted)||Q)&&Re(()=>{me&&He(me,h,u),Q&&Ge(u,null,h,"unmounted")},_)},Xt=u=>{const{type:h,el:_,anchor:P,transition:A}=u;if(h===Oe){C(_,P);return}if(h===fn){H(u);return}const k=()=>{o(_),A&&!A.persisted&&A.afterLeave&&A.afterLeave()};if(u.shapeFlag&1&&A&&!A.persisted){const{leave:M,delayLeave:L}=A,B=()=>M(_,k);L?L(u.el,k,B):B()}else k()},C=(u,h)=>{let _;for(;u!==h;)_=d(u),o(u),u=_;o(h)},F=(u,h,_)=>{const{bum:P,scope:A,update:k,subTree:M,um:L}=u;P&&fr(P),A.stop(),k&&(k.active=!1,Se(M,u,h,_)),L&&Re(L,h),Re(()=>{u.isUnmounted=!0},h),h&&h.pendingBranch&&!h.isUnmounted&&u.asyncDep&&!u.asyncResolved&&u.suspenseId===h.pendingId&&(h.deps--,h.deps===0&&h.resolve())},I=(u,h,_,P=!1,A=!1,k=0)=>{for(let M=k;Mu.shapeFlag&6?z(u.component.subTree):u.shapeFlag&128?u.suspense.next():d(u.anchor||u.el),ae=(u,h,_)=>{u==null?h._vnode&&Se(h._vnode,null,null,!0):g(h._vnode||null,u,h,null,null,null,_),$n(),h._vnode=u},ce={p:g,um:Se,m:Me,r:Xt,mt:le,mc:G,pc:ye,pbc:Y,n:z,o:e};let te,Z;return t&&([te,Z]=t(ce)),{render:ae,hydrate:te,createApp:Ga(ae,te)}}function mt({effect:e,update:t},n){e.allowRecurse=t.allowRecurse=n}function wi(e,t,n=!1){const r=e.children,o=t.children;if(J(r)&&J(o))for(let s=0;s>1,e[n[l]]0&&(t[r]=n[s-1]),n[s]=r)}}for(s=n.length,i=n[s-1];s-- >0;)n[s]=i,i=t[i];return n}const Xa=e=>e.__isTeleport,Ti="components";function ec(e,t){return nc(Ti,e,!0,t)||e}const tc=Symbol();function nc(e,t,n=!0,r=!1){const o=Be||Ee;if(o){const s=o.type;if(e===Ti){const l=mc(s);if(l&&(l===t||l===Qe(t)||l===tr(Qe(t))))return s}const i=Vo(o[e]||s[e],t)||Vo(o.appContext[e],t);return!i&&r?s:i}}function Vo(e,t){return e&&(e[t]||e[Qe(t)]||e[tr(Qe(t))])}const Oe=Symbol(void 0),yn=Symbol(void 0),$e=Symbol(void 0),fn=Symbol(void 0),dn=[];let Pt=null;function Vt(e=!1){dn.push(Pt=e?null:[])}function rc(){dn.pop(),Pt=dn[dn.length-1]||null}let Kn=1;function jo(e){Kn+=e}function Ci(e){return e.dynamicChildren=Kn>0?Pt||Ht:null,rc(),Kn>0&&Pt&&Pt.push(e),e}function Wn(e,t,n,r,o,s){return Ci(En(e,t,n,r,o,s,!0))}function Ai(e,t,n,r,o){return Ci(_e(e,t,n,r,o,!0))}function Gn(e){return e?e.__v_isVNode===!0:!1}function Et(e,t){return e.type===t.type&&e.key===t.key}const ir="__vInternal",xi=({key:e})=>e!=null?e:null,Mn=({ref:e,ref_key:t,ref_for:n})=>e!=null?pe(e)||we(e)||ee(e)?{i:Be,r:e,k:t,f:!!n}:e:null;function En(e,t=null,n=null,r=0,o=null,s=e===Oe?0:1,i=!1,l=!1){const a={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&xi(t),ref:t&&Mn(t),scopeId:rr,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:s,patchFlag:r,dynamicProps:o,dynamicChildren:null,appContext:null};return l?(co(a,n),s&128&&e.normalize(a)):n&&(a.shapeFlag|=pe(n)?8:16),Kn>0&&!i&&Pt&&(a.patchFlag>0||s&6)&&a.patchFlag!==32&&Pt.push(a),a}const _e=oc;function oc(e,t=null,n=null,r=0,o=null,s=!1){if((!e||e===tc)&&(e=$e),Gn(e)){const l=jt(e,t,!0);return n&&co(l,n),l}if(gc(e)&&(e=e.__vccOpts),t){t=sc(t);let{class:l,style:a}=t;l&&!pe(l)&&(t.class=Rt(l)),be(a)&&(Ws(a)&&!J(a)&&(a=Ce({},a)),t.style=$t(a))}const i=pe(e)?1:Ca(e)?128:Xa(e)?64:be(e)?4:ee(e)?2:0;return En(e,t,n,r,o,i,s,!0)}function sc(e){return e?Ws(e)||ir in e?Ce({},e):e:null}function jt(e,t,n=!1){const{props:r,ref:o,patchFlag:s,children:i}=e,l=t?ic(r||{},t):r;return{__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&xi(l),ref:t&&t.ref?n&&o?J(o)?o.concat(Mn(t)):[o,Mn(t)]:Mn(t):o,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:i,target:e.target,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Oe?s===-1?16:s|16:s,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:e.transition,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&jt(e.ssContent),ssFallback:e.ssFallback&&jt(e.ssFallback),el:e.el,anchor:e.anchor}}function ao(e=" ",t=0){return _e(yn,null,e,t)}function op(e,t){const n=_e(fn,null,e);return n.staticCount=t,n}function sp(e="",t=!1){return t?(Vt(),Ai($e,null,e)):_e($e,null,e)}function je(e){return e==null||typeof e=="boolean"?_e($e):J(e)?_e(Oe,null,e.slice()):typeof e=="object"?ct(e):_e(yn,null,String(e))}function ct(e){return e.el===null||e.memo?e:jt(e)}function co(e,t){let n=0;const{shapeFlag:r}=e;if(t==null)t=null;else if(J(t))n=16;else if(typeof t=="object")if(r&65){const o=t.default;o&&(o._c&&(o._d=!1),co(e,o()),o._c&&(o._d=!0));return}else{n=32;const o=t._;!o&&!(ir in t)?t._ctx=Be:o===3&&Be&&(Be.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else ee(t)?(t={default:t,_ctx:Be},n=32):(t=String(t),r&64?(n=16,t=[ao(t)]):n=8);e.children=t,e.shapeFlag|=n}function ic(...e){const t={};for(let n=0;nt(i,l,void 0,s&&s[l]));else{const i=Object.keys(e);o=new Array(i.length);for(let l=0,a=i.length;lGn(t)?!(t.type===$e||t.type===Oe&&!Si(t.children)):!0)?e:null}const Br=e=>e?Oi(e)?uo(e)||e.proxy:Br(e.parent):null,Yn=Ce(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>Br(e.parent),$root:e=>Br(e.root),$emit:e=>e.emit,$options:e=>hi(e),$forceUpdate:e=>()=>ro(e.update),$nextTick:e=>no.bind(e.proxy),$watch:e=>Aa.bind(e)}),lc={get({_:e},t){const{ctx:n,setupState:r,data:o,props:s,accessCache:i,type:l,appContext:a}=e;let c;if(t[0]!=="$"){const E=i[t];if(E!==void 0)switch(E){case 1:return r[t];case 2:return o[t];case 4:return n[t];case 3:return s[t]}else{if(r!==de&&se(r,t))return i[t]=1,r[t];if(o!==de&&se(o,t))return i[t]=2,o[t];if((c=e.propsOptions[0])&&se(c,t))return i[t]=3,s[t];if(n!==de&&se(n,t))return i[t]=4,n[t];kr&&(i[t]=0)}}const f=Yn[t];let m,d;if(f)return t==="$attrs"&&De(e,"get",t),f(e);if((m=l.__cssModules)&&(m=m[t]))return m;if(n!==de&&se(n,t))return i[t]=4,n[t];if(d=a.config.globalProperties,se(d,t))return d[t]},set({_:e},t,n){const{data:r,setupState:o,ctx:s}=e;return o!==de&&se(o,t)?(o[t]=n,!0):r!==de&&se(r,t)?(r[t]=n,!0):se(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(s[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:o,propsOptions:s}},i){let l;return!!n[i]||e!==de&&se(e,i)||t!==de&&se(t,i)||(l=s[0])&&se(l,i)||se(r,i)||se(Yn,i)||se(o.config.globalProperties,i)},defineProperty(e,t,n){return n.get!=null?this.set(e,t,n.get(),null):n.value!=null&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}},ac=yi();let cc=0;function uc(e,t,n){const r=e.type,o=(t?t.appContext:e.appContext)||ac,s={uid:cc++,vnode:e,type:r,parent:t,appContext:o,root:null,next:null,subTree:null,effect:null,update:null,scope:new Rl(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(o.provides),accessCache:null,renderCache:[],components:null,directives:null,propsOptions:gi(r,o),emitsOptions:oi(r,o),emit:null,emitted:null,propsDefaults:de,inheritAttrs:r.inheritAttrs,ctx:de,data:de,props:de,attrs:de,slots:de,refs:de,setupState:de,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return s.ctx={_:s},s.root=t?t.root:s,s.emit=ga.bind(null,s),e.ce&&e.ce(s),s}let Ee=null;const Ri=()=>Ee||Be,Ut=e=>{Ee=e,e.scope.on()},St=()=>{Ee&&Ee.scope.off(),Ee=null};function Oi(e){return e.vnode.shapeFlag&4}let qt=!1;function fc(e,t=!1){qt=t;const{props:n,children:r}=e.vnode,o=Oi(e);Va(e,n,o,t),qa(e,r);const s=o?dc(e,t):void 0;return qt=!1,s}function dc(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=Gs(new Proxy(e.ctx,lc));const{setup:r}=n;if(r){const o=e.setupContext=r.length>1?hc(e):null;Ut(e),Gt();const s=pt(r,e,0,[e.props,o]);if(Yt(),St(),Ls(s)){if(s.then(St,St),t)return s.then(i=>{Uo(e,i,t)}).catch(i=>{Cn(i,e,0)});e.asyncDep=s}else Uo(e,s,t)}else ki(e,t)}function Uo(e,t,n){ee(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:be(t)&&(e.setupState=Xs(t)),ki(e,n)}let qo;function ki(e,t,n){const r=e.type;if(!e.render){if(!t&&qo&&!r.render){const o=r.template;if(o){const{isCustomElement:s,compilerOptions:i}=e.appContext.config,{delimiters:l,compilerOptions:a}=r,c=Ce(Ce({isCustomElement:s,delimiters:l},i),a);r.render=qo(o,c)}}e.render=r.render||Ue}Ut(e),Gt(),Na(e),Yt(),St()}function pc(e){return new Proxy(e.attrs,{get(t,n){return De(e,"get","$attrs"),t[n]}})}function hc(e){const t=r=>{e.exposed=r||{}};let n;return{get attrs(){return n||(n=pc(e))},slots:e.slots,emit:e.emit,expose:t}}function uo(e){if(e.exposed)return e.exposeProxy||(e.exposeProxy=new Proxy(Xs(Gs(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Yn)return Yn[n](e)}}))}function mc(e){return ee(e)&&e.displayName||e.name}function gc(e){return ee(e)&&"__vccOpts"in e}const ge=(e,t)=>ua(e,t,qt);function ve(e,t,n){const r=arguments.length;return r===2?be(t)&&!J(t)?Gn(t)?_e(e,null,[t]):_e(e,t):_e(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&Gn(n)&&(n=[n]),_e(e,t,n))}const vc="3.2.31",_c="http://www.w3.org/2000/svg",wt=typeof document!="undefined"?document:null,Ko=wt&&wt.createElement("template"),bc={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{const o=t?wt.createElementNS(_c,e):wt.createElement(e,n?{is:n}:void 0);return e==="select"&&r&&r.multiple!=null&&o.setAttribute("multiple",r.multiple),o},createText:e=>wt.createTextNode(e),createComment:e=>wt.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>wt.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},cloneNode(e){const t=e.cloneNode(!0);return"_value"in e&&(t._value=e._value),t},insertStaticContent(e,t,n,r,o,s){const i=n?n.previousSibling:t.lastChild;if(o&&(o===s||o.nextSibling))for(;t.insertBefore(o.cloneNode(!0),n),!(o===s||!(o=o.nextSibling)););else{Ko.innerHTML=r?`${e}`:e;const l=Ko.content;if(r){const a=l.firstChild;for(;a.firstChild;)l.appendChild(a.firstChild);l.removeChild(a)}t.insertBefore(l,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}};function yc(e,t,n){const r=e._vtc;r&&(t=(t?[t,...r]:[...r]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}function Ec(e,t,n){const r=e.style,o=pe(n);if(n&&!o){for(const s in n)Dr(r,s,n[s]);if(t&&!pe(t))for(const s in t)n[s]==null&&Dr(r,s,"")}else{const s=r.display;o?t!==n&&(r.cssText=n):t&&e.removeAttribute("style"),"_vod"in e&&(r.display=s)}}const Wo=/\s*!important$/;function Dr(e,t,n){if(J(n))n.forEach(r=>Dr(e,t,r));else if(t.startsWith("--"))e.setProperty(t,n);else{const r=wc(e,t);Wo.test(n)?e.setProperty(Ot(r),n.replace(Wo,""),"important"):e[r]=n}}const Go=["Webkit","Moz","ms"],gr={};function wc(e,t){const n=gr[t];if(n)return n;let r=Qe(t);if(r!=="filter"&&r in e)return gr[t]=r;r=tr(r);for(let o=0;odocument.createEvent("Event").timeStamp&&(Jn=()=>performance.now());const e=navigator.userAgent.match(/firefox\/(\d+)/i);Li=!!(e&&Number(e[1])<=53)}let Mr=0;const Ac=Promise.resolve(),xc=()=>{Mr=0},Pc=()=>Mr||(Ac.then(xc),Mr=Jn());function Sc(e,t,n,r){e.addEventListener(t,n,r)}function Rc(e,t,n,r){e.removeEventListener(t,n,r)}function Oc(e,t,n,r,o=null){const s=e._vei||(e._vei={}),i=s[t];if(r&&i)i.value=r;else{const[l,a]=kc(t);if(r){const c=s[t]=Lc(r,o);Sc(e,l,c,a)}else i&&(Rc(e,l,i,a),s[t]=void 0)}}const Jo=/(?:Once|Passive|Capture)$/;function kc(e){let t;if(Jo.test(e)){t={};let n;for(;n=e.match(Jo);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[Ot(e.slice(2)),t]}function Lc(e,t){const n=r=>{const o=r.timeStamp||Jn();(Li||o>=n.attached-1)&&ze(Ic(r,n.value),t,5,[r])};return n.value=e,n.attached=Pc(),n}function Ic(e,t){if(J(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(r=>o=>!o._stopped&&r&&r(o))}else return t}const Qo=/^on[a-z]/,Bc=(e,t,n,r,o=!1,s,i,l,a)=>{t==="class"?yc(e,r,o):t==="style"?Ec(e,n,r):Tn(t)?jr(t)||Oc(e,t,n,r,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Dc(e,t,r,o))?Cc(e,t,r,s,i,l,a):(t==="true-value"?e._trueValue=r:t==="false-value"&&(e._falseValue=r),Tc(e,t,r,o))};function Dc(e,t,n,r){return r?!!(t==="innerHTML"||t==="textContent"||t in e&&Qo.test(t)&&ee(n)):t==="spellcheck"||t==="draggable"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA"||Qo.test(t)&&pe(n)?!1:t in e}const it="transition",tn="animation",fo=(e,{slots:t})=>ve(ai,Mc(e),t);fo.displayName="Transition";const Ii={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String};fo.props=Ce({},ai.props,Ii);const gt=(e,t=[])=>{J(e)?e.forEach(n=>n(...t)):e&&e(...t)},Zo=e=>e?J(e)?e.some(t=>t.length>1):e.length>1:!1;function Mc(e){const t={};for(const y in e)y in Ii||(t[y]=e[y]);if(e.css===!1)return t;const{name:n="v",type:r,duration:o,enterFromClass:s=`${n}-enter-from`,enterActiveClass:i=`${n}-enter-active`,enterToClass:l=`${n}-enter-to`,appearFromClass:a=s,appearActiveClass:c=i,appearToClass:f=l,leaveFromClass:m=`${n}-leave-from`,leaveActiveClass:d=`${n}-leave-active`,leaveToClass:E=`${n}-leave-to`}=e,p=Nc(o),b=p&&p[0],g=p&&p[1],{onBeforeEnter:v,onEnter:T,onEnterCancelled:S,onLeave:O,onLeaveCancelled:H,onBeforeAppear:j=v,onAppear:x=T,onAppearCancelled:w=S}=t,G=(y,D,W)=>{Lt(y,D?f:l),Lt(y,D?c:i),W&&W()},U=(y,D)=>{Lt(y,E),Lt(y,d),D&&D()},Y=y=>(D,W)=>{const le=y?x:T,V=()=>G(D,y,W);gt(le,[D,V]),Xo(()=>{Lt(D,y?a:s),lt(D,y?f:l),Zo(le)||es(D,r,b,V)})};return Ce(t,{onBeforeEnter(y){gt(v,[y]),lt(y,s),lt(y,i)},onBeforeAppear(y){gt(j,[y]),lt(y,a),lt(y,c)},onEnter:Y(!1),onAppear:Y(!0),onLeave(y,D){const W=()=>U(y,D);lt(y,m),zc(),lt(y,d),Xo(()=>{Lt(y,m),lt(y,E),Zo(O)||es(y,r,g,W)}),gt(O,[y,W])},onEnterCancelled(y){G(y,!1),gt(S,[y])},onAppearCancelled(y){G(y,!0),gt(w,[y])},onLeaveCancelled(y){U(y),gt(H,[y])}})}function Nc(e){if(e==null)return null;if(be(e))return[vr(e.enter),vr(e.leave)];{const t=vr(e);return[t,t]}}function vr(e){return Ds(e)}function lt(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e._vtc||(e._vtc=new Set)).add(t)}function Lt(e,t){t.split(/\s+/).forEach(r=>r&&e.classList.remove(r));const{_vtc:n}=e;n&&(n.delete(t),n.size||(e._vtc=void 0))}function Xo(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let Hc=0;function es(e,t,n,r){const o=e._endId=++Hc,s=()=>{o===e._endId&&r()};if(n)return setTimeout(s,n);const{type:i,timeout:l,propCount:a}=Fc(e,t);if(!i)return r();const c=i+"end";let f=0;const m=()=>{e.removeEventListener(c,d),s()},d=E=>{E.target===e&&++f>=a&&m()};setTimeout(()=>{f(n[p]||"").split(", "),o=r(it+"Delay"),s=r(it+"Duration"),i=ts(o,s),l=r(tn+"Delay"),a=r(tn+"Duration"),c=ts(l,a);let f=null,m=0,d=0;t===it?i>0&&(f=it,m=i,d=s.length):t===tn?c>0&&(f=tn,m=c,d=a.length):(m=Math.max(i,c),f=m>0?i>c?it:tn:null,d=f?f===it?s.length:a.length:0);const E=f===it&&/\b(transform|all)(,|$)/.test(n[it+"Property"]);return{type:f,timeout:m,propCount:d,hasTransform:E}}function ts(e,t){for(;e.lengthns(n)+ns(e[r])))}function ns(e){return Number(e.slice(0,-1).replace(",","."))*1e3}function zc(){return document.body.offsetHeight}const $c={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},lp=(e,t)=>n=>{if(!("key"in n))return;const r=Ot(n.key);if(t.some(o=>o===r||$c[o]===r))return e(n)},ap={beforeMount(e,{value:t},{transition:n}){e._vod=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):nn(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),nn(e,!0),r.enter(e)):r.leave(e,()=>{nn(e,!1)}):nn(e,t))},beforeUnmount(e,{value:t}){nn(e,t)}};function nn(e,t){e.style.display=t?e._vod:"none"}const Bi=Ce({patchProp:Bc},bc);let pn,rs=!1;function Vc(){return pn||(pn=Ja(Bi))}function jc(){return pn=rs?pn:Qa(Bi),rs=!0,pn}const Uc=(...e)=>{const t=Vc().createApp(...e),{mount:n}=t;return t.mount=r=>{const o=Di(r);if(!o)return;const s=t._component;!ee(s)&&!s.render&&!s.template&&(s.template=o.innerHTML),o.innerHTML="";const i=n(o,!1,o instanceof SVGElement);return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),i},t},qc=(...e)=>{const t=jc().createApp(...e),{mount:n}=t;return t.mount=r=>{const o=Di(r);if(o)return n(o,!0,o instanceof SVGElement)},t};function Di(e){return pe(e)?document.querySelector(e):e}/*! + * vue-router v4.0.12 + * (c) 2021 Eduardo San Martin Morote + * @license MIT + */const Mi=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Qt=e=>Mi?Symbol(e):"_vr_"+e,Kc=Qt("rvlm"),os=Qt("rvd"),lr=Qt("r"),po=Qt("rl"),Nr=Qt("rvl"),Nt=typeof window!="undefined";function Wc(e){return e.__esModule||Mi&&e[Symbol.toStringTag]==="Module"}const fe=Object.assign;function _r(e,t){const n={};for(const r in t){const o=t[r];n[r]=Array.isArray(o)?o.map(e):e(o)}return n}const hn=()=>{},Gc=/\/$/,Yc=e=>e.replace(Gc,"");function br(e,t,n="/"){let r,o={},s="",i="";const l=t.indexOf("?"),a=t.indexOf("#",l>-1?l:0);return l>-1&&(r=t.slice(0,l),s=t.slice(l+1,a>-1?a:t.length),o=e(s)),a>-1&&(r=r||t.slice(0,a),i=t.slice(a,t.length)),r=Xc(r!=null?r:t,n),{fullPath:r+(s&&"?")+s+i,path:r,query:o,hash:i}}function Jc(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function ss(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||"/"}function Qc(e,t,n){const r=t.matched.length-1,o=n.matched.length-1;return r>-1&&r===o&&Kt(t.matched[r],n.matched[o])&&Ni(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Kt(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function Ni(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(!Zc(e[n],t[n]))return!1;return!0}function Zc(e,t){return Array.isArray(e)?is(e,t):Array.isArray(t)?is(t,e):e===t}function is(e,t){return Array.isArray(t)?e.length===t.length&&e.every((n,r)=>n===t[r]):e.length===1&&e[0]===t}function Xc(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),r=e.split("/");let o=n.length-1,s,i;for(s=0;s({left:window.pageXOffset,top:window.pageYOffset});function ou(e){let t;if("el"in e){const n=e.el,r=typeof n=="string"&&n.startsWith("#"),o=typeof n=="string"?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!o)return;t=ru(o,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left!=null?t.left:window.pageXOffset,t.top!=null?t.top:window.pageYOffset)}function ls(e,t){return(history.state?history.state.position-t:-1)+e}const Hr=new Map;function su(e,t){Hr.set(e,t)}function iu(e){const t=Hr.get(e);return Hr.delete(e),t}let lu=()=>location.protocol+"//"+location.host;function Hi(e,t){const{pathname:n,search:r,hash:o}=t,s=e.indexOf("#");if(s>-1){let l=o.includes(e.slice(s))?e.slice(s).length:1,a=o.slice(l);return a[0]!=="/"&&(a="/"+a),ss(a,"")}return ss(n,e)+r+o}function au(e,t,n,r){let o=[],s=[],i=null;const l=({state:d})=>{const E=Hi(e,location),p=n.value,b=t.value;let g=0;if(d){if(n.value=E,t.value=d,i&&i===p){i=null;return}g=b?d.position-b.position:0}else r(E);o.forEach(v=>{v(n.value,p,{delta:g,type:wn.pop,direction:g?g>0?mn.forward:mn.back:mn.unknown})})};function a(){i=n.value}function c(d){o.push(d);const E=()=>{const p=o.indexOf(d);p>-1&&o.splice(p,1)};return s.push(E),E}function f(){const{history:d}=window;!d.state||d.replaceState(fe({},d.state,{scroll:ar()}),"")}function m(){for(const d of s)d();s=[],window.removeEventListener("popstate",l),window.removeEventListener("beforeunload",f)}return window.addEventListener("popstate",l),window.addEventListener("beforeunload",f),{pauseListeners:a,listen:c,destroy:m}}function as(e,t,n,r=!1,o=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:o?ar():null}}function cu(e){const{history:t,location:n}=window,r={value:Hi(e,n)},o={value:t.state};o.value||s(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function s(a,c,f){const m=e.indexOf("#"),d=m>-1?(n.host&&document.querySelector("base")?e:e.slice(m))+a:lu()+e+a;try{t[f?"replaceState":"pushState"](c,"",d),o.value=c}catch(E){console.error(E),n[f?"replace":"assign"](d)}}function i(a,c){const f=fe({},t.state,as(o.value.back,a,o.value.forward,!0),c,{position:o.value.position});s(a,f,!0),r.value=a}function l(a,c){const f=fe({},o.value,t.state,{forward:a,scroll:ar()});s(f.current,f,!0);const m=fe({},as(r.value,a,null),{position:f.position+1},c);s(a,m,!1),r.value=a}return{location:r,state:o,push:l,replace:i}}function uu(e){e=eu(e);const t=cu(e),n=au(e,t.state,t.location,t.replace);function r(s,i=!0){i||n.pauseListeners(),history.go(s)}const o=fe({location:"",base:e,go:r,createHref:nu.bind(null,e)},t,n);return Object.defineProperty(o,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(o,"state",{enumerable:!0,get:()=>t.state.value}),o}function fu(e){return typeof e=="string"||e&&typeof e=="object"}function Fi(e){return typeof e=="string"||typeof e=="symbol"}const Xe={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},zi=Qt("nf");var cs;(function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"})(cs||(cs={}));function Wt(e,t){return fe(new Error,{type:e,[zi]:!0},t)}function vt(e,t){return e instanceof Error&&zi in e&&(t==null||!!(e.type&t))}const us="[^/]+?",du={sensitive:!1,strict:!1,start:!0,end:!0},pu=/[.+*?^${}()[\]/\\]/g;function hu(e,t){const n=fe({},du,t),r=[];let o=n.start?"^":"";const s=[];for(const c of e){const f=c.length?[]:[90];n.strict&&!c.length&&(o+="/");for(let m=0;mt.length?t.length===1&&t[0]===40+40?1:-1:0}function gu(e,t){let n=0;const r=e.score,o=t.score;for(;n1&&(a==="*"||a==="+")&&t(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),s.push({type:1,value:c,regexp:f,repeatable:a==="*"||a==="+",optional:a==="*"||a==="?"})):t("Invalid state to consume buffer"),c="")}function d(){c+=a}for(;l{i(T)}:hn}function i(f){if(Fi(f)){const m=r.get(f);m&&(r.delete(f),n.splice(n.indexOf(m),1),m.children.forEach(i),m.alias.forEach(i))}else{const m=n.indexOf(f);m>-1&&(n.splice(m,1),f.record.name&&r.delete(f.record.name),f.children.forEach(i),f.alias.forEach(i))}}function l(){return n}function a(f){let m=0;for(;m=0;)m++;n.splice(m,0,f),f.record.name&&!fs(f)&&r.set(f.record.name,f)}function c(f,m){let d,E={},p,b;if("name"in f&&f.name){if(d=r.get(f.name),!d)throw Wt(1,{location:f});b=d.record.name,E=fe(wu(m.params,d.keys.filter(T=>!T.optional).map(T=>T.name)),f.params),p=d.stringify(E)}else if("path"in f)p=f.path,d=n.find(T=>T.re.test(p)),d&&(E=d.parse(p),b=d.record.name);else{if(d=m.name?r.get(m.name):n.find(T=>T.re.test(m.path)),!d)throw Wt(1,{location:f,currentLocation:m});b=d.record.name,E=fe({},m.params,f.params),p=d.stringify(E)}const g=[];let v=d;for(;v;)g.unshift(v.record),v=v.parent;return{name:b,path:p,params:E,matched:g,meta:Au(g)}}return e.forEach(f=>s(f)),{addRoute:s,resolve:c,removeRoute:i,getRoutes:l,getRecordMatcher:o}}function wu(e,t){const n={};for(const r of t)r in e&&(n[r]=e[r]);return n}function Tu(e){return{path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:void 0,beforeEnter:e.beforeEnter,props:Cu(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||{}:{default:e.component}}}function Cu(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const r in e.components)t[r]=typeof n=="boolean"?n:n[r];return t}function fs(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Au(e){return e.reduce((t,n)=>fe(t,n.meta),{})}function ds(e,t){const n={};for(const r in e)n[r]=r in t?t[r]:e[r];return n}const $i=/#/g,xu=/&/g,Pu=/\//g,Su=/=/g,Ru=/\?/g,Vi=/\+/g,Ou=/%5B/g,ku=/%5D/g,ji=/%5E/g,Lu=/%60/g,Ui=/%7B/g,Iu=/%7C/g,qi=/%7D/g,Bu=/%20/g;function ho(e){return encodeURI(""+e).replace(Iu,"|").replace(Ou,"[").replace(ku,"]")}function Du(e){return ho(e).replace(Ui,"{").replace(qi,"}").replace(ji,"^")}function Fr(e){return ho(e).replace(Vi,"%2B").replace(Bu,"+").replace($i,"%23").replace(xu,"%26").replace(Lu,"`").replace(Ui,"{").replace(qi,"}").replace(ji,"^")}function Mu(e){return Fr(e).replace(Su,"%3D")}function Nu(e){return ho(e).replace($i,"%23").replace(Ru,"%3F")}function Hu(e){return e==null?"":Nu(e).replace(Pu,"%2F")}function Qn(e){try{return decodeURIComponent(""+e)}catch{}return""+e}function Fu(e){const t={};if(e===""||e==="?")return t;const r=(e[0]==="?"?e.slice(1):e).split("&");for(let o=0;os&&Fr(s)):[r&&Fr(r)]).forEach(s=>{s!==void 0&&(t+=(t.length?"&":"")+n,s!=null&&(t+="="+s))})}return t}function zu(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=Array.isArray(r)?r.map(o=>o==null?null:""+o):r==null?r:""+r)}return t}function rn(){let e=[];function t(r){return e.push(r),()=>{const o=e.indexOf(r);o>-1&&e.splice(o,1)}}function n(){e=[]}return{add:t,list:()=>e,reset:n}}function ut(e,t,n,r,o){const s=r&&(r.enterCallbacks[o]=r.enterCallbacks[o]||[]);return()=>new Promise((i,l)=>{const a=m=>{m===!1?l(Wt(4,{from:n,to:t})):m instanceof Error?l(m):fu(m)?l(Wt(2,{from:t,to:m})):(s&&r.enterCallbacks[o]===s&&typeof m=="function"&&s.push(m),i())},c=e.call(r&&r.instances[o],t,n,a);let f=Promise.resolve(c);e.length<3&&(f=f.then(a)),f.catch(m=>l(m))})}function yr(e,t,n,r){const o=[];for(const s of e)for(const i in s.components){let l=s.components[i];if(!(t!=="beforeRouteEnter"&&!s.instances[i]))if($u(l)){const c=(l.__vccOpts||l)[t];c&&o.push(ut(c,n,r,s,i))}else{let a=l();o.push(()=>a.then(c=>{if(!c)return Promise.reject(new Error(`Couldn't resolve component "${i}" at "${s.path}"`));const f=Wc(c)?c.default:c;s.components[i]=f;const d=(f.__vccOpts||f)[t];return d&&ut(d,n,r,s,i)()}))}}return o}function $u(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function hs(e){const t=Te(lr),n=Te(po),r=ge(()=>t.resolve(At(e.to))),o=ge(()=>{const{matched:a}=r.value,{length:c}=a,f=a[c-1],m=n.matched;if(!f||!m.length)return-1;const d=m.findIndex(Kt.bind(null,f));if(d>-1)return d;const E=ms(a[c-2]);return c>1&&ms(f)===E&&m[m.length-1].path!==E?m.findIndex(Kt.bind(null,a[c-2])):d}),s=ge(()=>o.value>-1&&qu(n.params,r.value.params)),i=ge(()=>o.value>-1&&o.value===n.matched.length-1&&Ni(n.params,r.value.params));function l(a={}){return Uu(a)?t[At(e.replace)?"replace":"push"](At(e.to)).catch(hn):Promise.resolve()}return{route:r,href:ge(()=>r.value.href),isActive:s,isExactActive:i,navigate:l}}const Vu=qe({name:"RouterLink",props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:hs,setup(e,{slots:t}){const n=Jt(hs(e)),{options:r}=Te(lr),o=ge(()=>({[gs(e.activeClass,r.linkActiveClass,"router-link-active")]:n.isActive,[gs(e.exactActiveClass,r.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const s=t.default&&t.default(n);return e.custom?s:ve("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:o.value},s)}}}),ju=Vu;function Uu(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function qu(e,t){for(const n in t){const r=t[n],o=e[n];if(typeof r=="string"){if(r!==o)return!1}else if(!Array.isArray(o)||o.length!==r.length||r.some((s,i)=>s!==o[i]))return!1}return!0}function ms(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const gs=(e,t,n)=>e!=null?e:t!=null?t:n,Ku=qe({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},setup(e,{attrs:t,slots:n}){const r=Te(Nr),o=ge(()=>e.route||r.value),s=Te(os,0),i=ge(()=>o.value.matched[s]);xt(os,s+1),xt(Kc,i),xt(Nr,o);const l=Pe();return Je(()=>[l.value,i.value,e.name],([a,c,f],[m,d,E])=>{c&&(c.instances[f]=a,d&&d!==c&&a&&a===m&&(c.leaveGuards.size||(c.leaveGuards=d.leaveGuards),c.updateGuards.size||(c.updateGuards=d.updateGuards))),a&&c&&(!d||!Kt(c,d)||!m)&&(c.enterCallbacks[f]||[]).forEach(p=>p(a))},{flush:"post"}),()=>{const a=o.value,c=i.value,f=c&&c.components[e.name],m=e.name;if(!f)return vs(n.default,{Component:f,route:a});const d=c.props[e.name],E=d?d===!0?a.params:typeof d=="function"?d(a):d:null,b=ve(f,fe({},E,t,{onVnodeUnmounted:g=>{g.component.isUnmounted&&(c.instances[m]=null)},ref:l}));return vs(n.default,{Component:b,route:a})||b}}});function vs(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const Ki=Ku;function Wu(e){const t=Eu(e.routes,e),n=e.parseQuery||Fu,r=e.stringifyQuery||ps,o=e.history,s=rn(),i=rn(),l=rn(),a=Qs(Xe);let c=Xe;Nt&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const f=_r.bind(null,C=>""+C),m=_r.bind(null,Hu),d=_r.bind(null,Qn);function E(C,F){let I,z;return Fi(C)?(I=t.getRecordMatcher(C),z=F):z=C,t.addRoute(z,I)}function p(C){const F=t.getRecordMatcher(C);F&&t.removeRoute(F)}function b(){return t.getRoutes().map(C=>C.record)}function g(C){return!!t.getRecordMatcher(C)}function v(C,F){if(F=fe({},F||a.value),typeof C=="string"){const Z=br(n,C,F.path),u=t.resolve({path:Z.path},F),h=o.createHref(Z.fullPath);return fe(Z,u,{params:d(u.params),hash:Qn(Z.hash),redirectedFrom:void 0,href:h})}let I;if("path"in C)I=fe({},C,{path:br(n,C.path,F.path).path});else{const Z=fe({},C.params);for(const u in Z)Z[u]==null&&delete Z[u];I=fe({},C,{params:m(C.params)}),F.params=m(F.params)}const z=t.resolve(I,F),ae=C.hash||"";z.params=f(d(z.params));const ce=Jc(r,fe({},C,{hash:Du(ae),path:z.path})),te=o.createHref(ce);return fe({fullPath:ce,hash:ae,query:r===ps?zu(C.query):C.query||{}},z,{redirectedFrom:void 0,href:te})}function T(C){return typeof C=="string"?br(n,C,a.value.path):fe({},C)}function S(C,F){if(c!==C)return Wt(8,{from:F,to:C})}function O(C){return x(C)}function H(C){return O(fe(T(C),{replace:!0}))}function j(C){const F=C.matched[C.matched.length-1];if(F&&F.redirect){const{redirect:I}=F;let z=typeof I=="function"?I(C):I;return typeof z=="string"&&(z=z.includes("?")||z.includes("#")?z=T(z):{path:z},z.params={}),fe({query:C.query,hash:C.hash,params:C.params},z)}}function x(C,F){const I=c=v(C),z=a.value,ae=C.state,ce=C.force,te=C.replace===!0,Z=j(I);if(Z)return x(fe(T(Z),{state:ae,force:ce,replace:te}),F||I);const u=I;u.redirectedFrom=F;let h;return!ce&&Qc(r,z,I)&&(h=Wt(16,{to:u,from:z}),Ae(z,z,!0,!1)),(h?Promise.resolve(h):G(u,z)).catch(_=>vt(_)?_:X(_,u,z)).then(_=>{if(_){if(vt(_,2))return x(fe(T(_.to),{state:ae,force:ce,replace:te}),F||u)}else _=Y(u,z,!0,te,ae);return U(u,z,_),_})}function w(C,F){const I=S(C,F);return I?Promise.reject(I):Promise.resolve()}function G(C,F){let I;const[z,ae,ce]=Gu(C,F);I=yr(z.reverse(),"beforeRouteLeave",C,F);for(const Z of z)Z.leaveGuards.forEach(u=>{I.push(ut(u,C,F))});const te=w.bind(null,C,F);return I.push(te),It(I).then(()=>{I=[];for(const Z of s.list())I.push(ut(Z,C,F));return I.push(te),It(I)}).then(()=>{I=yr(ae,"beforeRouteUpdate",C,F);for(const Z of ae)Z.updateGuards.forEach(u=>{I.push(ut(u,C,F))});return I.push(te),It(I)}).then(()=>{I=[];for(const Z of C.matched)if(Z.beforeEnter&&!F.matched.includes(Z))if(Array.isArray(Z.beforeEnter))for(const u of Z.beforeEnter)I.push(ut(u,C,F));else I.push(ut(Z.beforeEnter,C,F));return I.push(te),It(I)}).then(()=>(C.matched.forEach(Z=>Z.enterCallbacks={}),I=yr(ce,"beforeRouteEnter",C,F),I.push(te),It(I))).then(()=>{I=[];for(const Z of i.list())I.push(ut(Z,C,F));return I.push(te),It(I)}).catch(Z=>vt(Z,8)?Z:Promise.reject(Z))}function U(C,F,I){for(const z of l.list())z(C,F,I)}function Y(C,F,I,z,ae){const ce=S(C,F);if(ce)return ce;const te=F===Xe,Z=Nt?history.state:{};I&&(z||te?o.replace(C.fullPath,fe({scroll:te&&Z&&Z.scroll},ae)):o.push(C.fullPath,ae)),a.value=C,Ae(C,F,I,te),ye()}let y;function D(){y=o.listen((C,F,I)=>{const z=v(C),ae=j(z);if(ae){x(fe(ae,{replace:!0}),z).catch(hn);return}c=z;const ce=a.value;Nt&&su(ls(ce.fullPath,I.delta),ar()),G(z,ce).catch(te=>vt(te,12)?te:vt(te,2)?(x(te.to,z).then(Z=>{vt(Z,20)&&!I.delta&&I.type===wn.pop&&o.go(-1,!1)}).catch(hn),Promise.reject()):(I.delta&&o.go(-I.delta,!1),X(te,z,ce))).then(te=>{te=te||Y(z,ce,!1),te&&(I.delta?o.go(-I.delta,!1):I.type===wn.pop&&vt(te,20)&&o.go(-1,!1)),U(z,ce,te)}).catch(hn)})}let W=rn(),le=rn(),V;function X(C,F,I){ye(C);const z=le.list();return z.length?z.forEach(ae=>ae(C,F,I)):console.error(C),Promise.reject(C)}function ne(){return V&&a.value!==Xe?Promise.resolve():new Promise((C,F)=>{W.add([C,F])})}function ye(C){V||(V=!0,D(),W.list().forEach(([F,I])=>C?I(C):F()),W.reset())}function Ae(C,F,I,z){const{scrollBehavior:ae}=e;if(!Nt||!ae)return Promise.resolve();const ce=!I&&iu(ls(C.fullPath,0))||(z||!I)&&history.state&&history.state.scroll||null;return no().then(()=>ae(C,F,ce)).then(te=>te&&ou(te)).catch(te=>X(te,C,F))}const ke=C=>o.go(C);let Me;const Se=new Set;return{currentRoute:a,addRoute:E,removeRoute:p,hasRoute:g,getRoutes:b,resolve:v,options:e,push:O,replace:H,go:ke,back:()=>ke(-1),forward:()=>ke(1),beforeEach:s.add,beforeResolve:i.add,afterEach:l.add,onError:le.add,isReady:ne,install(C){const F=this;C.component("RouterLink",ju),C.component("RouterView",Ki),C.config.globalProperties.$router=F,Object.defineProperty(C.config.globalProperties,"$route",{enumerable:!0,get:()=>At(a)}),Nt&&!Me&&a.value===Xe&&(Me=!0,O(o.location).catch(ae=>{}));const I={};for(const ae in Xe)I[ae]=ge(()=>a.value[ae]);C.provide(lr,F),C.provide(po,Jt(I)),C.provide(Nr,a);const z=C.unmount;Se.add(C),C.unmount=function(){Se.delete(C),Se.size<1&&(c=Xe,y&&y(),a.value=Xe,Me=!1,V=!1),z()}}}}function It(e){return e.reduce((t,n)=>t.then(()=>n()),Promise.resolve())}function Gu(e,t){const n=[],r=[],o=[],s=Math.max(t.matched.length,e.matched.length);for(let i=0;iKt(c,l))?r.push(l):n.push(l));const a=e.matched[i];a&&(t.matched.find(c=>Kt(c,a))||o.push(a))}return[n,r,o]}function mo(){return Te(lr)}function go(){return Te(po)}const Yu=qe({setup(e,t){const n=Pe(!1);return Ze(()=>{n.value=!0}),()=>{var r,o;return n.value?(o=(r=t.slots).default)===null||o===void 0?void 0:o.call(r):null}}}),Ju="modulepreload",_s={},Qu="/solana-go-sdk/",N=function(t,n){return!n||n.length===0?t():Promise.all(n.map(r=>{if(r=`${Qu}${r}`,r in _s)return;_s[r]=!0;const o=r.endsWith(".css"),s=o?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${s}`))return;const i=document.createElement("link");if(i.rel=o?"stylesheet":Ju,o||(i.as="script",i.crossOrigin=""),i.href=r,document.head.appendChild(i),o)return new Promise((l,a)=>{i.addEventListener("load",l),i.addEventListener("error",a)})})).then(()=>t())},Wi={"v-8daa1a0e":oe(()=>N(()=>import("./index.html.04cad356.js"),[])),"v-59d0d0eb":oe(()=>N(()=>import("./memo.html.0c84df14.js"),[])),"v-280665e7":oe(()=>N(()=>import("./get-metadata.html.ce06a87a.js"),[])),"v-23bafe30":oe(()=>N(()=>import("./mint-a-nft.html.1e06d8d8.js"),[])),"v-a02bf734":oe(()=>N(()=>import("./sign-metadata.html.ad27d8d4.js"),[])),"v-b8f58dfe":oe(()=>N(()=>import("./get-signatures-for-address.html.fee9b0bb.js"),[])),"v-24f1ec82":oe(()=>N(()=>import("./create-account.html.f7bf0e2a.js"),[])),"v-6a1127a4":oe(()=>N(()=>import("./create-mint.html.4d530f84.js"),[])),"v-3079eed3":oe(()=>N(()=>import("./create-token-account.html.22925637.js"),[])),"v-35d7797c":oe(()=>N(()=>import("./get-mint.html.f401f049.js"),[])),"v-09e730af":oe(()=>N(()=>import("./get-sol-balance.html.578f37d1.js"),[])),"v-25cdf616":oe(()=>N(()=>import("./get-token-account.html.ab23e19a.js"),[])),"v-0f32b5a6":oe(()=>N(()=>import("./get-token-balance.html.37d5d04e.js"),[])),"v-41cbbd5e":oe(()=>N(()=>import("./mint-to.html.c01cbfdc.js"),[])),"v-79469b88":oe(()=>N(()=>import("./request-airdrop.html.3d12a5cb.js"),[])),"v-eec8ee88":oe(()=>N(()=>import("./token-transfer.html.a00e023f.js"),[])),"v-7c3a81e0":oe(()=>N(()=>import("./transfer.html.30a9e0f8.js"),[])),"v-6c8477c6":oe(()=>N(()=>import("./index.html.ab4ba558.js"),[])),"v-c5aa4956":oe(()=>N(()=>import("./create-nonce-account.html.d221497b.js"),[])),"v-ab1b707e":oe(()=>N(()=>import("./get-nonce-account-by-owner.html.4c9b1566.js"),[])),"v-7b499707":oe(()=>N(()=>import("./get-nonce-account.html.ac8bfed0.js"),[])),"v-068ebe3e":oe(()=>N(()=>import("./upgrade-nonce.html.3f10af1b.js"),[])),"v-5036c796":oe(()=>N(()=>import("./use-nonce.html.e9ee4223.js"),[])),"v-da536522":oe(()=>N(()=>import("./accounts.html.4d38c647.js"),[])),"v-231c922b":oe(()=>N(()=>import("./data.html.7beec709.js"),[])),"v-5586a7ea":oe(()=>N(()=>import("./hello.html.0c4f7db6.js"),[])),"v-254605e9":oe(()=>N(()=>import("./deactivate.html.1552dba3.js"),[])),"v-5f2dec78":oe(()=>N(()=>import("./delegate.html.892b180b.js"),[])),"v-2c025226":oe(()=>N(()=>import("./initialize-account.html.5dc86f3c.js"),[])),"v-10776a13":oe(()=>N(()=>import("./withdraw.html.99ffd08e.js"),[])),"v-3706649a":oe(()=>N(()=>import("./404.html.ca9a1c30.js"),[]))},Zu={"v-8daa1a0e":()=>N(()=>import("./index.html.aa82496b.js"),[]).then(({data:e})=>e),"v-59d0d0eb":()=>N(()=>import("./memo.html.7283ccff.js"),[]).then(({data:e})=>e),"v-280665e7":()=>N(()=>import("./get-metadata.html.2bbab957.js"),[]).then(({data:e})=>e),"v-23bafe30":()=>N(()=>import("./mint-a-nft.html.3f3b89f5.js"),[]).then(({data:e})=>e),"v-a02bf734":()=>N(()=>import("./sign-metadata.html.0570f274.js"),[]).then(({data:e})=>e),"v-b8f58dfe":()=>N(()=>import("./get-signatures-for-address.html.637d35dd.js"),[]).then(({data:e})=>e),"v-24f1ec82":()=>N(()=>import("./create-account.html.8cde0ffe.js"),[]).then(({data:e})=>e),"v-6a1127a4":()=>N(()=>import("./create-mint.html.8c737506.js"),[]).then(({data:e})=>e),"v-3079eed3":()=>N(()=>import("./create-token-account.html.3be4b61e.js"),[]).then(({data:e})=>e),"v-35d7797c":()=>N(()=>import("./get-mint.html.b4cc973b.js"),[]).then(({data:e})=>e),"v-09e730af":()=>N(()=>import("./get-sol-balance.html.6f961e64.js"),[]).then(({data:e})=>e),"v-25cdf616":()=>N(()=>import("./get-token-account.html.e4cf79d9.js"),[]).then(({data:e})=>e),"v-0f32b5a6":()=>N(()=>import("./get-token-balance.html.48dc74ba.js"),[]).then(({data:e})=>e),"v-41cbbd5e":()=>N(()=>import("./mint-to.html.fe63e0ea.js"),[]).then(({data:e})=>e),"v-79469b88":()=>N(()=>import("./request-airdrop.html.fa688e36.js"),[]).then(({data:e})=>e),"v-eec8ee88":()=>N(()=>import("./token-transfer.html.c870739e.js"),[]).then(({data:e})=>e),"v-7c3a81e0":()=>N(()=>import("./transfer.html.565e3105.js"),[]).then(({data:e})=>e),"v-6c8477c6":()=>N(()=>import("./index.html.53b060d9.js"),[]).then(({data:e})=>e),"v-c5aa4956":()=>N(()=>import("./create-nonce-account.html.09101beb.js"),[]).then(({data:e})=>e),"v-ab1b707e":()=>N(()=>import("./get-nonce-account-by-owner.html.e7678f5f.js"),[]).then(({data:e})=>e),"v-7b499707":()=>N(()=>import("./get-nonce-account.html.365f85e2.js"),[]).then(({data:e})=>e),"v-068ebe3e":()=>N(()=>import("./upgrade-nonce.html.c7e291c7.js"),[]).then(({data:e})=>e),"v-5036c796":()=>N(()=>import("./use-nonce.html.7b82dfda.js"),[]).then(({data:e})=>e),"v-da536522":()=>N(()=>import("./accounts.html.26bf1d29.js"),[]).then(({data:e})=>e),"v-231c922b":()=>N(()=>import("./data.html.22999d61.js"),[]).then(({data:e})=>e),"v-5586a7ea":()=>N(()=>import("./hello.html.fc8163f0.js"),[]).then(({data:e})=>e),"v-254605e9":()=>N(()=>import("./deactivate.html.a290904c.js"),[]).then(({data:e})=>e),"v-5f2dec78":()=>N(()=>import("./delegate.html.bfe61ede.js"),[]).then(({data:e})=>e),"v-2c025226":()=>N(()=>import("./initialize-account.html.1bb0c22c.js"),[]).then(({data:e})=>e),"v-10776a13":()=>N(()=>import("./withdraw.html.5e758645.js"),[]).then(({data:e})=>e),"v-3706649a":()=>N(()=>import("./404.html.e275e9a9.js"),[]).then(({data:e})=>e)},Gi=Pe(Zu),Yi=Zr({key:"",path:"",title:"",lang:"",frontmatter:{},excerpt:"",headers:[]}),tt=Pe(Yi),Zt=()=>tt;yo.webpackHot&&(__VUE_HMR_RUNTIME__.updatePageData=e=>{Gi.value[e.key]=()=>Promise.resolve(e),e.key===tt.value.key&&(tt.value=e)});const Ji=Symbol(""),Xu=()=>{const e=Te(Ji);if(!e)throw new Error("usePageFrontmatter() is called without provider.");return e},Qi=Symbol(""),ef=()=>{const e=Te(Qi);if(!e)throw new Error("usePageHead() is called without provider.");return e},tf=Symbol(""),Zi=Symbol(""),nf=()=>{const e=Te(Zi);if(!e)throw new Error("usePageLang() is called without provider.");return e},vo=Symbol(""),rf=()=>{const e=Te(vo);if(!e)throw new Error("useRouteLocale() is called without provider.");return e},of={base:"/solana-go-sdk/",lang:"en-US",title:"Solana Development With Go",description:"",head:[],locales:{}},ft=Pe(of),sf=()=>ft;yo.webpackHot&&(__VUE_HMR_RUNTIME__.updateSiteData=e=>{ft.value=e});const Xi=Symbol(""),cp=()=>{const e=Te(Xi);if(!e)throw new Error("useSiteLocaleData() is called without provider.");return e},lf=Symbol(""),_o=e=>{let t;e.pageKey?t=e.pageKey:t=Zt().value.key;const n=Wi[t];return n?ve(n):ve("div","404 Not Found")};_o.displayName="Content";_o.props={pageKey:{type:String,required:!1}};const af={"404":oe(()=>N(()=>import("./404.2fa22a2d.js"),[])),Layout:oe(()=>N(()=>import("./Layout.18d821ba.js"),[]))},cf=([e,t,n])=>e==="meta"&&t.name?`${e}.${t.name}`:["title","base"].includes(e)?e:e==="template"&&t.id?`${e}.${t.id}`:JSON.stringify([e,t,n]),uf=e=>{const t=new Set,n=[];return e.forEach(r=>{const o=cf(r);t.has(o)||(t.add(o),n.push(r))}),n},ff=e=>/^(https?:)?\/\//.test(e),up=e=>/^mailto:/.test(e),fp=e=>/^tel:/.test(e),el=e=>Object.prototype.toString.call(e)==="[object Object]",df=e=>e.replace(/\/$/,""),pf=e=>e.replace(/^\//,""),tl=(e,t)=>{const n=Object.keys(e).sort((r,o)=>{const s=o.split("/").length-r.split("/").length;return s!==0?s:o.length-r.length});for(const r of n)if(t.startsWith(r))return r;return"/"},bs=qe({name:"Vuepress",setup(){const e=Zt(),t=ge(()=>{let n;if(e.value.path){const r=e.value.frontmatter.layout;pe(r)?n=r:n="Layout"}else n="404";return af[n]||ec(n,!1)});return()=>ve(t.value)}}),xn=e=>e,cr=e=>e,hf=e=>ff(e)?e:`${sf().value.base}${pf(e)}`,bt=Jt({resolvePageData:async e=>{const t=Gi.value[e],n=await(t==null?void 0:t());return n!=null?n:Yi},resolvePageFrontmatter:e=>e.frontmatter,resolvePageHead:(e,t,n)=>{const r=pe(t.description)?t.description:n.description,o=[...J(t.head)?t.head:[],...n.head,["title",{},e],["meta",{name:"description",content:r}]];return uf(o)},resolvePageHeadTitle:(e,t)=>`${e.title?`${e.title} | `:""}${t.title}`,resolvePageLang:e=>e.lang||"en",resolveRouteLocale:(e,t)=>tl(e,t),resolveSiteLocaleData:(e,t)=>We(We({},e),e.locales[t])});const mf=ve("svg",{class:"external-link-icon",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false",x:"0px",y:"0px",viewBox:"0 0 100 100",width:"15",height:"15"},[ve("path",{fill:"currentColor",d:"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"}),ve("polygon",{fill:"currentColor",points:"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"})]),gf=qe({name:"ExternalLinkIcon",props:{locales:{type:Object,required:!1,default:()=>({})}},setup(e){const t=rf(),n=ge(()=>{var r;return(r=e.locales[t.value])!==null&&r!==void 0?r:{openInNewWindow:"open in new window"}});return()=>ve("span",[mf,ve("span",{class:"external-link-icon-sr-only"},n.value.openInNewWindow)])}}),vf={"/":{openInNewWindow:"open in new window"}};var _f=xn(({app:e})=>{e.component("ExternalLinkIcon",ve(gf,{locales:vf}))});/*! medium-zoom 1.0.6 | MIT License | https://github.com/francoischalifour/medium-zoom */var yt=Object.assign||function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{},r=window.Promise||function(y){function D(){}y(D,D)},o=function(y){var D=y.target;if(D===G){p();return}S.indexOf(D)!==-1&&b({target:D})},s=function(){if(!(H||!w.original)){var y=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(j-y)>x.scrollOffset&&setTimeout(p,150)}},i=function(y){var D=y.key||y.keyCode;(D==="Escape"||D==="Esc"||D===27)&&p()},l=function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},D=y;if(y.background&&(G.style.background=y.background),y.container&&y.container instanceof Object&&(D.container=yt({},x.container,y.container)),y.template){var W=Nn(y.template)?y.template:document.querySelector(y.template);D.template=W}return x=yt({},x,D),S.forEach(function(le){le.dispatchEvent(Bt("medium-zoom:update",{detail:{zoom:U}}))}),U},a=function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return e(yt({},x,y))},c=function(){for(var y=arguments.length,D=Array(y),W=0;W0?D.reduce(function(V,X){return[].concat(V,Es(X))},[]):S;return le.forEach(function(V){V.classList.remove("medium-zoom-image"),V.dispatchEvent(Bt("medium-zoom:detach",{detail:{zoom:U}}))}),S=S.filter(function(V){return le.indexOf(V)===-1}),U},m=function(y,D){var W=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(le){le.addEventListener("medium-zoom:"+y,D,W)}),O.push({type:"medium-zoom:"+y,listener:D,options:W}),U},d=function(y,D){var W=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(le){le.removeEventListener("medium-zoom:"+y,D,W)}),O=O.filter(function(le){return!(le.type==="medium-zoom:"+y&&le.listener.toString()===D.toString())}),U},E=function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},D=y.target,W=function(){var V={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},X=void 0,ne=void 0;if(x.container)if(x.container instanceof Object)V=yt({},V,x.container),X=V.width-V.left-V.right-x.margin*2,ne=V.height-V.top-V.bottom-x.margin*2;else{var ye=Nn(x.container)?x.container:document.querySelector(x.container),Ae=ye.getBoundingClientRect(),ke=Ae.width,Me=Ae.height,Se=Ae.left,Xt=Ae.top;V=yt({},V,{width:ke,height:Me,left:Se,top:Xt})}X=X||V.width-x.margin*2,ne=ne||V.height-x.margin*2;var C=w.zoomedHd||w.original,F=ys(C)?X:C.naturalWidth||X,I=ys(C)?ne:C.naturalHeight||ne,z=C.getBoundingClientRect(),ae=z.top,ce=z.left,te=z.width,Z=z.height,u=Math.min(F,X)/te,h=Math.min(I,ne)/Z,_=Math.min(u,h),P=(-ce+(X-te)/2+x.margin+V.left)/_,A=(-ae+(ne-Z)/2+x.margin+V.top)/_,k="scale("+_+") translate3d("+P+"px, "+A+"px, 0)";w.zoomed.style.transform=k,w.zoomedHd&&(w.zoomedHd.style.transform=k)};return new r(function(le){if(D&&S.indexOf(D)===-1){le(U);return}var V=function ke(){H=!1,w.zoomed.removeEventListener("transitionend",ke),w.original.dispatchEvent(Bt("medium-zoom:opened",{detail:{zoom:U}})),le(U)};if(w.zoomed){le(U);return}if(D)w.original=D;else if(S.length>0){var X=S;w.original=X[0]}else{le(U);return}if(w.original.dispatchEvent(Bt("medium-zoom:open",{detail:{zoom:U}})),j=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,H=!0,w.zoomed=Ef(w.original),document.body.appendChild(G),x.template){var ne=Nn(x.template)?x.template:document.querySelector(x.template);w.template=document.createElement("div"),w.template.appendChild(ne.content.cloneNode(!0)),document.body.appendChild(w.template)}if(document.body.appendChild(w.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),w.original.classList.add("medium-zoom-image--hidden"),w.zoomed.classList.add("medium-zoom-image--opened"),w.zoomed.addEventListener("click",p),w.zoomed.addEventListener("transitionend",V),w.original.getAttribute("data-zoom-src")){w.zoomedHd=w.zoomed.cloneNode(),w.zoomedHd.removeAttribute("srcset"),w.zoomedHd.removeAttribute("sizes"),w.zoomedHd.src=w.zoomed.getAttribute("data-zoom-src"),w.zoomedHd.onerror=function(){clearInterval(ye),console.warn("Unable to reach the zoom image target "+w.zoomedHd.src),w.zoomedHd=null,W()};var ye=setInterval(function(){w.zoomedHd.complete&&(clearInterval(ye),w.zoomedHd.classList.add("medium-zoom-image--opened"),w.zoomedHd.addEventListener("click",p),document.body.appendChild(w.zoomedHd),W())},10)}else if(w.original.hasAttribute("srcset")){w.zoomedHd=w.zoomed.cloneNode(),w.zoomedHd.removeAttribute("sizes"),w.zoomedHd.removeAttribute("loading");var Ae=w.zoomedHd.addEventListener("load",function(){w.zoomedHd.removeEventListener("load",Ae),w.zoomedHd.classList.add("medium-zoom-image--opened"),w.zoomedHd.addEventListener("click",p),document.body.appendChild(w.zoomedHd),W()})}else W()})},p=function(){return new r(function(y){if(H||!w.original){y(U);return}var D=function W(){w.original.classList.remove("medium-zoom-image--hidden"),document.body.removeChild(w.zoomed),w.zoomedHd&&document.body.removeChild(w.zoomedHd),document.body.removeChild(G),w.zoomed.classList.remove("medium-zoom-image--opened"),w.template&&document.body.removeChild(w.template),H=!1,w.zoomed.removeEventListener("transitionend",W),w.original.dispatchEvent(Bt("medium-zoom:closed",{detail:{zoom:U}})),w.original=null,w.zoomed=null,w.zoomedHd=null,w.template=null,y(U)};H=!0,document.body.classList.remove("medium-zoom--opened"),w.zoomed.style.transform="",w.zoomedHd&&(w.zoomedHd.style.transform=""),w.template&&(w.template.style.transition="opacity 150ms",w.template.style.opacity=0),w.original.dispatchEvent(Bt("medium-zoom:close",{detail:{zoom:U}})),w.zoomed.addEventListener("transitionend",D)})},b=function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},D=y.target;return w.original?p():E({target:D})},g=function(){return x},v=function(){return S},T=function(){return w.original},S=[],O=[],H=!1,j=0,x=n,w={original:null,zoomed:null,zoomedHd:null,template:null};Object.prototype.toString.call(t)==="[object Object]"?x=t:(t||typeof t=="string")&&c(t),x=yt({margin:0,background:"#fff",scrollOffset:40,container:null,template:null},x);var G=yf(x.background);document.addEventListener("click",o),document.addEventListener("keyup",i),document.addEventListener("scroll",s),window.addEventListener("resize",p);var U={open:E,close:p,toggle:b,update:l,clone:a,attach:c,detach:f,on:m,off:d,getOptions:g,getImages:v,getZoomedImage:T};return U};function Tf(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(!e||typeof document=="undefined")){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",n==="top"&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}var Cf=".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";Tf(Cf);var Af=wf;const xf=Symbol("mediumZoom");const Pf=".theme-default-content > img, .theme-default-content :not(a) > img",Sf={},Rf=300;var Of=xn(({app:e,router:t})=>{const n=Af(Sf);n.refresh=(r=Pf)=>{n.detach(),n.attach(r)},e.provide(xf,n),t.afterEach(()=>{setTimeout(()=>n.refresh(),Rf)})});const kf={navbar:[{text:"GitHub",link:"https://github.com/blocto/solana-go-sdk"}],locales:{"/":{selectLanguageName:"English",sidebar:[{text:"Tour",children:[{text:"Basic",children:[{text:"Create Account",link:"/tour/create-account"},{text:"Request Airdrop",link:"/tour/request-airdrop"},{text:"Get Balance",link:"/tour/get-sol-balance"},{text:"Transfer",link:"/tour/transfer"}]},{text:"Token",children:[{text:"Create Mint",link:"/tour/create-mint"},{text:"Get Mint",link:"/tour/get-mint"},{text:"Create Token Account",link:"/tour/create-token-account"},{text:"Get Token Account",link:"/tour/get-token-account"},{text:"Mint To",link:"/tour/mint-to"},{text:"Get Balance",link:"/tour/get-token-balance"},{text:"Transfer",link:"/tour/token-transfer"}]}]},{text:"NFT",children:[{text:"Mint a NFT",link:"/nft/mint-a-nft"},{text:"Get Metadata",link:"/nft/get-metadata"},{text:"Sign Metadata",link:"/nft/sign-metadata"}]},{text:"Advanced",children:[{text:"Add Memo",link:"/advanced/memo"},{text:"Durable Nonce",link:"/advanced/durable-nonce/README.md",children:[{text:"Create Nonce Account",link:"/advanced/durable-nonce/create-nonce-account"},{text:"Get Nonce Account",link:"/advanced/durable-nonce/get-nonce-account"},{text:"Use Nonce",link:"/advanced/durable-nonce/use-nonce"},{text:"Upgrade Nonce",link:"/advanced/durable-nonce/upgrade-nonce"},{text:"Get Nonce Account By Owner",link:"/advanced/durable-nonce/get-nonce-account-by-owner"}]}]},{text:"RPC",children:[{text:"Get Signatures For Address",link:"/rpc/get-signatures-for-address"}]},{text:"Program",children:[{text:"101",children:[{text:"Hello",link:"/programs/101/hello"},{text:"Accounts",link:"/programs/101/accounts"},{text:"Data",link:"/programs/101/data"}]},{text:"Stake",children:[{text:"Initialize Account",link:"/programs/stake/initialize-account"},{text:"Delegate (stake)",link:"/programs/stake/delegate"},{text:"Deactivate (unstake)",link:"/programs/stake/deactivate"},{text:"Withdraw",link:"/programs/stake/withdraw"}]}]}]}},logo:null,darkMode:!0,repo:null,selectLanguageText:"Languages",selectLanguageAriaLabel:"Select language",sidebar:"auto",sidebarDepth:2,editLink:!0,editLinkText:"Edit this page",lastUpdated:!0,lastUpdatedText:"Last Updated",contributors:!0,contributorsText:"Contributors",notFound:["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],backToHome:"Take me home",openInNewWindow:"open in new window",toggleDarkMode:"toggle dark mode",toggleSidebar:"toggle sidebar"},nl=Pe(kf),Lf=()=>nl;yo.webpackHot&&(__VUE_HMR_RUNTIME__.updateThemeData=e=>{nl.value=e});const rl=Symbol(""),If=()=>{const e=Te(rl);if(!e)throw new Error("useThemeLocaleData() is called without provider.");return e},Bf=(e,t)=>{var n;return We(We({},e),(n=e.locales)===null||n===void 0?void 0:n[t])};var Df=xn(({app:e})=>{const t=Lf(),n=e._context.provides[vo],r=ge(()=>Bf(t.value,n.value));e.provide(rl,r),Object.defineProperties(e.config.globalProperties,{$theme:{get(){return t.value}},$themeLocale:{get(){return r.value}}})});const Mf=qe({props:{type:{type:String,required:!1,default:"tip"},text:{type:String,required:!1,default:""},vertical:{type:String,required:!1,default:void 0}},setup(e){return(t,n)=>(Vt(),Wn("span",{class:Rt(["badge",e.type]),style:$t({verticalAlign:e.vertical})},[Pi(t.$slots,"default",{},()=>[ao(Rs(e.text),1)])],6))}});var Nf=qe({name:"CodeGroup",setup(e,{slots:t}){const n=Pe(-1),r=Pe([]),o=(l=n.value)=>{l{l>0?n.value=l-1:n.value=r.value.length-1,r.value[n.value].focus()},i=(l,a)=>{l.key===" "||l.key==="Enter"?(l.preventDefault(),n.value=a):l.key==="ArrowRight"?(l.preventDefault(),o(a)):l.key==="ArrowLeft"&&(l.preventDefault(),s(a))};return()=>{var l;const a=(((l=t.default)===null||l===void 0?void 0:l.call(t))||[]).filter(c=>c.type.name==="CodeGroupItem").map(c=>(c.props===null&&(c.props={}),c));return a.length===0?null:(n.value<0||n.value>a.length-1?(n.value=a.findIndex(c=>c.props.active===""||c.props.active===!0),n.value===-1&&(n.value=0)):a.forEach((c,f)=>{c.props.active=f===n.value}),ve("div",{class:"code-group"},[ve("div",{class:"code-group__nav"},ve("ul",{class:"code-group__ul"},a.map((c,f)=>{const m=f===n.value;return ve("li",{class:"code-group__li"},ve("button",{ref:d=>{d&&(r.value[f]=d)},class:{"code-group__nav-tab":!0,"code-group__nav-tab-active":m},ariaPressed:m,ariaExpanded:m,onClick:()=>n.value=f,onKeydown:d=>i(d,f)},c.props.title))}))),a]))}}});const Hf=["aria-selected"],Ff=qe({name:"CodeGroupItem"}),zf=qe(Sn(We({},Ff),{props:{title:{type:String,required:!0},active:{type:Boolean,required:!1,default:!1}},setup(e){return(t,n)=>(Vt(),Wn("div",{class:Rt(["code-group-item",{"code-group-item__active":e.active}]),"aria-selected":e.active},[Pi(t.$slots,"default")],10,Hf))}}));function ol(e){return kl()?(Ll(e),!0):!1}const Pn=typeof window!="undefined",$f=e=>typeof e=="string",Er=()=>{};function Vf(e,t){function n(...r){e(()=>t.apply(this,r),{fn:t,thisArg:this,args:r})}return n}const jf=e=>e();var ws=Object.getOwnPropertySymbols,Uf=Object.prototype.hasOwnProperty,qf=Object.prototype.propertyIsEnumerable,Kf=(e,t)=>{var n={};for(var r in e)Uf.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ws)for(var r of ws(e))t.indexOf(r)<0&&qf.call(e,r)&&(n[r]=e[r]);return n};function Wf(e,t,n={}){const r=n,{eventFilter:o=jf}=r,s=Kf(r,["eventFilter"]);return Je(e,Vf(o,t),s)}function Gf(e,t=!0){Ri()?Ze(e):t?e():no(e)}const Zn=Pn?window:void 0;Pn&&window.document;Pn&&window.navigator;Pn&&window.location;function Yf(...e){let t,n,r,o;if($f(e[0])?([n,r,o]=e,t=Zn):[t,n,r,o]=e,!t)return Er;let s=Er;const i=Je(()=>At(t),a=>{s(),!!a&&(a.addEventListener(n,r,o),s=()=>{a.removeEventListener(n,r,o),s=Er})},{immediate:!0,flush:"post"}),l=()=>{i(),s()};return ol(l),l}function Jf(e,t={}){const{window:n=Zn}=t;let r;const o=Pe(!1),s=()=>{!n||(r||(r=n.matchMedia(e)),o.value=r.matches)};return Gf(()=>{s(),!!r&&("addEventListener"in r?r.addEventListener("change",s):r.addListener(s),ol(()=>{"removeEventListener"in s?r.removeEventListener("change",s):r.removeListener(s)}))}),o}const zr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},$r="__vueuse_ssr_handlers__";zr[$r]=zr[$r]||{};const Qf=zr[$r];function Zf(e,t){return Qf[e]||t}function Xf(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"||Array.isArray(e)?"object":Number.isNaN(e)?"any":"number"}const ed={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))}};function td(e,t,n,r={}){var o;const{flush:s="pre",deep:i=!0,listenToStorageChanges:l=!0,writeDefaults:a=!0,shallow:c,window:f=Zn,eventFilter:m,onError:d=T=>{console.error(T)}}=r,E=At(t),p=Xf(E),b=(c?Qs:Pe)(t),g=(o=r.serializer)!=null?o:ed[p];if(!n)try{n=Zf("getDefaultStorage",()=>{var T;return(T=Zn)==null?void 0:T.localStorage})()}catch(T){d(T)}function v(T){if(!(!n||T&&T.key!==e))try{const S=T?T.newValue:n.getItem(e);S==null?(b.value=E,a&&E!==null&&n.setItem(e,g.write(E))):typeof S!="string"?b.value=S:b.value=g.read(S)}catch(S){d(S)}}return v(),f&&l&&Yf(f,"storage",T=>setTimeout(()=>v(T),0)),n&&Wf(b,()=>{try{b.value==null?n.removeItem(e):n.setItem(e,g.write(b.value))}catch(T){d(T)}},{flush:s,deep:i,eventFilter:m}),b}function nd(e){return Jf("(prefers-color-scheme: dark)",e)}var Ts,Cs;Pn&&(window==null?void 0:window.navigator)&&((Ts=window==null?void 0:window.navigator)==null?void 0:Ts.platform)&&/iP(ad|hone|od)/.test((Cs=window==null?void 0:window.navigator)==null?void 0:Cs.platform);var rd=Object.defineProperty,As=Object.getOwnPropertySymbols,od=Object.prototype.hasOwnProperty,sd=Object.prototype.propertyIsEnumerable,xs=(e,t,n)=>t in e?rd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,id=(e,t)=>{for(var n in t||(t={}))od.call(t,n)&&xs(e,n,t[n]);if(As)for(var n of As(t))sd.call(t,n)&&xs(e,n,t[n]);return e};const ld={top:0,left:0,bottom:0,right:0,height:0,width:0};id({text:""},ld);const sl=Symbol(""),dp=()=>{const e=Te(sl);if(!e)throw new Error("useDarkMode() is called without provider.");return e},ad=()=>{const e=cl(),t=nd(),n=td("vuepress-color-scheme","auto"),r=ge({get(){return e.value.darkMode?n.value==="auto"?t.value:n.value==="dark":!1},set(o){o===t.value?n.value="auto":n.value=o?"dark":"light"}});xt(sl,r),cd(r)},cd=e=>{const t=(n=e.value)=>{const r=window==null?void 0:window.document.querySelector("html");r==null||r.classList.toggle("dark",n)};Ze(()=>{Je(e,t,{immediate:!0})}),io(()=>t())},il=(...e)=>{const n=mo().resolve(...e),r=n.matched[n.matched.length-1];if(!(r==null?void 0:r.redirect))return n;const{redirect:o}=r,s=ee(o)?o(n):o,i=pe(s)?{path:s}:s;return il(We({hash:n.hash,query:n.query,params:n.params},i))},ud=e=>{const t=il(e);return{text:t.meta.title||e,link:t.name==="404"?e:t.fullPath}};let wr=null,on=null;const fd={wait:()=>wr,pending:()=>{wr=new Promise(e=>on=e)},resolve:()=>{on==null||on(),wr=null,on=null}},dd=()=>fd,ll=Symbol("sidebarItems"),pp=()=>{const e=Te(ll);if(!e)throw new Error("useSidebarItems() is called without provider.");return e},pd=()=>{const e=cl(),t=Xu(),n=ge(()=>hd(t.value,e.value));xt(ll,n)},hd=(e,t)=>{var n,r,o,s;const i=(r=(n=e.sidebar)!==null&&n!==void 0?n:t.sidebar)!==null&&r!==void 0?r:"auto",l=(s=(o=e.sidebarDepth)!==null&&o!==void 0?o:t.sidebarDepth)!==null&&s!==void 0?s:2;return e.home||i===!1?[]:i==="auto"?gd(l):J(i)?al(i,l):el(i)?vd(i,l):[]},md=(e,t)=>({text:e.title,link:`#${e.slug}`,children:bo(e.children,t)}),bo=(e,t)=>t>0?e.map(n=>md(n,t-1)):[],gd=e=>{const t=Zt();return[{text:t.value.title,children:bo(t.value.headers,e)}]},al=(e,t)=>{const n=go(),r=Zt(),o=s=>{var i;let l;if(pe(s)?l=ud(s):l=s,l.children)return Sn(We({},l),{children:l.children.map(a=>o(a))});if(l.link===n.path){const a=((i=r.value.headers[0])===null||i===void 0?void 0:i.level)===1?r.value.headers[0].children:r.value.headers;return Sn(We({},l),{children:bo(a,t)})}return l};return e.map(s=>o(s))},vd=(e,t)=>{var n;const r=go(),o=tl(e,r.path),s=(n=e[o])!==null&&n!==void 0?n:[];return al(s,t)},cl=()=>If();var _d=xn(({app:e,router:t})=>{e.component("Badge",Mf),e.component("CodeGroup",Nf),e.component("CodeGroupItem",zf),e.component("NavbarSearch",()=>{const r=e.component("Docsearch")||e.component("SearchBox");return r?ve(r):null});const n=t.options.scrollBehavior;t.options.scrollBehavior=async(...r)=>(await dd().wait(),n(...r))});var bd=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n};const yd={name:"CodeCopy",props:{parent:Object,code:String,options:{align:String,color:String,backgroundTransition:Boolean,backgroundColor:String,successText:String,successTextColor:String,staticIcon:Boolean}},data(){return{success:!1,originalBackground:null,originalTransition:null}},computed:{alignStyle(){let e={};return e[this.options.align]="7.5px",e},iconClass(){return this.options.staticIcon?"":"hover"}},mounted(){this.originalTransition=this.parent.style.transition,this.originalBackground=this.parent.style.background},beforeDestroy(){this.parent.style.transition=this.originalTransition,this.parent.style.background=this.originalBackground},methods:{hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},copyToClipboard(e){if(navigator.clipboard)navigator.clipboard.writeText(this.code).then(()=>{this.setSuccessTransitions()},()=>{});else{let t=document.createElement("textarea");document.body.appendChild(t),t.value=this.code,t.select(),document.execCommand("Copy"),t.remove(),this.setSuccessTransitions()}},setSuccessTransitions(){if(clearTimeout(this.successTimeout),this.options.backgroundTransition){this.parent.style.transition="background 350ms";let e=this.hexToRgb(this.options.backgroundColor);this.parent.style.background=`rgba(${e.r}, ${e.g}, ${e.b}, 0.1)`}this.success=!0,this.successTimeout=setTimeout(()=>{this.options.backgroundTransition&&(this.parent.style.background=this.originalBackground,this.parent.style.transition=this.originalTransition),this.success=!1},500)}}},Ed=e=>(va("data-v-51dd6513"),e=e(),_a(),e),wd={class:"code-copy"},Td=Ed(()=>En("path",{fill:"none",d:"M0 0h24v24H0z"},null,-1)),Cd=["fill"];function Ad(e,t,n,r,o,s){return Vt(),Wn("div",wd,[(Vt(),Wn("svg",{onClick:t[0]||(t[0]=(...i)=>s.copyToClipboard&&s.copyToClipboard(...i)),xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",class:Rt(s.iconClass),style:$t(s.alignStyle)},[Td,En("path",{fill:n.options.color,d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"},null,8,Cd)],6)),En("span",{class:Rt(o.success?"success":""),style:$t(We({color:n.options.successTextColor},s.alignStyle))},Rs(n.options.successText),7)])}var ul=bd(yd,[["render",Ad],["__scopeId","data-v-51dd6513"]]),xd=xn(({app:e,router:t,siteData:n})=>{e.component("CodeCopy",ul)});const Pd=[_f,Of,Df,_d,xd];function fl(e,t,n){var r,o,s;t===void 0&&(t=50),n===void 0&&(n={});var i=(r=n.isImmediate)!=null&&r,l=(o=n.callback)!=null&&o,a=n.maxWait,c=Date.now(),f=[];function m(){if(a!==void 0){var E=Date.now()-c;if(E+t>=a)return a-E}return t}var d=function(){var E=[].slice.call(arguments),p=this;return new Promise(function(b,g){var v=i&&s===void 0;if(s!==void 0&&clearTimeout(s),s=setTimeout(function(){if(s=void 0,c=Date.now(),!i){var S=e.apply(p,E);l&&l(S),f.forEach(function(O){return(0,O.resolve)(S)}),f=[]}},m()),v){var T=e.apply(p,E);return l&&l(T),b(T)}f.push({resolve:b,reject:g})})};return d.cancel=function(E){s!==void 0&&clearTimeout(s),f.forEach(function(p){return(0,p.reject)(E)}),f=[]},d}const Ps=()=>window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,Sd=()=>window.scrollTo({top:0,behavior:"smooth"});const Rd=qe({name:"BackToTop",setup(){const e=Pe(0),t=ge(()=>e.value>300),n=fl(()=>{e.value=Ps()},100);Ze(()=>{e.value=Ps(),window.addEventListener("scroll",()=>n())});const r=ve("div",{class:"back-to-top",onClick:Sd});return()=>ve(fo,{name:"back-to-top"},{default:()=>t.value?r:null})}}),Od=[Rd],kd=({headerLinkSelector:e,headerAnchorSelector:t,delay:n,offset:r=5})=>{const o=mo(),s=Zt(),l=fl(()=>{var a,c,f,m;const d=Array.from(document.querySelectorAll(e)),p=Array.from(document.querySelectorAll(t)).filter(S=>d.some(O=>O.hash===S.hash)),b=Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop),g=window.innerHeight+b,v=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),T=Math.abs(v-g)=((c=(a=O.parentElement)===null||a===void 0?void 0:a.offsetTop)!==null&&c!==void 0?c:0)-r,w=!H||b<((m=(f=H.parentElement)===null||f===void 0?void 0:f.offsetTop)!==null&&m!==void 0?m:0)-r;if(!(j||x&&w))continue;const U=decodeURIComponent(o.currentRoute.value.hash),Y=decodeURIComponent(O.hash);if(U===Y)return;if(T){for(let y=S+1;y{l(),window.addEventListener("scroll",l)}),sr(()=>{window.removeEventListener("scroll",l)}),Je(()=>s.value.path,l)},Ld=async(e,...t)=>{const{scrollBehavior:n}=e.options;e.options.scrollBehavior=void 0,await e.replace(...t).finally(()=>e.options.scrollBehavior=n)},Id="a.sidebar-item",Bd=".header-anchor",Dd=300,Md=5;var Nd=cr(()=>{kd({headerLinkSelector:Id,headerAnchorSelector:Bd,delay:Dd,offset:Md})}),Hd=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Hn={exports:{}};/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress + * @license MIT */(function(e,t){(function(n,r){e.exports=r()})(Hd,function(){var n={};n.version="0.2.0";var r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};n.configure=function(p){var b,g;for(b in p)g=p[b],g!==void 0&&p.hasOwnProperty(b)&&(r[b]=g);return this},n.status=null,n.set=function(p){var b=n.isStarted();p=o(p,r.minimum,1),n.status=p===1?null:p;var g=n.render(!b),v=g.querySelector(r.barSelector),T=r.speed,S=r.easing;return g.offsetWidth,l(function(O){r.positionUsing===""&&(r.positionUsing=n.getPositioningCSS()),a(v,i(p,T,S)),p===1?(a(g,{transition:"none",opacity:1}),g.offsetWidth,setTimeout(function(){a(g,{transition:"all "+T+"ms linear",opacity:0}),setTimeout(function(){n.remove(),O()},T)},T)):setTimeout(O,T)}),this},n.isStarted=function(){return typeof n.status=="number"},n.start=function(){n.status||n.set(0);var p=function(){setTimeout(function(){!n.status||(n.trickle(),p())},r.trickleSpeed)};return r.trickle&&p(),this},n.done=function(p){return!p&&!n.status?this:n.inc(.3+.5*Math.random()).set(1)},n.inc=function(p){var b=n.status;return b?(typeof p!="number"&&(p=(1-b)*o(Math.random()*b,.1,.95)),b=o(b+p,0,.994),n.set(b)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},function(){var p=0,b=0;n.promise=function(g){return!g||g.state()==="resolved"?this:(b===0&&n.start(),p++,b++,g.always(function(){b--,b===0?(p=0,n.done()):n.set((p-b)/p)}),this)}}(),n.render=function(p){if(n.isRendered())return document.getElementById("nprogress");f(document.documentElement,"nprogress-busy");var b=document.createElement("div");b.id="nprogress",b.innerHTML=r.template;var g=b.querySelector(r.barSelector),v=p?"-100":s(n.status||0),T=document.querySelector(r.parent),S;return a(g,{transition:"all 0 linear",transform:"translate3d("+v+"%,0,0)"}),r.showSpinner||(S=b.querySelector(r.spinnerSelector),S&&E(S)),T!=document.body&&f(T,"nprogress-custom-parent"),T.appendChild(b),b},n.remove=function(){m(document.documentElement,"nprogress-busy"),m(document.querySelector(r.parent),"nprogress-custom-parent");var p=document.getElementById("nprogress");p&&E(p)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var p=document.body.style,b="WebkitTransform"in p?"Webkit":"MozTransform"in p?"Moz":"msTransform"in p?"ms":"OTransform"in p?"O":"";return b+"Perspective"in p?"translate3d":b+"Transform"in p?"translate":"margin"};function o(p,b,g){return pg?g:p}function s(p){return(-1+p)*100}function i(p,b,g){var v;return r.positionUsing==="translate3d"?v={transform:"translate3d("+s(p)+"%,0,0)"}:r.positionUsing==="translate"?v={transform:"translate("+s(p)+"%,0)"}:v={"margin-left":s(p)+"%"},v.transition="all "+b+"ms "+g,v}var l=function(){var p=[];function b(){var g=p.shift();g&&g(b)}return function(g){p.push(g),p.length==1&&b()}}(),a=function(){var p=["Webkit","O","Moz","ms"],b={};function g(O){return O.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(H,j){return j.toUpperCase()})}function v(O){var H=document.body.style;if(O in H)return O;for(var j=p.length,x=O.charAt(0).toUpperCase()+O.slice(1),w;j--;)if(w=p[j]+x,w in H)return w;return O}function T(O){return O=g(O),b[O]||(b[O]=v(O))}function S(O,H,j){H=T(H),O.style[H]=j}return function(O,H){var j=arguments,x,w;if(j.length==2)for(x in H)w=H[x],w!==void 0&&H.hasOwnProperty(x)&&S(O,x,w);else S(O,j[1],j[2])}}();function c(p,b){var g=typeof p=="string"?p:d(p);return g.indexOf(" "+b+" ")>=0}function f(p,b){var g=d(p),v=g+b;c(g,b)||(p.className=v.substring(1))}function m(p,b){var g=d(p),v;!c(p,b)||(v=g.replace(" "+b+" "," "),p.className=v.substring(1,v.length-1))}function d(p){return(" "+(p.className||"")+" ").replace(/\s+/gi," ")}function E(p){p&&p.parentNode&&p.parentNode.removeChild(p)}return n})})(Hn);const Fd=()=>{Ze(()=>{const e=mo(),t=new Set;t.add(e.currentRoute.value.path),Hn.exports.configure({showSpinner:!1}),e.beforeEach(n=>{t.has(n.path)||Hn.exports.start()}),e.afterEach(n=>{t.add(n.path),Hn.exports.done()})})};var zd=cr(()=>{Fd()}),$d=cr(()=>{ad(),pd()});var Vd=cr(()=>{const e=Zt(),t=()=>{setTimeout(()=>{document.querySelectorAll('div[class*="language-"]').forEach(n=>{if(n.classList.contains("code-copy-added"))return;let r={align:"bottom",color:"#BBBBBB",backgroundTransition:!0,backgroundColor:"#0075b8",successText:"Copied!",successTextColor:"#BBBBBB",staticIcon:!1},o=Uc(ul,{parent:n,code:n.querySelector("pre").innerText,options:r}),s=document.createElement("div");n.appendChild(s),o.mount(s),n.classList.add("code-copy-added")})},100)};return Ze(()=>{t(),window.addEventListener("snippetors-vuepress-plugin-code-copy-update-event",t)}),sr(()=>{window.removeEventListener("snippetors-vuepress-plugin-code-copy-update-event",t)}),di(()=>{t()}),Je(()=>e.value.path,t),t});const jd=[Nd,zd,$d,Vd],Ud=[["v-8daa1a0e","/",{title:"Solana Development With Go"},["/index.html","/README.md"]],["v-59d0d0eb","/advanced/memo.html",{title:"Add Memo"},["/advanced/memo","/advanced/memo.md"]],["v-280665e7","/nft/get-metadata.html",{title:"Get Token Metadata"},["/nft/get-metadata","/nft/get-metadata.md"]],["v-23bafe30","/nft/mint-a-nft.html",{title:"Mint A NFT"},["/nft/mint-a-nft","/nft/mint-a-nft.md"]],["v-a02bf734","/nft/sign-metadata.html",{title:"Sign Metadata"},["/nft/sign-metadata","/nft/sign-metadata.md"]],["v-b8f58dfe","/rpc/get-signatures-for-address.html",{title:"Get Signatures For Address"},["/rpc/get-signatures-for-address","/rpc/get-signatures-for-address.md"]],["v-24f1ec82","/tour/create-account.html",{title:"Create Account"},["/tour/create-account","/tour/create-account.md"]],["v-6a1127a4","/tour/create-mint.html",{title:"Create Mint"},["/tour/create-mint","/tour/create-mint.md"]],["v-3079eed3","/tour/create-token-account.html",{title:"Create Token Account"},["/tour/create-token-account","/tour/create-token-account.md"]],["v-35d7797c","/tour/get-mint.html",{title:"Get Mint"},["/tour/get-mint","/tour/get-mint.md"]],["v-09e730af","/tour/get-sol-balance.html",{title:"Get Balance"},["/tour/get-sol-balance","/tour/get-sol-balance.md"]],["v-25cdf616","/tour/get-token-account.html",{title:"Get Token Account"},["/tour/get-token-account","/tour/get-token-account.md"]],["v-0f32b5a6","/tour/get-token-balance.html",{title:"Get Token Balance"},["/tour/get-token-balance","/tour/get-token-balance.md"]],["v-41cbbd5e","/tour/mint-to.html",{title:"Mint To"},["/tour/mint-to","/tour/mint-to.md"]],["v-79469b88","/tour/request-airdrop.html",{title:"Request Airdrop"},["/tour/request-airdrop","/tour/request-airdrop.md"]],["v-eec8ee88","/tour/token-transfer.html",{title:"Token Transfer"},["/tour/token-transfer","/tour/token-transfer.md"]],["v-7c3a81e0","/tour/transfer.html",{title:"Transfer"},["/tour/transfer","/tour/transfer.md"]],["v-6c8477c6","/advanced/durable-nonce/",{title:"Durable Nonce"},["/advanced/durable-nonce/index.html","/advanced/durable-nonce/README.md"]],["v-c5aa4956","/advanced/durable-nonce/create-nonce-account.html",{title:"Create Nonce Account"},["/advanced/durable-nonce/create-nonce-account","/advanced/durable-nonce/create-nonce-account.md"]],["v-ab1b707e","/advanced/durable-nonce/get-nonce-account-by-owner.html",{title:"Get Nonce Account By Owner"},["/advanced/durable-nonce/get-nonce-account-by-owner","/advanced/durable-nonce/get-nonce-account-by-owner.md"]],["v-7b499707","/advanced/durable-nonce/get-nonce-account.html",{title:"Get Nonce Account"},["/advanced/durable-nonce/get-nonce-account","/advanced/durable-nonce/get-nonce-account.md"]],["v-068ebe3e","/advanced/durable-nonce/upgrade-nonce.html",{title:"Upgrade Nonce"},["/advanced/durable-nonce/upgrade-nonce","/advanced/durable-nonce/upgrade-nonce.md"]],["v-5036c796","/advanced/durable-nonce/use-nonce.html",{title:"Use Nonce"},["/advanced/durable-nonce/use-nonce","/advanced/durable-nonce/use-nonce.md"]],["v-da536522","/programs/101/accounts.html",{title:"Accounts"},["/programs/101/accounts","/programs/101/accounts.md"]],["v-231c922b","/programs/101/data.html",{title:"Data"},["/programs/101/data","/programs/101/data.md"]],["v-5586a7ea","/programs/101/hello.html",{title:"Hello"},["/programs/101/hello","/programs/101/hello.md"]],["v-254605e9","/programs/stake/deactivate.html",{title:"Deactivate (unstake)"},["/programs/stake/deactivate","/programs/stake/deactivate.md"]],["v-5f2dec78","/programs/stake/delegate.html",{title:"Delegate (stake)"},["/programs/stake/delegate","/programs/stake/delegate.md"]],["v-2c025226","/programs/stake/initialize-account.html",{title:"Initialize Account"},["/programs/stake/initialize-account","/programs/stake/initialize-account.md"]],["v-10776a13","/programs/stake/withdraw.html",{title:"Withdraw"},["/programs/stake/withdraw","/programs/stake/withdraw.md"]],["v-3706649a","/404.html",{title:""},["/404"]]],qd=Ud.reduce((e,[t,n,r,o])=>(e.push({name:t,path:n,component:bs,meta:r},...o.map(s=>({path:s,redirect:n}))),e),[{name:"404",path:"/:catchAll(.*)",component:bs}]),Kd=uu,Wd=()=>{const e=Wu({history:Kd(df(ft.value.base)),routes:qd,scrollBehavior:(t,n,r)=>r||(t.hash?{el:t.hash}:{top:0})});return e.beforeResolve(async(t,n)=>{var r;(t.path!==n.path||n===Xe)&&([tt.value]=await Promise.all([bt.resolvePageData(t.name),(r=Wi[t.name])===null||r===void 0?void 0:r.__asyncLoader()]))}),e},Gd=e=>{e.component("ClientOnly",Yu),e.component("Content",_o)},Yd=(e,t)=>{const n=ge(()=>bt.resolveRouteLocale(ft.value.locales,t.currentRoute.value.path)),r=ge(()=>bt.resolveSiteLocaleData(ft.value,n.value)),o=ge(()=>bt.resolvePageFrontmatter(tt.value)),s=ge(()=>bt.resolvePageHeadTitle(tt.value,r.value)),i=ge(()=>bt.resolvePageHead(s.value,o.value,r.value)),l=ge(()=>bt.resolvePageLang(tt.value));return e.provide(vo,n),e.provide(Xi,r),e.provide(Ji,o),e.provide(tf,s),e.provide(Qi,i),e.provide(Zi,l),Object.defineProperties(e.config.globalProperties,{$frontmatter:{get:()=>o.value},$head:{get:()=>i.value},$headTitle:{get:()=>s.value},$lang:{get:()=>l.value},$page:{get:()=>tt.value},$routeLocale:{get:()=>n.value},$site:{get:()=>ft.value},$siteLocale:{get:()=>r.value},$withBase:{get:()=>hf}}),{pageData:tt,pageFrontmatter:o,pageHead:i,pageHeadTitle:s,pageLang:l,routeLocale:n,siteData:ft,siteLocaleData:r}},Jd=()=>{const e=go(),t=ef(),n=nf(),r=Pe([]),o=()=>{t.value.forEach(i=>{const l=Qd(i);l&&r.value.push(l)})},s=()=>{document.documentElement.lang=n.value,r.value.forEach(i=>{i.parentNode===document.head&&document.head.removeChild(i)}),r.value.splice(0,r.value.length),t.value.forEach(i=>{const l=Zd(i);l!==null&&(document.head.appendChild(l),r.value.push(l))})};xt(lf,s),Ze(()=>{o(),s(),Je(()=>e.path,()=>s())})},Qd=([e,t,n=""])=>{const r=Object.entries(t).map(([l,a])=>pe(a)?`[${l}="${a}"]`:a===!0?`[${l}]`:"").join(""),o=`head > ${e}${r}`;return Array.from(document.querySelectorAll(o)).find(l=>l.innerText===n)||null},Zd=([e,t,n])=>{if(!pe(e))return null;const r=document.createElement(e);return el(t)&&Object.entries(t).forEach(([o,s])=>{pe(s)?r.setAttribute(o,s):s===!0&&r.setAttribute(o,"")}),pe(n)&&r.appendChild(document.createTextNode(n)),r},Xd=qc,ep=async()=>{const e=Xd({name:"VuepressApp",setup(){Jd();for(const n of jd)n();return()=>[ve(Ki),...Od.map(n=>ve(n))]}}),t=Wd();Gd(e),Yd(e,t);for(const n of Pd)await n({app:e,router:t,siteData:ft});return e.use(t),{app:e,router:t}};ep().then(({app:e,router:t})=>{t.isReady().then(()=>{e.mount("#app")})});export{sf as A,cp as B,dp as C,ve as D,hf as E,Oe as F,Yu as G,Rt as H,Pe as I,Je as J,rp as K,ap as L,pf as M,df as N,mo as O,pe as P,ud as Q,Ze as R,$t as S,fo as T,Zt as U,pp as V,el as W,lp as X,io as Y,dd as Z,bd as _,En as a,_e as b,Wn as c,ep as createVueApp,ao as d,op as e,qe as f,cl as g,At as h,Xu as i,ge as j,J as k,ip as l,sp as m,go as n,Vt as o,np as p,Ai as q,ec as r,ic as s,Rs as t,rf as u,Pi as v,ba as w,ff as x,up as y,fp as z}; diff --git a/assets/back-to-top.8efcbe56.svg b/assets/back-to-top.8efcbe56.svg new file mode 100644 index 00000000..83236781 --- /dev/null +++ b/assets/back-to-top.8efcbe56.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/create-account.html.8cde0ffe.js b/assets/create-account.html.8cde0ffe.js new file mode 100644 index 00000000..430c60cc --- /dev/null +++ b/assets/create-account.html.8cde0ffe.js @@ -0,0 +1 @@ +const e={key:"v-24f1ec82",path:"/tour/create-account.html",title:"Create Account",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"Create a new account",slug:"create-a-new-account",children:[]},{level:2,title:"Recover from a key",slug:"recover-from-a-key",children:[{level:3,title:"Base58",slug:"base58",children:[]},{level:3,title:"Bytes",slug:"bytes",children:[]},{level:3,title:"BIP 39",slug:"bip-39",children:[]},{level:3,title:"BIP 44",slug:"bip-44",children:[]}]},{level:2,title:"Full Code",slug:"full-code",children:[]}],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/create-account.md"};export{e as data}; diff --git a/assets/create-account.html.f7bf0e2a.js b/assets/create-account.html.f7bf0e2a.js new file mode 100644 index 00000000..232ccf89 --- /dev/null +++ b/assets/create-account.html.f7bf0e2a.js @@ -0,0 +1,97 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},p=s(`

Create Account

An account is a basic identity on chain.

Create a new account

		account := types.NewAccount()
+
1

Recover from a key

Base58

		account, _ := types.AccountFromBase58("28WJTTqMuurAfz6yqeTrFMXeFd91uzi9i1AW6F5KyHQDS9siXb8TquAuatvLuCEYdggyeiNKLAUr3w7Czmmf2Rav")
+
1

Bytes

		account, _ := types.AccountFromBytes([]byte{
+			56, 125, 59, 118, 230, 173, 152, 169, 197, 34,
+			168, 187, 217, 160, 119, 204, 124, 69, 52, 136,
+			214, 49, 207, 234, 79, 70, 83, 224, 1, 224, 36,
+			247, 131, 83, 164, 85, 139, 215, 183, 148, 79,
+			198, 74, 93, 156, 157, 208, 99, 221, 127, 51,
+			156, 43, 196, 101, 144, 104, 252, 221, 108,
+			245, 104, 13, 151,
+		})
+
1
2
3
4
5
6
7
8
9

BIP 39

		mnemonic := "pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		account, _ := types.AccountFromSeed(seed[:32])
+
1
2
3

BIP 44

		mnemonic := "neither lonely flavor argue grass remind eye tag avocado spot unusual intact"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		path := \`m/44'/501'/0'/0'\`
+		derivedKey, _ := hdwallet.Derived(path, seed)
+		account, _ := types.AccountFromSeed(derivedKey.PrivateKey)
+
1
2
3
4
5

Full Code

package main
+
+import (
+	"fmt"
+
+	"github.com/blocto/solana-go-sdk/pkg/hdwallet"
+	"github.com/blocto/solana-go-sdk/types"
+	"github.com/mr-tron/base58"
+	"github.com/tyler-smith/go-bip39"
+)
+
+func main() {
+	// create a new account
+	{
+		account := types.NewAccount()
+		fmt.Println(account.PublicKey.ToBase58())
+		fmt.Println(base58.Encode(account.PrivateKey))
+	}
+
+	// from a base58 pirvate key
+	{
+		account, _ := types.AccountFromBase58("28WJTTqMuurAfz6yqeTrFMXeFd91uzi9i1AW6F5KyHQDS9siXb8TquAuatvLuCEYdggyeiNKLAUr3w7Czmmf2Rav")
+		fmt.Println(account.PublicKey.ToBase58())
+	}
+
+	// from a private key bytes
+	{
+		account, _ := types.AccountFromBytes([]byte{
+			56, 125, 59, 118, 230, 173, 152, 169, 197, 34,
+			168, 187, 217, 160, 119, 204, 124, 69, 52, 136,
+			214, 49, 207, 234, 79, 70, 83, 224, 1, 224, 36,
+			247, 131, 83, 164, 85, 139, 215, 183, 148, 79,
+			198, 74, 93, 156, 157, 208, 99, 221, 127, 51,
+			156, 43, 196, 101, 144, 104, 252, 221, 108,
+			245, 104, 13, 151,
+		})
+		fmt.Println(account.PublicKey.ToBase58())
+	}
+
+	// from bip 39 (solana cli tool)
+	{
+		mnemonic := "pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		account, _ := types.AccountFromSeed(seed[:32])
+		fmt.Println(account.PublicKey.ToBase58())
+	}
+
+	// from bip 44 (phantom)
+	{
+		mnemonic := "neither lonely flavor argue grass remind eye tag avocado spot unusual intact"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		path := \`m/44'/501'/0'/0'\`
+		derivedKey, _ := hdwallet.Derived(path, seed)
+		account, _ := types.AccountFromSeed(derivedKey.PrivateKey)
+		fmt.Printf("%v => %v\\n", path, account.PublicKey.ToBase58())
+
+		// others
+		for i := 1; i < 10; i++ {
+			path := fmt.Sprintf(\`m/44'/501'/%d'/0'\`, i)
+			derivedKey, _ := hdwallet.Derived(path, seed)
+			account, _ := types.AccountFromSeed(derivedKey.PrivateKey)
+			fmt.Printf("%v => %v\\n", path, account.PublicKey.ToBase58())
+		}
+		/*
+			m/44'/501'/0'/0' => 5vftMkHL72JaJG6ExQfGAsT2uGVHpRR7oTNUPMs68Y2N
+			m/44'/501'/1'/0' => GcXbfQ5yY3uxCyBNDPBbR5FjumHf89E7YHXuULfGDBBv
+			m/44'/501'/2'/0' => 7QPgyQwNLqnoSwHEuK8wKy2Y3Ani6EHoZRihTuWkwxbc
+			m/44'/501'/3'/0' => 5aE8UprEEWtpVskhxo3f8ETco2kVKiZT9SS3D5Lcg8s2
+			m/44'/501'/4'/0' => 5n6afo6LZmzH1J4R38ZCaNSwaztLjd48nWwToLQkCHxp
+			m/44'/501'/5'/0' => 2Gr1hWnbaqGXMghicSTHncqV7GVLLddNFJDC7YJoso8M
+			m/44'/501'/6'/0' => BNMDY3tCyYbayMzBjZm8RW59unpDWcQRfVmWXCJhLb7D
+			m/44'/501'/7'/0' => 9CySTpi4iC85gMW6G4BMoYbNBsdyJrfseHoGmViLha63
+			m/44'/501'/8'/0' => ApteF7PmUWS8Lzm6tJPkWgrxSFW5LwYGWCUJ2ByAec91
+			m/44'/501'/9'/0' => 6frdqXQAgJMyKwmZxkLYbdGjnYTvUceh6LNhkQt2siQp
+		*/
+	}
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
`,15);function t(e,o){return p}var u=n(a,[["render",t]]);export{u as default}; diff --git a/assets/create-mint.html.4d530f84.js b/assets/create-mint.html.4d530f84.js new file mode 100644 index 00000000..7514bece --- /dev/null +++ b/assets/create-mint.html.4d530f84.js @@ -0,0 +1,76 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Create Mint

create a new token

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// create an mint account
+	mint := types.NewAccount()
+	fmt.Println("mint:", mint.PublicKey.ToBase58())
+
+	// get rent
+	rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(
+		context.Background(),
+		token.MintAccountSize,
+	)
+	if err != nil {
+		log.Fatalf("get min balacne for rent exemption, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      mint.PublicKey,
+					Owner:    common.TokenProgramID,
+					Lamports: rentExemptionBalance,
+					Space:    token.MintAccountSize,
+				}),
+				token.InitializeMint(token.InitializeMintParam{
+					Decimals:   8,
+					Mint:       mint.PublicKey,
+					MintAuth:   alice.PublicKey,
+					FreezeAuth: nil,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, mint},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
`,3);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/create-mint.html.8c737506.js b/assets/create-mint.html.8c737506.js new file mode 100644 index 00000000..b1094c94 --- /dev/null +++ b/assets/create-mint.html.8c737506.js @@ -0,0 +1 @@ +const t={key:"v-6a1127a4",path:"/tour/create-mint.html",title:"Create Mint",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/create-mint.md"};export{t as data}; diff --git a/assets/create-nonce-account.html.09101beb.js b/assets/create-nonce-account.html.09101beb.js new file mode 100644 index 00000000..eb793be5 --- /dev/null +++ b/assets/create-nonce-account.html.09101beb.js @@ -0,0 +1 @@ +const e={key:"v-c5aa4956",path:"/advanced/durable-nonce/create-nonce-account.html",title:"Create Nonce Account",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646930333e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/durable-nonce/create-nonce-account.md"};export{e as data}; diff --git a/assets/create-nonce-account.html.d221497b.js b/assets/create-nonce-account.html.d221497b.js new file mode 100644 index 00000000..246b013b --- /dev/null +++ b/assets/create-nonce-account.html.d221497b.js @@ -0,0 +1,72 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Create Nonce Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// create a new account
+	nonceAccount := types.NewAccount()
+	fmt.Println("nonce account:", nonceAccount.PublicKey)
+
+	// get minimum balance
+	nonceAccountMinimumBalance, err := c.GetMinimumBalanceForRentExemption(context.Background(), system.NonceAccountSize)
+	if err != nil {
+		log.Fatalf("failed to get minimum balance for nonce account, err: %v", err)
+	}
+
+	// recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, nonceAccount},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      nonceAccount.PublicKey,
+					Owner:    common.SystemProgramID,
+					Lamports: nonceAccountMinimumBalance,
+					Space:    system.NonceAccountSize,
+				}),
+				system.InitializeNonceAccount(system.InitializeNonceAccountParam{
+					Nonce: nonceAccount.PublicKey,
+					Auth:  alice.PublicKey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
`,2);function p(c,o){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/create-token-account.html.22925637.js b/assets/create-token-account.html.22925637.js new file mode 100644 index 00000000..ceeb49f7 --- /dev/null +++ b/assets/create-token-account.html.22925637.js @@ -0,0 +1,134 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Create Token Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/associated_token_account"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	ata, _, err := common.FindAssociatedTokenAddress(alice.PublicKey, mintPubkey)
+	if err != nil {
+		log.Fatalf("find ata error, err: %v", err)
+	}
+	fmt.Println("ata:", ata.ToBase58())
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				associated_token_account.Create(associated_token_account.CreateParam{
+					Funder:                 feePayer.PublicKey,
+					Owner:                  alice.PublicKey,
+					Mint:                   mintPubkey,
+					AssociatedTokenAccount: ata,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send raw tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62

Random

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	aliceRandomTokenAccount := types.NewAccount()
+	fmt.Println("alice token account:", aliceRandomTokenAccount.PublicKey.ToBase58())
+
+	rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(context.Background(), token.TokenAccountSize)
+	if err != nil {
+		log.Fatalf("get min balacne for rent exemption, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      aliceRandomTokenAccount.PublicKey,
+					Owner:    common.TokenProgramID,
+					Lamports: rentExemptionBalance,
+					Space:    token.TokenAccountSize,
+				}),
+				token.InitializeAccount(token.InitializeAccountParam{
+					Account: aliceRandomTokenAccount.PublicKey,
+					Mint:    mintPubkey,
+					Owner:   alice.PublicKey,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, aliceRandomTokenAccount},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
`,5);function p(o,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/create-token-account.html.3be4b61e.js b/assets/create-token-account.html.3be4b61e.js new file mode 100644 index 00000000..d9dc1a51 --- /dev/null +++ b/assets/create-token-account.html.3be4b61e.js @@ -0,0 +1 @@ +const e={key:"v-3079eed3",path:"/tour/create-token-account.html",title:"Create Token Account",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"Associated Token Account (Recommended)",slug:"associated-token-account-recommended",children:[]},{level:2,title:"Random",slug:"random",children:[]}],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/create-token-account.md"};export{e as data}; diff --git a/assets/data.html.22999d61.js b/assets/data.html.22999d61.js new file mode 100644 index 00000000..7d4c5b99 --- /dev/null +++ b/assets/data.html.22999d61.js @@ -0,0 +1 @@ +const e={key:"v-231c922b",path:"/programs/101/data.html",title:"Data",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:3,title:"client",slug:"client",children:[]},{level:3,title:"program",slug:"program",children:[]}],git:{updatedTime:1685469006e3,contributors:[{name:"Yihau Chen",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"programs/101/data.md"};export{e as data}; diff --git a/assets/data.html.7beec709.js b/assets/data.html.7beec709.js new file mode 100644 index 00000000..dd8b6a2d --- /dev/null +++ b/assets/data.html.7beec709.js @@ -0,0 +1,121 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Data

client

// data is the most powerful part in an instruction
+// we can pack everything into data, like number, pubkey ... whatever you want.
+// we need to make them become a u8 array when we try to pack it in to a tx.
+
+package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+var programId = common.PublicKeyFromString("c6vyXkJqgA85rYnLiMqxXd39fusJWbRJkoF3jXTd96H")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get latest blockhash, err: %v\\n", err)
+	}
+
+	// (our example prgoram will parse the first byte as the selector then print remaining data.)
+	{
+		tx, err := types.NewTransaction(types.NewTransactionParam{
+			Signers: []types.Account{feePayer},
+			Message: types.NewMessage(types.NewMessageParam{
+				FeePayer:        feePayer.PublicKey,
+				RecentBlockhash: res.Blockhash,
+				Instructions: []types.Instruction{
+					{
+						ProgramID: programId,
+						Accounts:  []types.AccountMeta{},
+						Data:      []byte{0, 1, 2, 3, 4},
+					},
+				},
+			}),
+		})
+		if err != nil {
+			log.Fatalf("failed to new a tx, err: %v", err)
+		}
+
+		sig, err := c.SendTransaction(context.Background(), tx)
+		if err != nil {
+			log.Fatalf("failed to send the tx, err: %v", err)
+		}
+
+		// 5X3qhwXJcjSZ3KqY8cTs5YbswBTS7yyqnfTn2diGwGERPrMNUjh9efc6Y9ABanfDUzaQN1n6BHHyMRjDJk2tfy1i
+		fmt.Println(sig)
+	}
+
+	{
+		tx, err := types.NewTransaction(types.NewTransactionParam{
+			Signers: []types.Account{feePayer},
+			Message: types.NewMessage(types.NewMessageParam{
+				FeePayer:        feePayer.PublicKey,
+				RecentBlockhash: res.Blockhash,
+				Instructions: []types.Instruction{
+					{
+						ProgramID: programId,
+						Accounts:  []types.AccountMeta{},
+						Data:      []byte{1, 5, 6, 7, 8},
+					},
+				},
+			}),
+		})
+		if err != nil {
+			log.Fatalf("failed to new a tx, err: %v", err)
+		}
+
+		sig, err := c.SendTransaction(context.Background(), tx)
+		if err != nil {
+			log.Fatalf("failed to send the tx, err: %v", err)
+		}
+
+		// 5GETq1uLwMGdmsAH79pPByzGxQxXS1LqZ6Y9T6dBQ5qiMHFo5EgwDAHccFVEcc9hTYyj5zGfLX6j1uSz5NX7HZ8Q
+		fmt.Println(sig)
+	}
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

program

use solana_program::{
+    account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg,
+    program_error::ProgramError, pubkey::Pubkey,
+};
+
+entrypoint!(process_instruction);
+
+fn process_instruction(
+    _program_id: &Pubkey,
+    _accounts: &[AccountInfo],
+    instruction_data: &[u8],
+) -> ProgramResult {
+    let (selector, rest) = instruction_data
+        .split_first()
+        .ok_or(ProgramError::InvalidInstructionData)?;
+
+    match selector {
+        0 => msg!(&format!(
+            "first instruction is called. remaining data: {:?}",
+            rest,
+        )),
+        1 => msg!(&format!(
+            "second instruction is called. remaining data: {:?}",
+            rest,
+        )),
+        _ => {
+            msg!("invalid called");
+            return Err(ProgramError::InvalidInstructionData);
+        }
+    }
+
+    Ok(())
+}
+
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
`,5);function p(o,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/deactivate.html.1552dba3.js b/assets/deactivate.html.1552dba3.js new file mode 100644 index 00000000..5b5e5a80 --- /dev/null +++ b/assets/deactivate.html.1552dba3.js @@ -0,0 +1,53 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Deactivate (unstake)

TIP

Activation requires waiting for 1 epoch. You can use solana-test-validator --slot-per-epoch <SLOT> for test.

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var aliceStakeAccountPubkey = common.PublicKeyFromString("oyRPx4Ejo11J6b4AGaCx9UXUvGzkEmZQoGxKqx4Yp4B")
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				stake.Deactivate(stake.DeactivateParam{
+					Stake: aliceStakeAccountPubkey,
+					Auth:  alice.PublicKey,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
`,3);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/deactivate.html.a290904c.js b/assets/deactivate.html.a290904c.js new file mode 100644 index 00000000..d78069a2 --- /dev/null +++ b/assets/deactivate.html.a290904c.js @@ -0,0 +1 @@ +const e={key:"v-254605e9",path:"/programs/stake/deactivate.html",title:"Deactivate (unstake)",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1707888442e3,contributors:[{name:"yihau",email:"yihau.chen@icloud.com",commits:1}]},filePathRelative:"programs/stake/deactivate.md"};export{e as data}; diff --git a/assets/delegate.html.892b180b.js b/assets/delegate.html.892b180b.js new file mode 100644 index 00000000..68ac6fb0 --- /dev/null +++ b/assets/delegate.html.892b180b.js @@ -0,0 +1,66 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Delegate (stake)

TIP

Activation requires waiting for 1 epoch. You can use solana-test-validator --slot-per-epoch <SLOT> for test.

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var aliceStakeAccountPubkey = common.PublicKeyFromString("oyRPx4Ejo11J6b4AGaCx9UXUvGzkEmZQoGxKqx4Yp4B")
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	// obtain a random voting account here, or you can use your own. please note that a voting account is required here, rather than an identity.
+	voteAccountStatus, err := c.GetVoteAccounts(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get vote account status, err: %v", err)
+	}
+	if len(voteAccountStatus.Current) == 0 {
+		log.Fatalf("there are no decent voting accounts")
+	}
+	delegatedVotePubkey := voteAccountStatus.Current[0].VotePubkey
+	fmt.Println("delegated vote pubkey:", delegatedVotePubkey.String())
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				stake.DelegateStake(stake.DelegateStakeParam{
+					Stake: aliceStakeAccountPubkey,
+					Auth:  alice.PublicKey,
+					Vote:  delegatedVotePubkey,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
`,3);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/delegate.html.bfe61ede.js b/assets/delegate.html.bfe61ede.js new file mode 100644 index 00000000..6cade292 --- /dev/null +++ b/assets/delegate.html.bfe61ede.js @@ -0,0 +1 @@ +const e={key:"v-5f2dec78",path:"/programs/stake/delegate.html",title:"Delegate (stake)",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1707888442e3,contributors:[{name:"yihau",email:"yihau.chen@icloud.com",commits:1}]},filePathRelative:"programs/stake/delegate.md"};export{e as data}; diff --git a/assets/get-metadata.html.2bbab957.js b/assets/get-metadata.html.2bbab957.js new file mode 100644 index 00000000..bcb8afa5 --- /dev/null +++ b/assets/get-metadata.html.2bbab957.js @@ -0,0 +1 @@ +const t={key:"v-280665e7",path:"/nft/get-metadata.html",title:"Get Token Metadata",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646244832e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"nft/get-metadata.md"};export{t as data}; diff --git a/assets/get-metadata.html.ce06a87a.js b/assets/get-metadata.html.ce06a87a.js new file mode 100644 index 00000000..f764633f --- /dev/null +++ b/assets/get-metadata.html.ce06a87a.js @@ -0,0 +1,42 @@ +import{_ as n,e as a}from"./app.aa4fcc9f.js";const s={},t=a(`

Get Token Metadata

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/davecgh/go-spew/spew"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/metaplex/token_metadata"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	// NFT in solana is a normal mint but only mint 1.
+	// If you want to get its metadata, you need to know where it stored.
+	// and you can use \`tokenmeta.GetTokenMetaPubkey\` to get the metadata account key
+	// here I take a random Degenerate Ape Academy as an example
+	mint := common.PublicKeyFromString("GphF2vTuzhwhLWBWWvD8y5QLCPp1aQC5EnzrWsnbiWPx")
+	metadataAccount, err := token_metadata.GetTokenMetaPubkey(mint)
+	if err != nil {
+		log.Fatalf("faield to get metadata account, err: %v", err)
+	}
+
+	// new a client
+	c := client.NewClient(rpc.MainnetRPCEndpoint)
+
+	// get data which stored in metadataAccount
+	accountInfo, err := c.GetAccountInfo(context.Background(), metadataAccount.ToBase58())
+	if err != nil {
+		log.Fatalf("failed to get accountInfo, err: %v", err)
+	}
+
+	// parse it
+	metadata, err := token_metadata.MetadataDeserialize(accountInfo.Data)
+	if err != nil {
+		log.Fatalf("failed to parse metaAccount, err: %v", err)
+	}
+	spew.Dump(metadata)
+}
+
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
`,2);function p(e,o){return t}var l=n(s,[["render",p]]);export{l as default}; diff --git a/assets/get-mint.html.b4cc973b.js b/assets/get-mint.html.b4cc973b.js new file mode 100644 index 00000000..066424eb --- /dev/null +++ b/assets/get-mint.html.b4cc973b.js @@ -0,0 +1 @@ +const t={key:"v-35d7797c",path:"/tour/get-mint.html",title:"Get Mint",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/get-mint.md"};export{t as data}; diff --git a/assets/get-mint.html.f401f049.js b/assets/get-mint.html.f401f049.js new file mode 100644 index 00000000..32e4fd17 --- /dev/null +++ b/assets/get-mint.html.f401f049.js @@ -0,0 +1,32 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Mint

get detail from a exist mint

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	getAccountInfoResponse, err := c.GetAccountInfo(context.TODO(), mintPubkey.ToBase58())
+	if err != nil {
+		log.Fatalf("failed to get account info, err: %v", err)
+	}
+
+	mintAccount, err := token.MintAccountFromData(getAccountInfoResponse.Data)
+	if err != nil {
+		log.Fatalf("failed to parse data to a mint account, err: %v", err)
+	}
+
+	fmt.Printf("%+v\\n", mintAccount)
+	// {MintAuthority:9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde Supply:0 Decimals:8 IsInitialized:true FreezeAuthority:<nil>}
+}
+
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
`,3);function p(o,e){return t}var l=n(a,[["render",p]]);export{l as default}; diff --git a/assets/get-nonce-account-by-owner.html.4c9b1566.js b/assets/get-nonce-account-by-owner.html.4c9b1566.js new file mode 100644 index 00000000..dd8f6392 --- /dev/null +++ b/assets/get-nonce-account-by-owner.html.4c9b1566.js @@ -0,0 +1,53 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Nonce Account By Owner

package main
+
+import (
+	"context"
+	"encoding/base64"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.RpcClient.GetProgramAccountsWithConfig(
+		context.Background(),
+		common.SystemProgramID.ToBase58(),
+		rpc.GetProgramAccountsConfig{
+			Encoding: rpc.AccountEncodingBase64,
+			Filters: []rpc.GetProgramAccountsConfigFilter{
+				{
+					DataSize: system.NonceAccountSize,
+				},
+				{
+					MemCmp: &rpc.GetProgramAccountsConfigFilterMemCmp{
+						Offset: 8,
+						Bytes:  "9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde", // owner address
+					},
+				},
+			},
+		},
+	)
+	if err != nil {
+		log.Fatalf("failed to get program accounts, err: %v", err)
+	}
+
+	for _, a := range res.Result {
+		fmt.Println("pubkey", a.Pubkey)
+		data, err := base64.StdEncoding.DecodeString((a.Account.Data.([]any))[0].(string))
+		if err != nil {
+			log.Fatalf("failed to decode data, err: %v", err)
+		}
+		nonceAccount, err := system.NonceAccountDeserialize(data)
+		if err != nil {
+			log.Fatalf("failed to parse nonce account, err: %v", err)
+		}
+		fmt.Printf("%+v\\n", nonceAccount)
+	}
+}
+
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
51
52
`,2);function p(o,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/get-nonce-account-by-owner.html.e7678f5f.js b/assets/get-nonce-account-by-owner.html.e7678f5f.js new file mode 100644 index 00000000..53531461 --- /dev/null +++ b/assets/get-nonce-account-by-owner.html.e7678f5f.js @@ -0,0 +1 @@ +const e={key:"v-ab1b707e",path:"/advanced/durable-nonce/get-nonce-account-by-owner.html",title:"Get Nonce Account By Owner",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:16553163e5,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/durable-nonce/get-nonce-account-by-owner.md"};export{e as data}; diff --git a/assets/get-nonce-account.html.365f85e2.js b/assets/get-nonce-account.html.365f85e2.js new file mode 100644 index 00000000..6a197aa9 --- /dev/null +++ b/assets/get-nonce-account.html.365f85e2.js @@ -0,0 +1 @@ +const e={key:"v-7b499707",path:"/advanced/durable-nonce/get-nonce-account.html",title:"Get Nonce Account",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"Nonce Account",slug:"nonce-account",children:[]},{level:2,title:"Only Nonce",slug:"only-nonce",children:[]}],git:{updatedTime:1646930333e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/durable-nonce/get-nonce-account.md"};export{e as data}; diff --git a/assets/get-nonce-account.html.ac8bfed0.js b/assets/get-nonce-account.html.ac8bfed0.js new file mode 100644 index 00000000..bb26e004 --- /dev/null +++ b/assets/get-nonce-account.html.ac8bfed0.js @@ -0,0 +1,52 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Nonce Account

Nonce Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
+	nonceAccount, err := c.GetNonceAccount(context.Background(), nonceAccountAddr)
+	if err != nil {
+		log.Fatalf("failed to get nonce account, err: %v", err)
+	}
+	fmt.Printf("%+v\\n", nonceAccount)
+	/*
+		type NonceAccount struct {
+			Version          uint32
+			State            uint32
+			AuthorizedPubkey common.PublicKey
+			Nonce            common.PublicKey
+			FeeCalculator    FeeCalculator
+		}
+	*/
+}
+
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

Only Nonce

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
+	nonce, err := c.GetNonceFromNonceAccount(context.Background(), nonceAccountAddr)
+	if err != nil {
+		log.Fatalf("failed to get nonce account, err: %v", err)
+	}
+
+	fmt.Println("nonce", nonce)
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
`,5);function p(e,c){return t}var l=n(a,[["render",p]]);export{l as default}; diff --git a/assets/get-signatures-for-address.html.637d35dd.js b/assets/get-signatures-for-address.html.637d35dd.js new file mode 100644 index 00000000..db6c711e --- /dev/null +++ b/assets/get-signatures-for-address.html.637d35dd.js @@ -0,0 +1 @@ +const e={key:"v-b8f58dfe",path:"/rpc/get-signatures-for-address.html",title:"Get Signatures For Address",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"All",slug:"all",children:[]},{level:2,title:"Limit",slug:"limit",children:[]},{level:2,title:"Range",slug:"range",children:[{level:3,title:"Before",slug:"before",children:[]},{level:3,title:"Until",slug:"until",children:[]}]},{level:2,title:"Full Code",slug:"full-code",children:[]}],git:{updatedTime:1658684184e3,contributors:[{name:"Yihau Chen",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"rpc/get-signatures-for-address.md"};export{e as data}; diff --git a/assets/get-signatures-for-address.html.fee9b0bb.js b/assets/get-signatures-for-address.html.fee9b0bb.js new file mode 100644 index 00000000..3246489a --- /dev/null +++ b/assets/get-signatures-for-address.html.fee9b0bb.js @@ -0,0 +1,153 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Signatures For Address

Fetch tx histroy.

All

	// get all (limit is between 1 ~ 1,000, default is 1,000)
+	{
+		res, err := c.GetSignaturesForAddress(context.Background(), target)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8

Limit

	// get latest X tx
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Limit: 5,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Range

context:

	/*
+		if a txhash list like:
+
+		(new)
+		3gwJwVorVprqZmm1ULAp9bKQy6sQ7skG11XYdMSQigA936MBANcSBy6NcNJF2yPf9ycgzZ6vFd4pjAY7qSko61Au
+		wTEnw3vpBthzLUD6gv9B3aC4dQNp4hews85ipM3w9MGZAh38HZ2im9LaWY7aRusVN5Wj33mNvqSRDNyC43u6GQs
+		3e6dRv5KnvpU43VjVjbsubvPR1yFK9b922WcTugyTBSdWdToeCK16NccSaxY6XJ5yi51UswP3ZDe3VJBZTVg2MCW
+		2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy
+		2uFaNDgQWZsgZvR6s3WQKwaCxFgS4ML7xrZyAqgmuTSEuGmrWyCcTrjtajr6baYR6FaVLZ4PWgyt55EmTcT8S7Sg
+		4XGVHHpLW99AUFEd6RivasG57vqu4EMMNdcQdmphepmW484dMYtWLkYw4nSNnSpKiDoYDbSu9ksxECNKBk2JEyHQ
+		3kjLJokcYqAhQjERCVutv5gdUuQ1HsxSCcFsJdQbqNkqd5ML8WRaZJguZgpWH8isCfyEN8YktxxPPNJURhAtvUKE
+		(old)
+	*/
+
1
2
3
4
5
6
7
8
9
10
11
12
13

Before

	// you can fetch the last 3 tx by
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Before: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit:  3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Until

	// you can fetch the latest 3 tx by \`until\`
+	// * the result will be different if there are some newer txs added.
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Until: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit: 3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Full Code

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/davecgh/go-spew/spew"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	target := "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo"
+
+	// get all (limit is between 1 ~ 1,000, default is 1,000)
+	{
+		res, err := c.GetSignaturesForAddress(context.Background(), target)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
+	// get latest X tx
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Limit: 5,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
+	/*
+		if a txhash list like:
+
+		(new)
+		3gwJwVorVprqZmm1ULAp9bKQy6sQ7skG11XYdMSQigA936MBANcSBy6NcNJF2yPf9ycgzZ6vFd4pjAY7qSko61Au
+		wTEnw3vpBthzLUD6gv9B3aC4dQNp4hews85ipM3w9MGZAh38HZ2im9LaWY7aRusVN5Wj33mNvqSRDNyC43u6GQs
+		3e6dRv5KnvpU43VjVjbsubvPR1yFK9b922WcTugyTBSdWdToeCK16NccSaxY6XJ5yi51UswP3ZDe3VJBZTVg2MCW
+		2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy
+		2uFaNDgQWZsgZvR6s3WQKwaCxFgS4ML7xrZyAqgmuTSEuGmrWyCcTrjtajr6baYR6FaVLZ4PWgyt55EmTcT8S7Sg
+		4XGVHHpLW99AUFEd6RivasG57vqu4EMMNdcQdmphepmW484dMYtWLkYw4nSNnSpKiDoYDbSu9ksxECNKBk2JEyHQ
+		3kjLJokcYqAhQjERCVutv5gdUuQ1HsxSCcFsJdQbqNkqd5ML8WRaZJguZgpWH8isCfyEN8YktxxPPNJURhAtvUKE
+		(old)
+	*/
+
+	// you can fetch the last 3 tx by
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Before: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit:  3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
+	// you can fetch the latest 3 tx by \`until\`
+	// * the result will be different if there are some newer txs added.
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Until: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit: 3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
`,15);function p(e,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/get-sol-balance.html.578f37d1.js b/assets/get-sol-balance.html.578f37d1.js new file mode 100644 index 00000000..de9587be --- /dev/null +++ b/assets/get-sol-balance.html.578f37d1.js @@ -0,0 +1,23 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Balance

get sol balance

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	balance, err := c.GetBalance(
+		context.TODO(),
+		"9qeP9DmjXAmKQc4wy133XZrQ3Fo4ejsYteA7X4YFJ3an",
+	)
+	if err != nil {
+		log.Fatalf("failed to request airdrop, err: %v", err)
+	}
+	fmt.Println(balance)
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

TIP

1 SOL = 10^9 lamports

`,4);function p(e,c){return t}var l=n(a,[["render",p]]);export{l as default}; diff --git a/assets/get-sol-balance.html.6f961e64.js b/assets/get-sol-balance.html.6f961e64.js new file mode 100644 index 00000000..b7a23398 --- /dev/null +++ b/assets/get-sol-balance.html.6f961e64.js @@ -0,0 +1 @@ +const e={key:"v-09e730af",path:"/tour/get-sol-balance.html",title:"Get Balance",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/get-sol-balance.md"};export{e as data}; diff --git a/assets/get-token-account.html.ab23e19a.js b/assets/get-token-account.html.ab23e19a.js new file mode 100644 index 00000000..677560be --- /dev/null +++ b/assets/get-token-account.html.ab23e19a.js @@ -0,0 +1,30 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Token Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// token account address
+	getAccountInfoResponse, err := c.GetAccountInfo(context.TODO(), "HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL")
+	if err != nil {
+		log.Fatalf("failed to get account info, err: %v", err)
+	}
+
+	tokenAccount, err := token.TokenAccountFromData(getAccountInfoResponse.Data)
+	if err != nil {
+		log.Fatalf("failed to parse data to a token account, err: %v", err)
+	}
+
+	fmt.Printf("%+v\\n", tokenAccount)
+	// {Mint:F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo Owner:9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde Amount:100000000 Delegate:<nil> State:1 IsNative:<nil> DelegatedAmount:0 CloseAuthority:<nil>}
+}
+
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
`,2);function p(o,e){return t}var l=n(a,[["render",p]]);export{l as default}; diff --git a/assets/get-token-account.html.e4cf79d9.js b/assets/get-token-account.html.e4cf79d9.js new file mode 100644 index 00000000..7f9446ab --- /dev/null +++ b/assets/get-token-account.html.e4cf79d9.js @@ -0,0 +1 @@ +const t={key:"v-25cdf616",path:"/tour/get-token-account.html",title:"Get Token Account",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/get-token-account.md"};export{t as data}; diff --git a/assets/get-token-balance.html.37d5d04e.js b/assets/get-token-balance.html.37d5d04e.js new file mode 100644 index 00000000..09bfa2aa --- /dev/null +++ b/assets/get-token-balance.html.37d5d04e.js @@ -0,0 +1,31 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Get Token Balance

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// should pass a token account address
+	balance, decimals, err := c.GetTokenAccountBalance(
+		context.Background(),
+		"HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL",
+	)
+	if err != nil {
+		log.Fatalln("get balance error", err)
+	}
+	// the smallest unit like lamports
+	fmt.Println("balance", balance)
+	// the decimals of mint which token account holds
+	fmt.Println("decimals", decimals)
+
+	// if you want use a normal unit, you can do
+	// balance / 10^decimals
+}
+
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
`,2);function p(e,c){return t}var l=n(a,[["render",p]]);export{l as default}; diff --git a/assets/get-token-balance.html.48dc74ba.js b/assets/get-token-balance.html.48dc74ba.js new file mode 100644 index 00000000..e7a8ad6e --- /dev/null +++ b/assets/get-token-balance.html.48dc74ba.js @@ -0,0 +1 @@ +const e={key:"v-0f32b5a6",path:"/tour/get-token-balance.html",title:"Get Token Balance",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/get-token-balance.md"};export{e as data}; diff --git a/assets/hello.html.0c4f7db6.js b/assets/hello.html.0c4f7db6.js new file mode 100644 index 00000000..7264d812 --- /dev/null +++ b/assets/hello.html.0c4f7db6.js @@ -0,0 +1,78 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},p=s(`

Hello

client

// an instruction is the smallest unit in a tx.
+// each instruction represent an action with a program.
+// there are three basic fields in an instruction:
+//   - program id
+//     the program which you would like to interact with
+//   - account meta list
+//     accounts which are used in the program
+//   - data
+//     a u8 array.
+
+package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+var programId = common.PublicKeyFromString("EGz5CDh7dG7BwzqL7y5ePpZNvrw7ehr4E4oGRhCCpiEK")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get latest blockhash, err: %v\\n", err)
+	}
+
+	// our first program won't use any accounts and parse any data. we leave them empty atm.
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				{
+					ProgramID: programId,
+					Accounts:  []types.AccountMeta{},
+					Data:      []byte{},
+				},
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send the tx, err: %v", err)
+	}
+
+	// 5eCfcdKGzn8yLGfgX6V1AfjAavTQRGQ936Zyuqejf9W1tTsjABjHTrc66nv5g9qKStmRPr3FeCVznADuCnJ8Zfbq
+	fmt.Println(sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63

program

use solana_program::{
+    account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
+};
+
+entrypoint!(process_instruction);
+
+fn process_instruction(
+    _program_id: &Pubkey,
+    _accounts: &[AccountInfo],
+    _instruction_data: &[u8],
+) -> ProgramResult {
+    msg!("hello");
+    Ok(())
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
`,5);function t(e,o){return p}var u=n(a,[["render",t]]);export{u as default}; diff --git a/assets/hello.html.fc8163f0.js b/assets/hello.html.fc8163f0.js new file mode 100644 index 00000000..672d51ad --- /dev/null +++ b/assets/hello.html.fc8163f0.js @@ -0,0 +1 @@ +const e={key:"v-5586a7ea",path:"/programs/101/hello.html",title:"Hello",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:3,title:"client",slug:"client",children:[]},{level:3,title:"program",slug:"program",children:[]}],git:{updatedTime:1685469006e3,contributors:[{name:"Yihau Chen",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"programs/101/hello.md"};export{e as data}; diff --git a/assets/index.html.04cad356.js b/assets/index.html.04cad356.js new file mode 100644 index 00000000..94691dc9 --- /dev/null +++ b/assets/index.html.04cad356.js @@ -0,0 +1 @@ +import{_ as t,r as a,o as s,c as r,a as e,b as c,F as l,d as o}from"./app.aa4fcc9f.js";const i={},_=e("h1",{id:"solana-development-with-go",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#solana-development-with-go","aria-hidden":"true"},"#"),o(" Solana Development With Go")],-1),d=o("Here is a book to help someone build something on "),h={href:"https://github.com/solana-labs/solana",target:"_blank",rel:"noopener noreferrer"},m=o("Solana"),p=o(" with Go.");function f(u,x){const n=a("ExternalLinkIcon");return s(),r(l,null,[_,e("p",null,[d,e("a",h,[m,c(n)]),p])],64)}var g=t(i,[["render",f]]);export{g as default}; diff --git a/assets/index.html.53b060d9.js b/assets/index.html.53b060d9.js new file mode 100644 index 00000000..853058f9 --- /dev/null +++ b/assets/index.html.53b060d9.js @@ -0,0 +1 @@ +const e={key:"v-6c8477c6",path:"/advanced/durable-nonce/",title:"Durable Nonce",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"Mechanism",slug:"mechanism",children:[]}],git:{updatedTime:1646930333e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/durable-nonce/README.md"};export{e as data}; diff --git a/assets/index.html.aa82496b.js b/assets/index.html.aa82496b.js new file mode 100644 index 00000000..ff5df3ed --- /dev/null +++ b/assets/index.html.aa82496b.js @@ -0,0 +1 @@ +const e={key:"v-8daa1a0e",path:"/",title:"Solana Development With Go",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646244832e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:2}]},filePathRelative:"README.md"};export{e as data}; diff --git a/assets/index.html.ab4ba558.js b/assets/index.html.ab4ba558.js new file mode 100644 index 00000000..93cee123 --- /dev/null +++ b/assets/index.html.ab4ba558.js @@ -0,0 +1 @@ +import{_ as e,e as a}from"./app.aa4fcc9f.js";const n={},c=a('

Durable Nonce

A transaction includes a recent blockhash. The recent blockhash will expire after 150 blocks. (arpox. 2 min) To get rid of it, you can use durable nonce.

Mechanism

We can trigger the mechanism by

  1. use the nonce which stored in a nonce account as a recent blockhash
  2. make nonce advance instruction is the first instruciton
',5);function r(i,o){return c}var h=e(n,[["render",r]]);export{h as default}; diff --git a/assets/initialize-account.html.1bb0c22c.js b/assets/initialize-account.html.1bb0c22c.js new file mode 100644 index 00000000..d7403097 --- /dev/null +++ b/assets/initialize-account.html.1bb0c22c.js @@ -0,0 +1 @@ +const t={key:"v-2c025226",path:"/programs/stake/initialize-account.html",title:"Initialize Account",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1707888442e3,contributors:[{name:"yihau",email:"yihau.chen@icloud.com",commits:1}]},filePathRelative:"programs/stake/initialize-account.md"};export{t as data}; diff --git a/assets/initialize-account.html.5dc86f3c.js b/assets/initialize-account.html.5dc86f3c.js new file mode 100644 index 00000000..56acfded --- /dev/null +++ b/assets/initialize-account.html.5dc86f3c.js @@ -0,0 +1,80 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Initialize Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var stakeAmountInLamports uint64 = 1_000_000_000 // 1 SOL
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	// create an stake account
+	stakeAccount := types.NewAccount()
+	fmt.Println("stake account:", stakeAccount.PublicKey.ToBase58())
+
+	// get rent
+	rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(
+		context.Background(),
+		stake.AccountSize,
+	)
+	if err != nil {
+		log.Fatalf("get min balacne for rent exemption, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      stakeAccount.PublicKey,
+					Owner:    common.StakeProgramID,
+					Lamports: rentExemptionBalance + stakeAmountInLamports,
+					Space:    stake.AccountSize,
+				}),
+				stake.Initialize(stake.InitializeParam{
+					Stake: stakeAccount.PublicKey,
+					Auth: stake.Authorized{
+						Staker:     alice.PublicKey,
+						Withdrawer: alice.PublicKey,
+					},
+					Lockup: stake.Lockup{},
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, stakeAccount},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
`,2);function p(o,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/memo.html.0c84df14.js b/assets/memo.html.0c84df14.js new file mode 100644 index 00000000..b2290537 --- /dev/null +++ b/assets/memo.html.0c84df14.js @@ -0,0 +1,56 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Add Memo

You can add a memo to your transaction by memo instruction

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/memo"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// to fetch recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				// memo instruction
+				memo.BuildMemo(memo.BuildMemoParam{
+					SignerPubkeys: []common.PublicKey{alice.PublicKey},
+					Memo:          []byte("\u{1F433}"),
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	// send tx
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
`,3);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/memo.html.7283ccff.js b/assets/memo.html.7283ccff.js new file mode 100644 index 00000000..dfbcc778 --- /dev/null +++ b/assets/memo.html.7283ccff.js @@ -0,0 +1 @@ +const e={key:"v-59d0d0eb",path:"/advanced/memo.html",title:"Add Memo",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646930333e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/memo.md"};export{e as data}; diff --git a/assets/mint-a-nft.html.1e06d8d8.js b/assets/mint-a-nft.html.1e06d8d8.js new file mode 100644 index 00000000..c3250e64 --- /dev/null +++ b/assets/mint-a-nft.html.1e06d8d8.js @@ -0,0 +1,138 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Mint A NFT

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/pkg/pointer"
+	"github.com/blocto/solana-go-sdk/program/associated_token_account"
+	"github.com/blocto/solana-go-sdk/program/metaplex/token_metadata"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	mint := types.NewAccount()
+	fmt.Printf("NFT: %v\\n", mint.PublicKey.ToBase58())
+
+	collection := types.NewAccount()
+	fmt.Printf("collection: %v\\n", collection.PublicKey.ToBase58())
+
+	ata, _, err := common.FindAssociatedTokenAddress(feePayer.PublicKey, mint.PublicKey)
+	if err != nil {
+		log.Fatalf("failed to find a valid ata, err: %v", err)
+	}
+
+	tokenMetadataPubkey, err := token_metadata.GetTokenMetaPubkey(mint.PublicKey)
+	if err != nil {
+		log.Fatalf("failed to find a valid token metadata, err: %v", err)
+
+	}
+	tokenMasterEditionPubkey, err := token_metadata.GetMasterEdition(mint.PublicKey)
+	if err != nil {
+		log.Fatalf("failed to find a valid master edition, err: %v", err)
+	}
+
+	mintAccountRent, err := c.GetMinimumBalanceForRentExemption(context.Background(), token.MintAccountSize)
+	if err != nil {
+		log.Fatalf("failed to get mint account rent, err: %v", err)
+	}
+
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{mint, feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      mint.PublicKey,
+					Owner:    common.TokenProgramID,
+					Lamports: mintAccountRent,
+					Space:    token.MintAccountSize,
+				}),
+				token.InitializeMint(token.InitializeMintParam{
+					Decimals:   0,
+					Mint:       mint.PublicKey,
+					MintAuth:   feePayer.PublicKey,
+					FreezeAuth: &feePayer.PublicKey,
+				}),
+				token_metadata.CreateMetadataAccountV3(token_metadata.CreateMetadataAccountV3Param{
+					Metadata:                tokenMetadataPubkey,
+					Mint:                    mint.PublicKey,
+					MintAuthority:           feePayer.PublicKey,
+					Payer:                   feePayer.PublicKey,
+					UpdateAuthority:         feePayer.PublicKey,
+					UpdateAuthorityIsSigner: true,
+					IsMutable:               true,
+					Data: token_metadata.DataV2{
+						Name:                 "Fake SMS #1355",
+						Symbol:               "FSMB",
+						Uri:                  "https://34c7ef24f4v2aejh75xhxy5z6ars4xv47gpsdrei6fiowptk2nqq.arweave.net/3wXyF1wvK6ARJ_9ue-O58CMuXrz5nyHEiPFQ6z5q02E",
+						SellerFeeBasisPoints: 100,
+						Creators: &[]token_metadata.Creator{
+							{
+								Address:  feePayer.PublicKey,
+								Verified: true,
+								Share:    100,
+							},
+						},
+						Collection: &token_metadata.Collection{
+							Verified: false,
+							Key:      collection.PublicKey,
+						},
+						Uses: nil,
+					},
+					CollectionDetails: nil,
+				}),
+				associated_token_account.CreateAssociatedTokenAccount(associated_token_account.CreateAssociatedTokenAccountParam{
+					Funder:                 feePayer.PublicKey,
+					Owner:                  feePayer.PublicKey,
+					Mint:                   mint.PublicKey,
+					AssociatedTokenAccount: ata,
+				}),
+				token.MintTo(token.MintToParam{
+					Mint:   mint.PublicKey,
+					To:     ata,
+					Auth:   feePayer.PublicKey,
+					Amount: 1,
+				}),
+				token_metadata.CreateMasterEditionV3(token_metadata.CreateMasterEditionParam{
+					Edition:         tokenMasterEditionPubkey,
+					Mint:            mint.PublicKey,
+					UpdateAuthority: feePayer.PublicKey,
+					MintAuthority:   feePayer.PublicKey,
+					Metadata:        tokenMetadataPubkey,
+					Payer:           feePayer.PublicKey,
+					MaxSupply:       pointer.Get[uint64](0),
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txid:", sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
`,2);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/mint-a-nft.html.3f3b89f5.js b/assets/mint-a-nft.html.3f3b89f5.js new file mode 100644 index 00000000..31e50638 --- /dev/null +++ b/assets/mint-a-nft.html.3f3b89f5.js @@ -0,0 +1 @@ +const t={key:"v-23bafe30",path:"/nft/mint-a-nft.html",title:"Mint A NFT",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646244832e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"nft/mint-a-nft.md"};export{t as data}; diff --git a/assets/mint-to.html.c01cbfdc.js b/assets/mint-to.html.c01cbfdc.js new file mode 100644 index 00000000..5ee99981 --- /dev/null +++ b/assets/mint-to.html.c01cbfdc.js @@ -0,0 +1,62 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Mint To

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+var aliceTokenRandomTokenPubkey = common.PublicKeyFromString("HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL")
+
+var aliceTokenATAPubkey = common.PublicKeyFromString("J1T6kAPowNFcxFh4pmwSqxQM9AitN7HwLyvxV2ZGfLf2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				token.MintToChecked(token.MintToCheckedParam{
+					Mint:     mintPubkey,
+					Auth:     alice.PublicKey,
+					Signers:  []common.PublicKey{},
+					To:       aliceTokenRandomTokenPubkey,
+					Amount:   1e8,
+					Decimals: 8,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send raw tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
`,2);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/mint-to.html.fe63e0ea.js b/assets/mint-to.html.fe63e0ea.js new file mode 100644 index 00000000..39cc7104 --- /dev/null +++ b/assets/mint-to.html.fe63e0ea.js @@ -0,0 +1 @@ +const t={key:"v-41cbbd5e",path:"/tour/mint-to.html",title:"Mint To",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/mint-to.md"};export{t as data}; diff --git a/assets/request-airdrop.html.3d12a5cb.js b/assets/request-airdrop.html.3d12a5cb.js new file mode 100644 index 00000000..7a5a175f --- /dev/null +++ b/assets/request-airdrop.html.3d12a5cb.js @@ -0,0 +1,24 @@ +import{_ as t,r as e,o as p,c as o,a as n,b as c,F as l,e as r,d as s}from"./app.aa4fcc9f.js";const u={},i=r(`

Request Airdrop

Request some airdrop for testing.

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	sig, err := c.RequestAirdrop(
+		context.TODO(),
+		"9qeP9DmjXAmKQc4wy133XZrQ3Fo4ejsYteA7X4YFJ3an", // address
+		1e9, // lamports (1 SOL = 10^9 lamports)
+	)
+	if err != nil {
+		log.Fatalf("failed to request airdrop, err: %v", err)
+	}
+	fmt.Println(sig)
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
`,3),k={class:"custom-container tip"},b=n("p",{class:"custom-container-title"},"TIP",-1),m=s("you can look up this tx on "),d={href:"https://explorer.solana.com/?cluster=devnet",target:"_blank",rel:"noopener noreferrer"},g=s("https://explorer.solana.com/?cluster=devnet");function _(f,q){const a=e("ExternalLinkIcon");return p(),o(l,null,[i,n("div",k,[b,n("p",null,[m,n("a",d,[g,c(a)])])])],64)}var x=t(u,[["render",_]]);export{x as default}; diff --git a/assets/request-airdrop.html.fa688e36.js b/assets/request-airdrop.html.fa688e36.js new file mode 100644 index 00000000..817166bc --- /dev/null +++ b/assets/request-airdrop.html.fa688e36.js @@ -0,0 +1 @@ +const t={key:"v-79469b88",path:"/tour/request-airdrop.html",title:"Request Airdrop",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/request-airdrop.md"};export{t as data}; diff --git a/assets/sign-metadata.html.0570f274.js b/assets/sign-metadata.html.0570f274.js new file mode 100644 index 00000000..04b82780 --- /dev/null +++ b/assets/sign-metadata.html.0570f274.js @@ -0,0 +1 @@ +const t={key:"v-a02bf734",path:"/nft/sign-metadata.html",title:"Sign Metadata",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646244832e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"nft/sign-metadata.md"};export{t as data}; diff --git a/assets/sign-metadata.html.ad27d8d4.js b/assets/sign-metadata.html.ad27d8d4.js new file mode 100644 index 00000000..51a7a2d9 --- /dev/null +++ b/assets/sign-metadata.html.ad27d8d4.js @@ -0,0 +1,58 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Sign Metadata

to convert a unverified creator to a verifeid creator.

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/metaplex/token_metadata"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// mint address
+	nft := common.PublicKeyFromString("FK8eFRgmqewUzr7R6pYUxSPnSNusYmkhAV4e3pUJYdCd")
+
+	tokenMetadataPubkey, err := token_metadata.GetTokenMetaPubkey(nft)
+	if err != nil {
+		log.Fatalf("failed to find a valid token metadata, err: %v", err)
+	}
+
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				token_metadata.SignMetadata(token_metadata.SignMetadataParam{
+					Metadata: tokenMetadataPubkey,
+					Creator:  feePayer.PublicKey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println(sig)
+}
+
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
51
52
53
54
55
56
57
`,3);function p(e,o){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/style.8cbb8e11.css b/assets/style.8cbb8e11.css new file mode 100644 index 00000000..293b8618 --- /dev/null +++ b/assets/style.8cbb8e11.css @@ -0,0 +1 @@ +:root{--external-link-icon-color:#aaa}.external-link-icon{position:relative;display:inline-block;color:var(--external-link-icon-color);vertical-align:middle;top:-1px}.external-link-icon-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}:root{--medium-zoom-z-index:100;--medium-zoom-bg-color:#ffffff;--medium-zoom-opacity:1}.medium-zoom-overlay{background-color:var(--medium-zoom-bg-color)!important;z-index:var(--medium-zoom-z-index)}.medium-zoom-overlay~img{z-index:calc(var(--medium-zoom-z-index) + 1)}.medium-zoom--opened .medium-zoom-overlay{opacity:var(--medium-zoom-opacity)}:root{--c-brand:#3eaf7c;--c-brand-light:#4abf8a;--c-bg:#ffffff;--c-bg-light:#f3f4f5;--c-bg-lighter:#eeeeee;--c-bg-navbar:var(--c-bg);--c-bg-sidebar:var(--c-bg);--c-bg-arrow:#cccccc;--c-text:#2c3e50;--c-text-accent:var(--c-brand);--c-text-light:#3a5169;--c-text-lighter:#4e6e8e;--c-text-lightest:#6a8bad;--c-text-quote:#999999;--c-border:#eaecef;--c-border-dark:#dfe2e5;--c-tip:#42b983;--c-tip-bg:var(--c-bg-light);--c-tip-title:var(--c-text);--c-tip-text:var(--c-text);--c-tip-text-accent:var(--c-text-accent);--c-warning:#e7c000;--c-warning-bg:#fffae3;--c-warning-title:#ad9000;--c-warning-text:#746000;--c-warning-text-accent:var(--c-text);--c-danger:#cc0000;--c-danger-bg:#ffe0e0;--c-danger-title:#990000;--c-danger-text:#660000;--c-danger-text-accent:var(--c-text);--c-details-bg:#eeeeee;--c-badge-tip:var(--c-tip);--c-badge-warning:var(--c-warning);--c-badge-danger:var(--c-danger);--t-color:.3s ease;--t-transform:.3s ease;--code-bg-color:#282c34;--code-hl-bg-color:rgba(0, 0, 0, .66);--code-ln-color:#9e9e9e;--code-ln-wrapper-width:3.5rem;--font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;--font-family-code:Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;--navbar-height:3.6rem;--navbar-padding-v:.7rem;--navbar-padding-h:1.5rem;--sidebar-width:20rem;--sidebar-width-mobile:calc(var(--sidebar-width) * .82);--content-width:740px;--homepage-width:960px}.back-to-top{--back-to-top-color:var(--c-brand);--back-to-top-color-hover:var(--c-brand-light)}.DocSearch{--docsearch-primary-color:var(--c-brand);--docsearch-text-color:var(--c-text);--docsearch-highlight-color:var(--c-brand);--docsearch-muted-color:var(--c-text-quote);--docsearch-container-background:rgba(9, 10, 17, .8);--docsearch-modal-background:var(--c-bg-light);--docsearch-searchbox-background:var(--c-bg-lighter);--docsearch-searchbox-focus-background:var(--c-bg);--docsearch-searchbox-shadow:inset 0 0 0 2px var(--c-brand);--docsearch-hit-color:var(--c-text-light);--docsearch-hit-active-color:var(--c-bg);--docsearch-hit-background:var(--c-bg);--docsearch-hit-shadow:0 1px 3px 0 var(--c-border-dark);--docsearch-footer-background:var(--c-bg)}.external-link-icon{--external-link-icon-color:var(--c-text-quote)}.medium-zoom-overlay{--medium-zoom-bg-color:var(--c-bg)}#nprogress{--nprogress-color:var(--c-brand)}.pwa-popup{--pwa-popup-text-color:var(--c-text);--pwa-popup-bg-color:var(--c-bg);--pwa-popup-border-color:var(--c-brand);--pwa-popup-shadow:0 4px 16px var(--c-brand);--pwa-popup-btn-text-color:var(--c-bg);--pwa-popup-btn-bg-color:var(--c-brand);--pwa-popup-btn-hover-bg-color:var(--c-brand-light)}.search-box{--search-bg-color:var(--c-bg);--search-accent-color:var(--c-brand);--search-text-color:var(--c-text);--search-border-color:var(--c-border);--search-item-text-color:var(--c-text-lighter);--search-item-focus-bg-color:var(--c-bg-light)}html.dark{--c-brand:#3aa675;--c-brand-light:#349469;--c-bg:#22272e;--c-bg-light:#2b313a;--c-bg-lighter:#262c34;--c-text:#adbac7;--c-text-light:#96a7b7;--c-text-lighter:#8b9eb0;--c-text-lightest:#8094a8;--c-border:#3e4c5a;--c-border-dark:#34404c;--c-tip:#318a62;--c-warning:#ceab00;--c-warning-bg:#7e755b;--c-warning-title:#ceac03;--c-warning-text:#362e00;--c-danger:#940000;--c-danger-bg:#806161;--c-danger-title:#610000;--c-danger-text:#3a0000;--c-details-bg:#323843;--code-hl-bg-color:#363b46;color-scheme:dark}html.dark .DocSearch{--docsearch-logo-color:var(--c-text);--docsearch-modal-shadow:inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;--docsearch-key-shadow:inset 0 -2px 0 0 #282d55, inset 0 0 1px 1px #51577d, 0 2px 2px 0 rgba(3, 4, 9, .3);--docsearch-key-gradient:linear-gradient(-225deg, #444950, #1c1e21);--docsearch-footer-shadow:inset 0 1px 0 0 rgba(73, 76, 106, .5), 0 -4px 8px 0 rgba(0, 0, 0, .2)}body,html{padding:0;margin:0;background-color:var(--c-bg);transition:background-color var(--t-color)}body{font-family:var(--font-family);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:16px}a,p a code{color:var(--c-text-accent)}a{font-weight:500;text-decoration:none;overflow-wrap:break-word}p a code{font-weight:400}code,kbd{font-family:var(--font-family-code)}body,kbd{color:var(--c-text)}kbd{background:var(--c-bg-lighter);border:solid .15rem var(--c-border-dark);border-bottom:solid .25rem var(--c-border-dark);border-radius:.15rem;padding:0 .15em}code{color:var(--c-text-lighter);padding:.25rem .5rem;font-size:.85em;background-color:var(--c-bg-light);border-radius:3px;overflow-wrap:break-word;transition:background-color var(--t-color)}blockquote{font-size:1rem;color:var(--c-text-quote);border-left:.2rem solid var(--c-border-dark);margin:1rem 0;padding:.25rem 0 .25rem 1rem}blockquote>p,code{margin:0}ol,ul{padding-left:1.2em}strong{font-weight:600}h1,h2,h3,h4,h5,h6{font-weight:600;line-height:1.25}h1:focus-visible,h2:focus-visible,h3:focus-visible,h4:focus-visible,h5:focus-visible,h6:focus-visible{outline:0}h1:hover .header-anchor,h2:hover .header-anchor,h3:hover .header-anchor,h4:hover .header-anchor,h5:hover .header-anchor,h6:hover .header-anchor{opacity:1}h1{font-size:2.2rem}h2{font-size:1.65rem;padding-bottom:.3rem;border-bottom:1px solid var(--c-border);transition:border-color var(--t-color)}h3{font-size:1.35rem}h4{font-size:1.15rem}h5{font-size:1.05rem}h6{font-size:1rem}a.header-anchor{font-size:.85em;float:left;margin-left:-.87em;padding-right:.23em;margin-top:.125em;opacity:0}a.header-anchor:hover{text-decoration:none}a.header-anchor:focus-visible{opacity:1}ol,p,ul{line-height:1.7}hr{border:0;border-top:1px solid var(--c-border)}table,tr{transition:border-color var(--t-color)}table{border-collapse:collapse;margin:1rem 0;display:block;overflow-x:auto}tr{border-top:1px solid var(--c-border-dark)}tr:nth-child(2n){background-color:var(--c-bg-light);transition:background-color var(--t-color)}td,th{padding:.6em 1em;border:1px solid var(--c-border-dark);transition:border-color var(--t-color)}.arrow,.badge{display:inline-block}.arrow{width:0;height:0}.arrow.down,.arrow.up{border-left:4px solid transparent;border-right:4px solid transparent}.arrow.up{border-bottom:6px solid var(--c-bg-arrow)}.arrow.down{border-top:6px solid var(--c-bg-arrow)}.arrow.left,.arrow.right{border-top:4px solid transparent;border-bottom:4px solid transparent}.arrow.right{border-left:6px solid var(--c-bg-arrow)}.arrow.left{border-right:6px solid var(--c-bg-arrow)}.badge{font-size:14px;height:18px;line-height:18px;border-radius:3px;padding:0 6px;color:var(--c-bg);vertical-align:top;transition:color var(--t-color),background-color var(--t-color)}.badge.tip{background-color:var(--c-badge-tip)}.badge.warning{background-color:var(--c-badge-warning)}.badge.danger{background-color:var(--c-badge-danger)}.badge+.badge{margin-left:5px}code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:var(--font-family-code);font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#ec5975}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:#3eaf7c}.theme-default-content pre,.theme-default-content pre[class*=language-]{line-height:1.4;padding:1.3rem 1.5rem;margin:.85rem 0;border-radius:6px;overflow:auto}.theme-default-content pre code,.theme-default-content pre[class*=language-] code{color:#fff;padding:0;background-color:transparent;border-radius:0;overflow-wrap:unset;-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.theme-default-content .line-number{font-family:var(--font-family-code)}div[class*=language-]{position:relative;background-color:var(--code-bg-color);border-radius:6px}div[class*=language-]:before{position:absolute;z-index:3;top:.8em;right:1em;font-size:.75rem;color:var(--code-ln-color)}div[class*=language-] pre,div[class*=language-] pre[class*=language-]{background:0 0!important;position:relative;z-index:1}div[class*=language-] .highlight-lines{-webkit-user-select:none;-moz-user-select:none;user-select:none;padding-top:1.3rem;position:absolute;top:0;left:0;width:100%;line-height:1.4}div[class*=language-] .highlight-lines .highlight-line{background-color:var(--code-hl-bg-color)}div[class*=language-]:not(.line-numbers-mode) .line-numbers{display:none}div[class*=language-].line-numbers-mode .highlight-lines .highlight-line{position:relative}div[class*=language-].line-numbers-mode .highlight-lines .highlight-line:before{content:" ";position:absolute;z-index:2;left:0;top:0;display:block;width:var(--code-ln-wrapper-width);height:100%}div[class*=language-].line-numbers-mode pre{margin-left:var(--code-ln-wrapper-width);padding-left:1rem;vertical-align:middle}div[class*=language-].line-numbers-mode .line-numbers{position:absolute;top:0;width:var(--code-ln-wrapper-width);text-align:center;color:var(--code-ln-color);padding-top:1.25rem;line-height:1.4}div[class*=language-].line-numbers-mode .line-numbers br{-webkit-user-select:none;-moz-user-select:none;user-select:none}div[class*=language-].line-numbers-mode .line-numbers .line-number{position:relative;z-index:3;-webkit-user-select:none;-moz-user-select:none;user-select:none;font-size:.85em;line-height:0}div[class*=language-].line-numbers-mode:after{content:"";position:absolute;top:0;left:0;width:var(--code-ln-wrapper-width);height:100%;border-radius:6px 0 0 6px;border-right:1px solid var(--code-hl-bg-color)}div[class*=language-].ext-c:before{content:"c"}div[class*=language-].ext-cpp:before{content:"cpp"}div[class*=language-].ext-cs:before{content:"cs"}div[class*=language-].ext-css:before{content:"css"}div[class*=language-].ext-dart:before{content:"dart"}div[class*=language-].ext-docker:before{content:"docker"}div[class*=language-].ext-fs:before{content:"fs"}div[class*=language-].ext-go:before{content:"go"}div[class*=language-].ext-html:before{content:"html"}div[class*=language-].ext-java:before{content:"java"}div[class*=language-].ext-js:before{content:"js"}div[class*=language-].ext-json:before{content:"json"}div[class*=language-].ext-kt:before{content:"kt"}div[class*=language-].ext-less:before{content:"less"}div[class*=language-].ext-makefile:before{content:"makefile"}div[class*=language-].ext-md:before{content:"md"}div[class*=language-].ext-php:before{content:"php"}div[class*=language-].ext-py:before{content:"py"}div[class*=language-].ext-rb:before{content:"rb"}div[class*=language-].ext-rs:before{content:"rs"}div[class*=language-].ext-sass:before{content:"sass"}div[class*=language-].ext-scss:before{content:"scss"}div[class*=language-].ext-sh:before{content:"sh"}div[class*=language-].ext-styl:before{content:"styl"}div[class*=language-].ext-ts:before{content:"ts"}div[class*=language-].ext-toml:before{content:"toml"}div[class*=language-].ext-vue:before{content:"vue"}div[class*=language-].ext-yml:before{content:"yml"}@media (max-width:419px){.theme-default-content div[class*=language-]{margin:.85rem -1.5rem;border-radius:0}}.code-group__nav{margin-top:.85rem;margin-bottom:calc(-1.7rem - 6px);padding-bottom:calc(1.7rem - 6px);padding-left:10px;padding-top:10px;border-top-left-radius:6px;border-top-right-radius:6px;background-color:var(--code-bg-color)}.code-group__ul{margin:auto 0;padding-left:0;display:inline-flex;list-style:none}.code-group__nav-tab{border:0;padding:5px;cursor:pointer;background-color:transparent;font-size:.85em;line-height:1.4;color:#ffffffe6;font-weight:600}.code-group__nav-tab:focus{outline:0}.code-group__nav-tab:focus-visible{outline:1px solid rgba(255,255,255,.9)}.code-group__nav-tab-active{border-bottom:var(--c-brand) 1px solid}@media (max-width:419px){.code-group__nav{margin-left:-1.5rem;margin-right:-1.5rem;border-radius:0}}.code-group-item,.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subtitle>a.router-link-active:after{display:none}.code-group-item__active{display:block}.code-group-item>pre{background-color:orange}.custom-container{transition:color var(--t-color),border-color var(--t-color),background-color var(--t-color)}.custom-container .custom-container-title{font-weight:600;margin-bottom:-.4rem}.custom-container.danger,.custom-container.tip,.custom-container.warning{padding:.1rem 1.5rem;border-left-width:.5rem;border-left-style:solid;margin:1rem 0}.custom-container.tip{border-color:var(--c-tip);background-color:var(--c-tip-bg);color:var(--c-tip-text)}.custom-container.tip .custom-container-title{color:var(--c-tip-title)}.custom-container.tip a{color:var(--c-tip-text-accent)}.custom-container.warning{border-color:var(--c-warning);background-color:var(--c-warning-bg);color:var(--c-warning-text)}.custom-container.warning .custom-container-title{color:var(--c-warning-title)}.custom-container.warning a{color:var(--c-warning-text-accent)}.custom-container.danger{border-color:var(--c-danger);background-color:var(--c-danger-bg);color:var(--c-danger-text)}.custom-container.danger .custom-container-title{color:var(--c-danger-title)}.custom-container.danger a{color:var(--c-danger-text-accent)}.custom-container.details{display:block;position:relative;border-radius:2px;margin:1.6em 0;padding:1.6em;background-color:var(--c-details-bg)}.custom-container.details h4{margin-top:0}.custom-container.details figure:last-child,.custom-container.details p:last-child{margin-bottom:0;padding-bottom:0}.custom-container.details summary{outline:0;cursor:pointer}.home{padding:var(--navbar-height) 2rem 0;max-width:var(--homepage-width);margin:0 auto;display:block}.home .hero{text-align:center}.home .hero img{max-width:100%;max-height:280px;display:block;margin:3rem auto 1.5rem}.home .hero h1{font-size:3rem}.home .hero .actions,.home .hero .description,.home .hero h1{margin:1.8rem auto}.home .hero .actions{display:flex;flex-wrap:wrap;gap:1rem;justify-content:center}.home .hero .description{max-width:35rem;font-size:1.6rem;line-height:1.3;color:var(--c-text-lightest)}.home .hero .action-button{display:inline-block;font-size:1.2rem;padding:.8rem 1.6rem;border-width:2px;border-style:solid;border-radius:4px;transition:background-color var(--t-color);box-sizing:border-box}.home .hero .action-button.primary{color:var(--c-bg);background-color:var(--c-brand);border-color:var(--c-brand)}.home .hero .action-button.primary:hover{background-color:var(--c-brand-light)}.home .hero .action-button.secondary{color:var(--c-brand);background-color:var(--c-bg);border-color:var(--c-brand)}.home .hero .action-button.secondary:hover{color:var(--c-bg);background-color:var(--c-brand-light)}.home .features{border-top:1px solid var(--c-border);transition:border-color var(--t-color);padding:1.2rem 0;margin-top:2.5rem;display:flex;flex-wrap:wrap;align-items:flex-start;align-content:stretch;justify-content:space-between}.home .feature{flex-grow:1;flex-basis:30%;max-width:30%}.home .feature h2{font-size:1.4rem;font-weight:500;border-bottom:none;padding-bottom:0;color:var(--c-text-light)}.home .feature p,.home .footer{color:var(--c-text-lighter)}.home .footer{padding:2.5rem;border-top:1px solid var(--c-border);text-align:center;transition:border-color var(--t-color)}@media (max-width:719px){.home .features{flex-direction:column}.home .feature{max-width:100%;padding:0 2.5rem}}@media (max-width:419px){.home{padding-left:1.5rem;padding-right:1.5rem}.home .hero img{max-height:210px;margin:2rem auto 1.2rem}.home .hero h1{font-size:2rem}.home .hero .actions,.home .hero .description,.home .hero h1{margin:1.2rem auto}.home .hero .description{font-size:1.2rem}.home .hero .action-button{font-size:1rem;padding:.6rem 1.2rem}.home .feature h2{font-size:1.25rem}}.page{padding-top:var(--navbar-height);padding-left:var(--sidebar-width)}.navbar,.sidebar{position:fixed;left:0;box-sizing:border-box}.navbar{z-index:20;top:0;right:0;height:var(--navbar-height);border-bottom:1px solid var(--c-border);background-color:var(--c-bg-navbar);transition:background-color var(--t-color),border-color var(--t-color)}.sidebar{font-size:16px;width:var(--sidebar-width);z-index:10;margin:0;top:var(--navbar-height);bottom:0;border-right:1px solid var(--c-border);overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--c-brand) var(--c-border);background-color:var(--c-bg-sidebar);transition:transform var(--t-transform),background-color var(--t-color),border-color var(--t-color)}.sidebar::-webkit-scrollbar{width:7px}.sidebar::-webkit-scrollbar-track{background-color:var(--c-border)}.sidebar::-webkit-scrollbar-thumb{background-color:var(--c-brand)}.sidebar-mask{position:fixed;z-index:9;top:0;left:0;width:100vw;height:100vh;display:none}.theme-container.sidebar-open .sidebar-mask{display:block}.theme-container.sidebar-open .navbar>.toggle-sidebar-button .icon span:nth-child(1){transform:rotate(45deg) translate(5.5px,5.5px)}.theme-container.sidebar-open .navbar>.toggle-sidebar-button .icon span:nth-child(2){transform:scaleX(0)}.theme-container.sidebar-open .navbar>.toggle-sidebar-button .icon span:nth-child(3){transform:rotate(-45deg) translate(6px,-6px)}.theme-container.sidebar-open .navbar>.toggle-sidebar-button .icon span:nth-child(1),.theme-container.sidebar-open .navbar>.toggle-sidebar-button .icon span:nth-child(3){transform-origin:center}.theme-container.no-navbar .theme-default-content:not(.custom)>h1,.theme-container.no-navbar h2,.theme-container.no-navbar h3,.theme-container.no-navbar h4,.theme-container.no-navbar h5,.theme-container.no-navbar h6{margin-top:1.5rem;padding-top:0}.theme-container.no-navbar .page{padding-top:0}.theme-container.no-navbar .sidebar{top:0}@media (min-width:720px){.theme-container.no-sidebar .sidebar{display:none}.theme-container.no-sidebar .page{padding-left:0}}.theme-default-content:not(.custom)>h1,.theme-default-content:not(.custom)>h2,.theme-default-content:not(.custom)>h3,.theme-default-content:not(.custom)>h4,.theme-default-content:not(.custom)>h5,.theme-default-content:not(.custom)>h6{margin-top:calc(.5rem - var(--navbar-height));padding-top:calc(1rem + var(--navbar-height));margin-bottom:0}.theme-default-content:not(.custom)>h1:first-child,.theme-default-content:not(.custom)>h2:first-child,.theme-default-content:not(.custom)>h3:first-child,.theme-default-content:not(.custom)>h4:first-child,.theme-default-content:not(.custom)>h5:first-child,.theme-default-content:not(.custom)>h6:first-child{margin-bottom:1rem}.theme-default-content:not(.custom)>h1:first-child+.custom-container,.theme-default-content:not(.custom)>h1:first-child+p,.theme-default-content:not(.custom)>h1:first-child+pre,.theme-default-content:not(.custom)>h2:first-child+.custom-container,.theme-default-content:not(.custom)>h2:first-child+p,.theme-default-content:not(.custom)>h2:first-child+pre,.theme-default-content:not(.custom)>h3:first-child+.custom-container,.theme-default-content:not(.custom)>h3:first-child+p,.theme-default-content:not(.custom)>h3:first-child+pre,.theme-default-content:not(.custom)>h4:first-child+.custom-container,.theme-default-content:not(.custom)>h4:first-child+p,.theme-default-content:not(.custom)>h4:first-child+pre,.theme-default-content:not(.custom)>h5:first-child+.custom-container,.theme-default-content:not(.custom)>h5:first-child+p,.theme-default-content:not(.custom)>h5:first-child+pre,.theme-default-content:not(.custom)>h6:first-child+.custom-container,.theme-default-content:not(.custom)>h6:first-child+p,.theme-default-content:not(.custom)>h6:first-child+pre{margin-top:2rem}.theme-default-content:not(.custom){max-width:var(--content-width);margin:0 auto;padding:2rem 2.5rem;padding-top:0}@media (max-width:959px){.theme-default-content:not(.custom){padding:2rem}}@media (max-width:419px){.theme-default-content:not(.custom){padding:1.5rem}}.theme-default-content:not(.custom) a:hover{text-decoration:underline}.theme-default-content:not(.custom) img{max-width:100%}.theme-default-content.custom{padding:0;margin:0}.theme-default-content.custom img{max-width:100%}@media (max-width:959px){.sidebar{font-size:15px;width:var(--sidebar-width-mobile)}.page{padding-left:var(--sidebar-width-mobile)}}@media (max-width:719px){.sidebar{top:0;padding-top:var(--navbar-height);transform:translate(-100%)}.page{padding-left:0}.theme-container.sidebar-open .sidebar{transform:translate(0)}.theme-container.no-navbar .sidebar{padding-top:0}}@media (max-width:419px){h1{font-size:1.9rem}}.navbar{--navbar-line-height:calc( var(--navbar-height) - 2 * var(--navbar-padding-v) );padding:var(--navbar-padding-v) var(--navbar-padding-h);line-height:var(--navbar-line-height)}.navbar .logo{height:var(--navbar-line-height);margin-right:var(--navbar-padding-v);vertical-align:top}.navbar .site-name{font-size:1.3rem;font-weight:600;color:var(--c-text);position:relative}.navbar .navbar-items-wrapper{display:flex;position:absolute;box-sizing:border-box;top:var(--navbar-padding-v);right:var(--navbar-padding-h);height:var(--navbar-line-height);padding-left:var(--navbar-padding-h);white-space:nowrap;font-size:.9rem}.navbar .navbar-items-wrapper .search-box{flex:0 0 auto;vertical-align:top}@media (max-width:719px){.navbar{padding-left:4rem}.navbar .can-hide{display:none}.navbar .site-name{width:calc(100vw - 9.4rem);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}}.navbar-items,.navbar-items a{display:inline-block}.navbar-items a{line-height:1.4rem;color:inherit}.navbar-items a.router-link-active,.navbar-items a:hover{color:var(--c-text-accent)}.navbar-items .navbar-item{position:relative;display:inline-block;margin-left:1.5rem;line-height:var(--navbar-line-height)}.navbar-items .navbar-item:first-child{margin-left:0}@media (max-width:719px){.navbar-items .navbar-item{margin-left:0}}@media (min-width:719px){.navbar-items a.router-link-active,.navbar-items a:hover{color:var(--c-text)}.navbar-item>a.router-link-active,.navbar-item>a:hover{margin-bottom:-2px;border-bottom:2px solid var(--c-text-accent)}}.toggle-sidebar-button{position:absolute;top:.6rem;left:1rem;display:none;padding:.6rem;cursor:pointer}.toggle-sidebar-button .icon{display:flex;flex-direction:column;justify-content:center;align-items:center;width:1.25rem;height:1.25rem;cursor:inherit}.toggle-sidebar-button .icon span{display:inline-block;width:100%;height:2px;border-radius:2px;background-color:var(--c-text);transition:transform var(--t-transform)}.toggle-sidebar-button .icon span:nth-child(2){margin:6px 0}@media screen and (max-width:719px){.toggle-sidebar-button{display:block}}.toggle-dark-button{display:flex;margin:auto;margin-left:1rem;border:0;background:0 0;color:var(--c-text);opacity:.8;cursor:pointer}.toggle-dark-button:hover{opacity:1}.toggle-dark-button .icon{width:1.25rem;height:1.25rem}.DocSearch{transition:background-color var(--t-color)}.navbar-dropdown-wrapper{cursor:pointer}.navbar-dropdown-wrapper .navbar-dropdown-title,.navbar-dropdown-wrapper .navbar-dropdown-title-mobile{display:block;font-size:.9rem;font-family:inherit;cursor:inherit;padding:inherit;line-height:1.4rem;background:0 0;border:0;font-weight:500;color:var(--c-text)}.navbar-dropdown-wrapper .navbar-dropdown-title-mobile{display:none;font-weight:600;font-size:inherit}.navbar-dropdown-wrapper .navbar-dropdown-title-mobile:hover,.navbar-dropdown-wrapper .navbar-dropdown-title:hover{border-color:transparent}.navbar-dropdown-wrapper .navbar-dropdown-title .arrow,.navbar-dropdown-wrapper .navbar-dropdown-title-mobile .arrow{vertical-align:middle;margin-top:-1px;margin-left:.4rem}.navbar-dropdown-wrapper .navbar-dropdown-title-mobile:hover{color:var(--c-text-accent)}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item{color:inherit;line-height:1.7rem}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subtitle{margin:.45rem 0 0;border-top:1px solid var(--c-border);padding:1rem 0 .45rem;font-size:.9rem}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subtitle>span{padding:0 1.5rem 0 1.25rem}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subtitle>a{font-weight:inherit}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subitem-wrapper{padding:0;list-style:none}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subitem-wrapper .navbar-dropdown-subitem{font-size:.9em}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item a{display:block;line-height:1.7rem;position:relative;border-bottom:none;font-weight:400;margin-bottom:0;padding:0 1.5rem 0 1.25rem}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item a.router-link-active,.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item a:hover{color:var(--c-text-accent)}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item a.router-link-active:after{content:"";width:0;height:0;border-left:5px solid var(--c-text-accent);border-top:3px solid transparent;border-bottom:3px solid transparent;position:absolute;top:calc(50% - 2px);left:9px}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item:first-child .navbar-dropdown-subtitle{margin-top:0;padding-top:0;border-top:0}@media (max-width:719px){.navbar-dropdown-wrapper.open .navbar-dropdown-title,.navbar-dropdown-wrapper.open .navbar-dropdown-title-mobile{margin-bottom:.5rem}.navbar-dropdown-wrapper .navbar-dropdown-title{display:none}.navbar-dropdown-wrapper .navbar-dropdown-title-mobile{display:block}.navbar-dropdown-wrapper .navbar-dropdown{transition:height .1s ease-out;overflow:hidden}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subtitle{border-top:0;margin-top:0;padding-top:0;padding-bottom:0;font-size:15px;line-height:2rem}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item>a{font-size:15px;line-height:2rem}.navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item .navbar-dropdown-subitem{font-size:14px;padding-left:1rem}}@media (min-width:720px){.navbar-dropdown-wrapper{height:1.8rem}.navbar-dropdown-wrapper.open .navbar-dropdown,.navbar-dropdown-wrapper:hover .navbar-dropdown{display:block!important}.navbar-dropdown-wrapper.open:blur{display:none}.navbar-dropdown-wrapper .navbar-dropdown{display:none;height:auto!important;box-sizing:border-box;max-height:calc(100vh - 2.7rem);overflow-y:auto;position:absolute;top:100%;right:0;background-color:var(--c-bg-navbar);padding:.6rem 0;border:1px solid var(--c-border);border-bottom-color:var(--c-border-dark);text-align:left;border-radius:.25rem;white-space:nowrap;margin:0}}.page{padding-bottom:2rem;display:block}.page-meta{max-width:var(--content-width);margin:0 auto;padding:1rem 2.5rem;overflow:auto}@media (max-width:959px){.page-meta{padding:2rem}}@media (max-width:419px){.page-meta{padding:1.5rem}}.page-meta .meta-item{cursor:default;margin-top:.8rem}.page-meta .meta-item .meta-item-label{font-weight:500;color:var(--c-text-lighter)}.page-meta .meta-item .meta-item-info{font-weight:400;color:var(--c-text-quote)}.page-meta .edit-link{display:inline-block;margin-right:.25rem}.page-meta .last-updated{float:right}@media (max-width:719px){.page-meta .last-updated{font-size:.8em;float:none}.page-meta .contributors{font-size:.8em}}.page-nav{max-width:var(--content-width);margin:0 auto;padding:1rem 2.5rem 2rem;padding-bottom:0}@media (max-width:959px){.page-nav{padding:2rem}}@media (max-width:419px){.page-nav{padding:1.5rem}}.page-nav .inner{min-height:2rem;margin-top:0;border-top:1px solid var(--c-border);transition:border-color var(--t-color);padding-top:1rem;overflow:auto}.page-nav .prev a:before{content:"\2190"}.page-nav .next{float:right}.page-nav .next a:after{content:"\2192"}.sidebar ul{padding:0;margin:0;list-style-type:none}.sidebar a{display:inline-block}.sidebar .navbar-items{display:none;border-bottom:1px solid var(--c-border);transition:border-color var(--t-color);padding:.5rem 0 .75rem}.sidebar .navbar-items a{font-weight:600}.sidebar .navbar-items .navbar-item{display:block;line-height:1.25rem;font-size:1.1em;padding:.5rem 0 .5rem 1.5rem}.sidebar .sidebar-items{padding:1.5rem 0}@media (max-width:719px){.sidebar .navbar-items{display:block}.sidebar .navbar-items .navbar-dropdown-wrapper .navbar-dropdown .navbar-dropdown-item a.router-link-active:after{top:calc(1rem - 2px)}.sidebar .sidebar-items{padding:1rem 0}}.sidebar-item{cursor:default;border-left:.25rem solid transparent;color:var(--c-text)}.sidebar-item:focus-visible{outline-width:1px;outline-offset:-1px}.sidebar-item.active:not(p.sidebar-heading){font-weight:600;color:var(--c-text-accent);border-left-color:var(--c-text-accent)}.sidebar-item.sidebar-heading{transition:color .15s ease;font-size:1.1em;font-weight:700;padding:.35rem 1.5rem .35rem 1.25rem;width:100%;box-sizing:border-box;margin:0}.sidebar-item.sidebar-heading.collapsible,a.sidebar-item{cursor:pointer}.sidebar-item.sidebar-heading.collapsible+.sidebar-item-children{transition:height .1s ease-out;overflow:hidden;margin-bottom:.75rem}.sidebar-item.sidebar-heading .arrow{position:relative;top:-.12em;left:.5em}.sidebar-item:not(.sidebar-heading){font-size:1em;font-weight:400;display:inline-block;margin:0;padding:.35rem 1rem .35rem 2rem;line-height:1.4;width:100%;box-sizing:border-box}.sidebar-item:not(.sidebar-heading)+.sidebar-item-children{padding-left:1rem;font-size:.95em}.sidebar-item-children .sidebar-item-children .sidebar-item:not(.sidebar-heading){padding:.25rem 1rem .25rem 1.75rem}.sidebar-item-children .sidebar-item-children .sidebar-item:not(.sidebar-heading).active{font-weight:500;border-left-color:transparent}a.sidebar-heading+.sidebar-item-children .sidebar-item:not(.sidebar-heading).active{border-left-color:transparent}a.sidebar-item:hover{color:var(--c-text-accent)}.table-of-contents .badge{vertical-align:middle}.dropdown-enter-from,.dropdown-leave-to{height:0!important}.fade-slide-y-enter-active{transition:all .2s ease}.fade-slide-y-leave-active{transition:all .2s cubic-bezier(1,.5,.8,1)}.fade-slide-y-enter-from,.fade-slide-y-leave-to{transform:translateY(10px);opacity:0}svg[data-v-51dd6513]{right:7.5px;opacity:.75;cursor:pointer;z-index:1}span[data-v-51dd6513],svg.hover[data-v-51dd6513]{opacity:0}.success[data-v-51dd6513],svg[data-v-51dd6513]:hover{opacity:1!important}span[data-v-51dd6513],svg[data-v-51dd6513]{position:absolute}span[data-v-51dd6513]{font-size:.85rem;line-height:1.2rem;right:40px;transition:opacity .5s}:root{--back-to-top-z-index:5;--back-to-top-color:#3eaf7c;--back-to-top-color-hover:#71cda3}.back-to-top{cursor:pointer;position:fixed;bottom:2rem;right:2.5rem;width:2rem;height:1.2rem;background-color:var(--back-to-top-color);-webkit-mask:url(/solana-go-sdk/assets/back-to-top.8efcbe56.svg)no-repeat;mask:url(/solana-go-sdk/assets/back-to-top.8efcbe56.svg)no-repeat;z-index:var(--back-to-top-z-index)}.back-to-top:hover{background-color:var(--back-to-top-color-hover)}@media (max-width:959px){.back-to-top{display:none}}.back-to-top-enter-active,.back-to-top-leave-active{transition:opacity .3s}.back-to-top-enter-from,.back-to-top-leave-to{opacity:0}:root{--nprogress-color:#29d;--nprogress-z-index:1031}#nprogress{pointer-events:none}#nprogress .bar{background:var(--nprogress-color);position:fixed;z-index:var(--nprogress-z-index);top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px var(--nprogress-color),0 0 5px var(--nprogress-color);opacity:1;transform:rotate(3deg) translateY(-4px)}.code-copy-added:hover>div>.code-copy svg{opacity:.75} diff --git a/assets/token-transfer.html.a00e023f.js b/assets/token-transfer.html.a00e023f.js new file mode 100644 index 00000000..b8820833 --- /dev/null +++ b/assets/token-transfer.html.a00e023f.js @@ -0,0 +1,63 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Token Transfer

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+var aliceTokenRandomTokenPubkey = common.PublicKeyFromString("HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL")
+
+var aliceTokenATAPubkey = common.PublicKeyFromString("J1T6kAPowNFcxFh4pmwSqxQM9AitN7HwLyvxV2ZGfLf2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				token.TransferChecked(token.TransferCheckedParam{
+					From:     aliceTokenRandomTokenPubkey,
+					To:       aliceTokenATAPubkey,
+					Mint:     mintPubkey,
+					Auth:     alice.PublicKey,
+					Signers:  []common.PublicKey{},
+					Amount:   1e8,
+					Decimals: 8,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("failed to new tx, err: %v", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send raw tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
`,2);function p(o,e){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/token-transfer.html.c870739e.js b/assets/token-transfer.html.c870739e.js new file mode 100644 index 00000000..f5954b28 --- /dev/null +++ b/assets/token-transfer.html.c870739e.js @@ -0,0 +1 @@ +const e={key:"v-eec8ee88",path:"/tour/token-transfer.html",title:"Token Transfer",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/token-transfer.md"};export{e as data}; diff --git a/assets/transfer.html.30a9e0f8.js b/assets/transfer.html.30a9e0f8.js new file mode 100644 index 00000000..0a6fe397 --- /dev/null +++ b/assets/transfer.html.30a9e0f8.js @@ -0,0 +1,56 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Transfer

We will build a transaction to transfer our SOL out.

A quick guide for a transaction is that:

  1. a transactions is composed by some signatures + a message
  2. a message is composed by one or more instructions + a blockhash

Full Code

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// to fetch recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a transfer tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.Transfer(system.TransferParam{
+					From:   alice.PublicKey,
+					To:     common.PublicKeyFromString("2xNweLHLqrbx4zo1waDvgWJHgsUpPj8Y8icbAFeR4a8i"),
+					Amount: 1e8, // 0.1 SOL
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	// send tx
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55

TIP

  1. fee payer and from can be different wallets but both of them need to sign the transaction
  2. a transaction can composed by many instructions so you can do something like A => B, B => C, C => A and D is the fee payer.
`,7);function p(o,e){return t}var l=n(a,[["render",p]]);export{l as default}; diff --git a/assets/transfer.html.565e3105.js b/assets/transfer.html.565e3105.js new file mode 100644 index 00000000..35f1d489 --- /dev/null +++ b/assets/transfer.html.565e3105.js @@ -0,0 +1 @@ +const e={key:"v-7c3a81e0",path:"/tour/transfer.html",title:"Transfer",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"Full Code",slug:"full-code",children:[]}],git:{updatedTime:1646071383e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"tour/transfer.md"};export{e as data}; diff --git a/assets/upgrade-nonce.html.3f10af1b.js b/assets/upgrade-nonce.html.3f10af1b.js new file mode 100644 index 00000000..6902a777 --- /dev/null +++ b/assets/upgrade-nonce.html.3f10af1b.js @@ -0,0 +1,109 @@ +import{_ as t,r as p,o,c as e,a as n,b as c,F as u,d as s,e as l}from"./app.aa4fcc9f.js";const i={},r=n("h1",{id:"upgrade-nonce",tabindex:"-1"},[n("a",{class:"header-anchor",href:"#upgrade-nonce","aria-hidden":"true"},"#"),s(" Upgrade Nonce")],-1),k=s("Due to "),b={href:"https://solana.com/news/06-01-22-solana-mainnet-beta-outage-report-2",target:"_blank",rel:"noopener noreferrer"},m=s("2022/06/01 Solana outage"),g=s(". All nonce account should be upgraded. You can update it either"),d=l(`
  1. Advance Nonce (need origin authority signature)
package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// get nonce account
+	nonceAccountPubkey := common.PublicKeyFromString("5Covh7EB4HtC5ieeP7GwUH9AHySMmNicBmvXo534wEA8")
+
+	// recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.AdvanceNonceAccount(system.AdvanceNonceAccountParam{
+					Nonce: nonceAccountPubkey,
+					Auth:  alice.PublicKey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
52
53
54
55
56
57
  1. Upgrade Nonce (you can use a random fee payer)
package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	nonceAccountPubkey := common.PublicKeyFromString("DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx")
+
+	// recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.UpgradeNonceAccount(system.UpgradeNonceAccountParam{
+					NonceAccountPubkey: nonceAccountPubkey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
`,4);function f(h,y){const a=p("ExternalLinkIcon");return o(),e(u,null,[r,n("p",null,[k,n("a",b,[m,c(a)]),g]),d],64)}var P=t(i,[["render",f]]);export{P as default}; diff --git a/assets/upgrade-nonce.html.c7e291c7.js b/assets/upgrade-nonce.html.c7e291c7.js new file mode 100644 index 00000000..fd2673aa --- /dev/null +++ b/assets/upgrade-nonce.html.c7e291c7.js @@ -0,0 +1 @@ +const e={key:"v-068ebe3e",path:"/advanced/durable-nonce/upgrade-nonce.html",title:"Upgrade Nonce",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:16553163e5,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/durable-nonce/upgrade-nonce.md"};export{e as data}; diff --git a/assets/use-nonce.html.7b82dfda.js b/assets/use-nonce.html.7b82dfda.js new file mode 100644 index 00000000..13a4c84a --- /dev/null +++ b/assets/use-nonce.html.7b82dfda.js @@ -0,0 +1 @@ +const e={key:"v-5036c796",path:"/advanced/durable-nonce/use-nonce.html",title:"Use Nonce",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1646930333e3,contributors:[{name:"yihau",email:"a122092487@gmail.com",commits:1}]},filePathRelative:"advanced/durable-nonce/use-nonce.md"};export{e as data}; diff --git a/assets/use-nonce.html.e9ee4223.js b/assets/use-nonce.html.e9ee4223.js new file mode 100644 index 00000000..8a1dc934 --- /dev/null +++ b/assets/use-nonce.html.e9ee4223.js @@ -0,0 +1,60 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Use Nonce

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/memo"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// get nonce account
+	nonceAccountPubkey := common.PublicKeyFromString("DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx")
+	nonceAccount, err := c.GetNonceAccount(context.Background(), nonceAccountPubkey.ToBase58())
+	if err != nil {
+		log.Fatalf("failed to get nonce account, err: %v", err)
+	}
+
+	// create a tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: nonceAccount.Nonce.ToBase58(),
+			Instructions: []types.Instruction{
+				system.AdvanceNonceAccount(system.AdvanceNonceAccountParam{
+					Nonce: nonceAccountPubkey,
+					Auth:  alice.PublicKey,
+				}),
+				memo.BuildMemo(memo.BuildMemoParam{
+					Memo: []byte("use nonce"),
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txhash", sig)
+}
+
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
51
52
53
54
55
56
57
58
59

TIP

You need to query nonce again after you used.

`,3);function p(o,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/assets/withdraw.html.5e758645.js b/assets/withdraw.html.5e758645.js new file mode 100644 index 00000000..a950b9f6 --- /dev/null +++ b/assets/withdraw.html.5e758645.js @@ -0,0 +1 @@ +const t={key:"v-10776a13",path:"/programs/stake/withdraw.html",title:"Withdraw",lang:"en-US",frontmatter:{},excerpt:"",headers:[],git:{updatedTime:1707888442e3,contributors:[{name:"yihau",email:"yihau.chen@icloud.com",commits:1}]},filePathRelative:"programs/stake/withdraw.md"};export{t as data}; diff --git a/assets/withdraw.html.99ffd08e.js b/assets/withdraw.html.99ffd08e.js new file mode 100644 index 00000000..c6ded375 --- /dev/null +++ b/assets/withdraw.html.99ffd08e.js @@ -0,0 +1,60 @@ +import{_ as n,e as s}from"./app.aa4fcc9f.js";const a={},t=s(`

Withdraw

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var aliceStakeAccountPubkey = common.PublicKeyFromString("oyRPx4Ejo11J6b4AGaCx9UXUvGzkEmZQoGxKqx4Yp4B")
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	aliceStakeAccountInfo, err := c.GetAccountInfo(context.Background(), aliceStakeAccountPubkey.String())
+	if err != nil {
+		log.Fatalf("failed to get stake account info, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\\n", err)
+	}
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				stake.Withdraw(stake.WithdrawParam{
+					Stake:    aliceStakeAccountPubkey,
+					Auth:     alice.PublicKey,
+					To:       alice.PublicKey,
+					Lamports: aliceStakeAccountInfo.Lamports, // withdraw all
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
`,2);function p(o,c){return t}var u=n(a,[["render",p]]);export{u as default}; diff --git a/index.html b/index.html new file mode 100644 index 00000000..ec4ebfda --- /dev/null +++ b/index.html @@ -0,0 +1,33 @@ + + + + + + + + + Solana Development With Go | Solana Development With Go + + + + + + + + diff --git a/nft/get-metadata.html b/nft/get-metadata.html new file mode 100644 index 00000000..32ba6aaa --- /dev/null +++ b/nft/get-metadata.html @@ -0,0 +1,74 @@ + + + + + + + + + Get Token Metadata | Solana Development With Go + + + + +

Get Token Metadata

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/davecgh/go-spew/spew"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/metaplex/token_metadata"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	// NFT in solana is a normal mint but only mint 1.
+	// If you want to get its metadata, you need to know where it stored.
+	// and you can use `tokenmeta.GetTokenMetaPubkey` to get the metadata account key
+	// here I take a random Degenerate Ape Academy as an example
+	mint := common.PublicKeyFromString("GphF2vTuzhwhLWBWWvD8y5QLCPp1aQC5EnzrWsnbiWPx")
+	metadataAccount, err := token_metadata.GetTokenMetaPubkey(mint)
+	if err != nil {
+		log.Fatalf("faield to get metadata account, err: %v", err)
+	}
+
+	// new a client
+	c := client.NewClient(rpc.MainnetRPCEndpoint)
+
+	// get data which stored in metadataAccount
+	accountInfo, err := c.GetAccountInfo(context.Background(), metadataAccount.ToBase58())
+	if err != nil {
+		log.Fatalf("failed to get accountInfo, err: %v", err)
+	}
+
+	// parse it
+	metadata, err := token_metadata.MetadataDeserialize(accountInfo.Data)
+	if err != nil {
+		log.Fatalf("failed to parse metaAccount, err: %v", err)
+	}
+	spew.Dump(metadata)
+}
+
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
Last Updated:
Contributors: yihau
+ + + diff --git a/nft/mint-a-nft.html b/nft/mint-a-nft.html new file mode 100644 index 00000000..c8ac986d --- /dev/null +++ b/nft/mint-a-nft.html @@ -0,0 +1,170 @@ + + + + + + + + + Mint A NFT | Solana Development With Go + + + + +

Mint A NFT

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/pkg/pointer"
+	"github.com/blocto/solana-go-sdk/program/associated_token_account"
+	"github.com/blocto/solana-go-sdk/program/metaplex/token_metadata"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	mint := types.NewAccount()
+	fmt.Printf("NFT: %v\n", mint.PublicKey.ToBase58())
+
+	collection := types.NewAccount()
+	fmt.Printf("collection: %v\n", collection.PublicKey.ToBase58())
+
+	ata, _, err := common.FindAssociatedTokenAddress(feePayer.PublicKey, mint.PublicKey)
+	if err != nil {
+		log.Fatalf("failed to find a valid ata, err: %v", err)
+	}
+
+	tokenMetadataPubkey, err := token_metadata.GetTokenMetaPubkey(mint.PublicKey)
+	if err != nil {
+		log.Fatalf("failed to find a valid token metadata, err: %v", err)
+
+	}
+	tokenMasterEditionPubkey, err := token_metadata.GetMasterEdition(mint.PublicKey)
+	if err != nil {
+		log.Fatalf("failed to find a valid master edition, err: %v", err)
+	}
+
+	mintAccountRent, err := c.GetMinimumBalanceForRentExemption(context.Background(), token.MintAccountSize)
+	if err != nil {
+		log.Fatalf("failed to get mint account rent, err: %v", err)
+	}
+
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{mint, feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      mint.PublicKey,
+					Owner:    common.TokenProgramID,
+					Lamports: mintAccountRent,
+					Space:    token.MintAccountSize,
+				}),
+				token.InitializeMint(token.InitializeMintParam{
+					Decimals:   0,
+					Mint:       mint.PublicKey,
+					MintAuth:   feePayer.PublicKey,
+					FreezeAuth: &feePayer.PublicKey,
+				}),
+				token_metadata.CreateMetadataAccountV3(token_metadata.CreateMetadataAccountV3Param{
+					Metadata:                tokenMetadataPubkey,
+					Mint:                    mint.PublicKey,
+					MintAuthority:           feePayer.PublicKey,
+					Payer:                   feePayer.PublicKey,
+					UpdateAuthority:         feePayer.PublicKey,
+					UpdateAuthorityIsSigner: true,
+					IsMutable:               true,
+					Data: token_metadata.DataV2{
+						Name:                 "Fake SMS #1355",
+						Symbol:               "FSMB",
+						Uri:                  "https://34c7ef24f4v2aejh75xhxy5z6ars4xv47gpsdrei6fiowptk2nqq.arweave.net/3wXyF1wvK6ARJ_9ue-O58CMuXrz5nyHEiPFQ6z5q02E",
+						SellerFeeBasisPoints: 100,
+						Creators: &[]token_metadata.Creator{
+							{
+								Address:  feePayer.PublicKey,
+								Verified: true,
+								Share:    100,
+							},
+						},
+						Collection: &token_metadata.Collection{
+							Verified: false,
+							Key:      collection.PublicKey,
+						},
+						Uses: nil,
+					},
+					CollectionDetails: nil,
+				}),
+				associated_token_account.CreateAssociatedTokenAccount(associated_token_account.CreateAssociatedTokenAccountParam{
+					Funder:                 feePayer.PublicKey,
+					Owner:                  feePayer.PublicKey,
+					Mint:                   mint.PublicKey,
+					AssociatedTokenAccount: ata,
+				}),
+				token.MintTo(token.MintToParam{
+					Mint:   mint.PublicKey,
+					To:     ata,
+					Auth:   feePayer.PublicKey,
+					Amount: 1,
+				}),
+				token_metadata.CreateMasterEditionV3(token_metadata.CreateMasterEditionParam{
+					Edition:         tokenMasterEditionPubkey,
+					Mint:            mint.PublicKey,
+					UpdateAuthority: feePayer.PublicKey,
+					MintAuthority:   feePayer.PublicKey,
+					Metadata:        tokenMetadataPubkey,
+					Payer:           feePayer.PublicKey,
+					MaxSupply:       pointer.Get[uint64](0),
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println("txid:", sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
Last Updated:
Contributors: yihau
+ + + diff --git a/nft/sign-metadata.html b/nft/sign-metadata.html new file mode 100644 index 00000000..072a191b --- /dev/null +++ b/nft/sign-metadata.html @@ -0,0 +1,90 @@ + + + + + + + + + Sign Metadata | Solana Development With Go + + + + +

Sign Metadata

to convert a unverified creator to a verifeid creator.

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/metaplex/token_metadata"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// mint address
+	nft := common.PublicKeyFromString("FK8eFRgmqewUzr7R6pYUxSPnSNusYmkhAV4e3pUJYdCd")
+
+	tokenMetadataPubkey, err := token_metadata.GetTokenMetaPubkey(nft)
+	if err != nil {
+		log.Fatalf("failed to find a valid token metadata, err: %v", err)
+	}
+
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				token_metadata.SignMetadata(token_metadata.SignMetadataParam{
+					Metadata: tokenMetadataPubkey,
+					Creator:  feePayer.PublicKey,
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	fmt.Println(sig)
+}
+
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
51
52
53
54
55
56
57
Last Updated:
Contributors: yihau
+ + + diff --git a/programs/101/accounts.html b/programs/101/accounts.html new file mode 100644 index 00000000..d21abbb1 --- /dev/null +++ b/programs/101/accounts.html @@ -0,0 +1,147 @@ + + + + + + + + + Accounts | Solana Development With Go + + + + +

Accounts

client

// an account meta list indicates which accounts will be used in a program.
+// we can only read/write accounts in progarms via this list.
+// (except some official vars)
+
+// an account meta includs
+//   - isSigner
+//     when an account is a signer. it needs to sign the tx.
+//   - isWritable
+//     when an account is writable. its data can be modified in this tx.
+
+package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+var programId = common.PublicKeyFromString("CDKLz6tftV4kSD8sPVBD6ACqZpDY4Zuxf8rgSEYzR4M2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get latest blockhash, err: %v\n", err)
+	}
+
+	firstAccount := types.NewAccount()
+	fmt.Printf("first account: %v\n", firstAccount.PublicKey)
+
+	secondAccount := types.NewAccount()
+	fmt.Printf("second account: %v\n", secondAccount.PublicKey)
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, firstAccount},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				{
+					ProgramID: programId,
+					Accounts: []types.AccountMeta{
+						{
+							PubKey:     firstAccount.PublicKey,
+							IsSigner:   true,
+							IsWritable: false,
+						},
+						{
+							PubKey:     secondAccount.PublicKey,
+							IsSigner:   false,
+							IsWritable: true,
+						},
+					},
+					Data: []byte{},
+				},
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send the tx, err: %v", err)
+	}
+
+	// 4jYHKXhZMoDL3HsRuYhFPhCiQJhtNjDzPv8FhSnH6cMi9mwBjgW649uoqvfBjpGbkdFB53NEUux6oq3GUV8e9YQA
+	fmt.Println(sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

program

use solana_program::{
+    account_info::{next_account_info, AccountInfo},
+    entrypoint,
+    entrypoint::ProgramResult,
+    msg,
+    pubkey::Pubkey,
+};
+
+entrypoint!(process_instruction);
+
+fn process_instruction(
+    _program_id: &Pubkey,
+    accounts: &[AccountInfo],
+    _instruction_data: &[u8],
+) -> ProgramResult {
+    let account_info_iter = &mut accounts.iter();
+
+    let first_account_info = next_account_info(account_info_iter)?;
+    msg!(&format!(
+        "first: {} isSigner: {}, isWritable: {}",
+        first_account_info.key.to_string(),
+        first_account_info.is_signer,
+        first_account_info.is_writable,
+    ));
+
+    let second_account_info = next_account_info(account_info_iter)?;
+    msg!(&format!(
+        "second: {} isSigner: {}, isWritable: {}",
+        second_account_info.key.to_string(),
+        second_account_info.is_signer,
+        second_account_info.is_writable,
+    ));
+
+    Ok(())
+}
+
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
Last Updated:
Contributors: Yihau Chen
+ + + diff --git a/programs/101/data.html b/programs/101/data.html new file mode 100644 index 00000000..03597f4c --- /dev/null +++ b/programs/101/data.html @@ -0,0 +1,153 @@ + + + + + + + + + Data | Solana Development With Go + + + + +

Data

client

// data is the most powerful part in an instruction
+// we can pack everything into data, like number, pubkey ... whatever you want.
+// we need to make them become a u8 array when we try to pack it in to a tx.
+
+package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+var programId = common.PublicKeyFromString("c6vyXkJqgA85rYnLiMqxXd39fusJWbRJkoF3jXTd96H")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get latest blockhash, err: %v\n", err)
+	}
+
+	// (our example prgoram will parse the first byte as the selector then print remaining data.)
+	{
+		tx, err := types.NewTransaction(types.NewTransactionParam{
+			Signers: []types.Account{feePayer},
+			Message: types.NewMessage(types.NewMessageParam{
+				FeePayer:        feePayer.PublicKey,
+				RecentBlockhash: res.Blockhash,
+				Instructions: []types.Instruction{
+					{
+						ProgramID: programId,
+						Accounts:  []types.AccountMeta{},
+						Data:      []byte{0, 1, 2, 3, 4},
+					},
+				},
+			}),
+		})
+		if err != nil {
+			log.Fatalf("failed to new a tx, err: %v", err)
+		}
+
+		sig, err := c.SendTransaction(context.Background(), tx)
+		if err != nil {
+			log.Fatalf("failed to send the tx, err: %v", err)
+		}
+
+		// 5X3qhwXJcjSZ3KqY8cTs5YbswBTS7yyqnfTn2diGwGERPrMNUjh9efc6Y9ABanfDUzaQN1n6BHHyMRjDJk2tfy1i
+		fmt.Println(sig)
+	}
+
+	{
+		tx, err := types.NewTransaction(types.NewTransactionParam{
+			Signers: []types.Account{feePayer},
+			Message: types.NewMessage(types.NewMessageParam{
+				FeePayer:        feePayer.PublicKey,
+				RecentBlockhash: res.Blockhash,
+				Instructions: []types.Instruction{
+					{
+						ProgramID: programId,
+						Accounts:  []types.AccountMeta{},
+						Data:      []byte{1, 5, 6, 7, 8},
+					},
+				},
+			}),
+		})
+		if err != nil {
+			log.Fatalf("failed to new a tx, err: %v", err)
+		}
+
+		sig, err := c.SendTransaction(context.Background(), tx)
+		if err != nil {
+			log.Fatalf("failed to send the tx, err: %v", err)
+		}
+
+		// 5GETq1uLwMGdmsAH79pPByzGxQxXS1LqZ6Y9T6dBQ5qiMHFo5EgwDAHccFVEcc9hTYyj5zGfLX6j1uSz5NX7HZ8Q
+		fmt.Println(sig)
+	}
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

program

use solana_program::{
+    account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg,
+    program_error::ProgramError, pubkey::Pubkey,
+};
+
+entrypoint!(process_instruction);
+
+fn process_instruction(
+    _program_id: &Pubkey,
+    _accounts: &[AccountInfo],
+    instruction_data: &[u8],
+) -> ProgramResult {
+    let (selector, rest) = instruction_data
+        .split_first()
+        .ok_or(ProgramError::InvalidInstructionData)?;
+
+    match selector {
+        0 => msg!(&format!(
+            "first instruction is called. remaining data: {:?}",
+            rest,
+        )),
+        1 => msg!(&format!(
+            "second instruction is called. remaining data: {:?}",
+            rest,
+        )),
+        _ => {
+            msg!("invalid called");
+            return Err(ProgramError::InvalidInstructionData);
+        }
+    }
+
+    Ok(())
+}
+
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
Last Updated:
Contributors: Yihau Chen
+ + + diff --git a/programs/101/hello.html b/programs/101/hello.html new file mode 100644 index 00000000..30bcd0ac --- /dev/null +++ b/programs/101/hello.html @@ -0,0 +1,110 @@ + + + + + + + + + Hello | Solana Development With Go + + + + +

Hello

client

// an instruction is the smallest unit in a tx.
+// each instruction represent an action with a program.
+// there are three basic fields in an instruction:
+//   - program id
+//     the program which you would like to interact with
+//   - account meta list
+//     accounts which are used in the program
+//   - data
+//     a u8 array.
+
+package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+var programId = common.PublicKeyFromString("EGz5CDh7dG7BwzqL7y5ePpZNvrw7ehr4E4oGRhCCpiEK")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get latest blockhash, err: %v\n", err)
+	}
+
+	// our first program won't use any accounts and parse any data. we leave them empty atm.
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				{
+					ProgramID: programId,
+					Accounts:  []types.AccountMeta{},
+					Data:      []byte{},
+				},
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a tx, err: %v", err)
+	}
+
+	sig, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send the tx, err: %v", err)
+	}
+
+	// 5eCfcdKGzn8yLGfgX6V1AfjAavTQRGQ936Zyuqejf9W1tTsjABjHTrc66nv5g9qKStmRPr3FeCVznADuCnJ8Zfbq
+	fmt.Println(sig)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63

program

use solana_program::{
+    account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
+};
+
+entrypoint!(process_instruction);
+
+fn process_instruction(
+    _program_id: &Pubkey,
+    _accounts: &[AccountInfo],
+    _instruction_data: &[u8],
+) -> ProgramResult {
+    msg!("hello");
+    Ok(())
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Last Updated:
Contributors: Yihau Chen
+ + + diff --git a/programs/stake/deactivate.html b/programs/stake/deactivate.html new file mode 100644 index 00000000..f576e95c --- /dev/null +++ b/programs/stake/deactivate.html @@ -0,0 +1,85 @@ + + + + + + + + + Deactivate (unstake) | Solana Development With Go + + + + +

Deactivate (unstake)

TIP

Activation requires waiting for 1 epoch. You can use solana-test-validator --slot-per-epoch <SLOT> for test.

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var aliceStakeAccountPubkey = common.PublicKeyFromString("oyRPx4Ejo11J6b4AGaCx9UXUvGzkEmZQoGxKqx4Yp4B")
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				stake.Deactivate(stake.DeactivateParam{
+					Stake: aliceStakeAccountPubkey,
+					Auth:  alice.PublicKey,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
Last Updated:
Contributors: yihau
+ + + diff --git a/programs/stake/delegate.html b/programs/stake/delegate.html new file mode 100644 index 00000000..9588885a --- /dev/null +++ b/programs/stake/delegate.html @@ -0,0 +1,98 @@ + + + + + + + + + Delegate (stake) | Solana Development With Go + + + + +

Delegate (stake)

TIP

Activation requires waiting for 1 epoch. You can use solana-test-validator --slot-per-epoch <SLOT> for test.

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var aliceStakeAccountPubkey = common.PublicKeyFromString("oyRPx4Ejo11J6b4AGaCx9UXUvGzkEmZQoGxKqx4Yp4B")
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	// obtain a random voting account here, or you can use your own. please note that a voting account is required here, rather than an identity.
+	voteAccountStatus, err := c.GetVoteAccounts(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get vote account status, err: %v", err)
+	}
+	if len(voteAccountStatus.Current) == 0 {
+		log.Fatalf("there are no decent voting accounts")
+	}
+	delegatedVotePubkey := voteAccountStatus.Current[0].VotePubkey
+	fmt.Println("delegated vote pubkey:", delegatedVotePubkey.String())
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				stake.DelegateStake(stake.DelegateStakeParam{
+					Stake: aliceStakeAccountPubkey,
+					Auth:  alice.PublicKey,
+					Vote:  delegatedVotePubkey,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Last Updated:
Contributors: yihau
+ + + diff --git a/programs/stake/initialize-account.html b/programs/stake/initialize-account.html new file mode 100644 index 00000000..86410593 --- /dev/null +++ b/programs/stake/initialize-account.html @@ -0,0 +1,112 @@ + + + + + + + + + Initialize Account | Solana Development With Go + + + + +

Initialize Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var stakeAmountInLamports uint64 = 1_000_000_000 // 1 SOL
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	// create an stake account
+	stakeAccount := types.NewAccount()
+	fmt.Println("stake account:", stakeAccount.PublicKey.ToBase58())
+
+	// get rent
+	rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(
+		context.Background(),
+		stake.AccountSize,
+	)
+	if err != nil {
+		log.Fatalf("get min balacne for rent exemption, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      stakeAccount.PublicKey,
+					Owner:    common.StakeProgramID,
+					Lamports: rentExemptionBalance + stakeAmountInLamports,
+					Space:    stake.AccountSize,
+				}),
+				stake.Initialize(stake.InitializeParam{
+					Stake: stakeAccount.PublicKey,
+					Auth: stake.Authorized{
+						Staker:     alice.PublicKey,
+						Withdrawer: alice.PublicKey,
+					},
+					Lockup: stake.Lockup{},
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, stakeAccount},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Last Updated:
Contributors: yihau
+ + + diff --git a/programs/stake/withdraw.html b/programs/stake/withdraw.html new file mode 100644 index 00000000..b9f4fb10 --- /dev/null +++ b/programs/stake/withdraw.html @@ -0,0 +1,92 @@ + + + + + + + + + Withdraw | Solana Development With Go + + + + +

Withdraw

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/stake"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var aliceStakeAccountPubkey = common.PublicKeyFromString("oyRPx4Ejo11J6b4AGaCx9UXUvGzkEmZQoGxKqx4Yp4B")
+
+func main() {
+	c := client.NewClient(rpc.LocalnetRPCEndpoint)
+
+	aliceStakeAccountInfo, err := c.GetAccountInfo(context.Background(), aliceStakeAccountPubkey.String())
+	if err != nil {
+		log.Fatalf("failed to get stake account info, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				stake.Withdraw(stake.WithdrawParam{
+					Stake:    aliceStakeAccountPubkey,
+					Auth:     alice.PublicKey,
+					To:       alice.PublicKey,
+					Lamports: aliceStakeAccountInfo.Lamports, // withdraw all
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
Last Updated:
Contributors: yihau
+ + + diff --git a/rpc/get-signatures-for-address.html b/rpc/get-signatures-for-address.html new file mode 100644 index 00000000..00bcb71b --- /dev/null +++ b/rpc/get-signatures-for-address.html @@ -0,0 +1,185 @@ + + + + + + + + + Get Signatures For Address | Solana Development With Go + + + + +

Get Signatures For Address

Fetch tx histroy.

All

	// get all (limit is between 1 ~ 1,000, default is 1,000)
+	{
+		res, err := c.GetSignaturesForAddress(context.Background(), target)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8

Limit

	// get latest X tx
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Limit: 5,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Range

context:

	/*
+		if a txhash list like:
+
+		(new)
+		3gwJwVorVprqZmm1ULAp9bKQy6sQ7skG11XYdMSQigA936MBANcSBy6NcNJF2yPf9ycgzZ6vFd4pjAY7qSko61Au
+		wTEnw3vpBthzLUD6gv9B3aC4dQNp4hews85ipM3w9MGZAh38HZ2im9LaWY7aRusVN5Wj33mNvqSRDNyC43u6GQs
+		3e6dRv5KnvpU43VjVjbsubvPR1yFK9b922WcTugyTBSdWdToeCK16NccSaxY6XJ5yi51UswP3ZDe3VJBZTVg2MCW
+		2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy
+		2uFaNDgQWZsgZvR6s3WQKwaCxFgS4ML7xrZyAqgmuTSEuGmrWyCcTrjtajr6baYR6FaVLZ4PWgyt55EmTcT8S7Sg
+		4XGVHHpLW99AUFEd6RivasG57vqu4EMMNdcQdmphepmW484dMYtWLkYw4nSNnSpKiDoYDbSu9ksxECNKBk2JEyHQ
+		3kjLJokcYqAhQjERCVutv5gdUuQ1HsxSCcFsJdQbqNkqd5ML8WRaZJguZgpWH8isCfyEN8YktxxPPNJURhAtvUKE
+		(old)
+	*/
+
1
2
3
4
5
6
7
8
9
10
11
12
13

Before

	// you can fetch the last 3 tx by
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Before: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit:  3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Until

	// you can fetch the latest 3 tx by `until`
+	// * the result will be different if there are some newer txs added.
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Until: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit: 3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Full Code

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/davecgh/go-spew/spew"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	target := "Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo"
+
+	// get all (limit is between 1 ~ 1,000, default is 1,000)
+	{
+		res, err := c.GetSignaturesForAddress(context.Background(), target)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
+	// get latest X tx
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Limit: 5,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
+	/*
+		if a txhash list like:
+
+		(new)
+		3gwJwVorVprqZmm1ULAp9bKQy6sQ7skG11XYdMSQigA936MBANcSBy6NcNJF2yPf9ycgzZ6vFd4pjAY7qSko61Au
+		wTEnw3vpBthzLUD6gv9B3aC4dQNp4hews85ipM3w9MGZAh38HZ2im9LaWY7aRusVN5Wj33mNvqSRDNyC43u6GQs
+		3e6dRv5KnvpU43VjVjbsubvPR1yFK9b922WcTugyTBSdWdToeCK16NccSaxY6XJ5yi51UswP3ZDe3VJBZTVg2MCW
+		2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy
+		2uFaNDgQWZsgZvR6s3WQKwaCxFgS4ML7xrZyAqgmuTSEuGmrWyCcTrjtajr6baYR6FaVLZ4PWgyt55EmTcT8S7Sg
+		4XGVHHpLW99AUFEd6RivasG57vqu4EMMNdcQdmphepmW484dMYtWLkYw4nSNnSpKiDoYDbSu9ksxECNKBk2JEyHQ
+		3kjLJokcYqAhQjERCVutv5gdUuQ1HsxSCcFsJdQbqNkqd5ML8WRaZJguZgpWH8isCfyEN8YktxxPPNJURhAtvUKE
+		(old)
+	*/
+
+	// you can fetch the last 3 tx by
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Before: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit:  3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+
+	// you can fetch the latest 3 tx by `until`
+	// * the result will be different if there are some newer txs added.
+	{
+		res, err := c.GetSignaturesForAddressWithConfig(
+			context.Background(),
+			target,
+			rpc.GetSignaturesForAddressConfig{
+				Until: "2nYnHvbVuwmYeara3VjoCt9uS8ZXrSra5DRK7QBT8i5acoBiSK3FQY2vsaDSJQ6QX5i1pkvyRRjL1oUATMLZEsqy",
+				Limit: 3,
+			},
+		)
+		if err != nil {
+			log.Fatalf("failed to GetSignaturesForAddress, err: %v", err)
+		}
+		spew.Dump(res)
+	}
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Last Updated:
Contributors: Yihau Chen
+ + + diff --git a/tour/create-account.html b/tour/create-account.html new file mode 100644 index 00000000..ce995455 --- /dev/null +++ b/tour/create-account.html @@ -0,0 +1,129 @@ + + + + + + + + + Create Account | Solana Development With Go + + + + +

Create Account

An account is a basic identity on chain.

Create a new account

		account := types.NewAccount()
+
1

Recover from a key

Base58

		account, _ := types.AccountFromBase58("28WJTTqMuurAfz6yqeTrFMXeFd91uzi9i1AW6F5KyHQDS9siXb8TquAuatvLuCEYdggyeiNKLAUr3w7Czmmf2Rav")
+
1

Bytes

		account, _ := types.AccountFromBytes([]byte{
+			56, 125, 59, 118, 230, 173, 152, 169, 197, 34,
+			168, 187, 217, 160, 119, 204, 124, 69, 52, 136,
+			214, 49, 207, 234, 79, 70, 83, 224, 1, 224, 36,
+			247, 131, 83, 164, 85, 139, 215, 183, 148, 79,
+			198, 74, 93, 156, 157, 208, 99, 221, 127, 51,
+			156, 43, 196, 101, 144, 104, 252, 221, 108,
+			245, 104, 13, 151,
+		})
+
1
2
3
4
5
6
7
8
9

BIP 39

		mnemonic := "pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		account, _ := types.AccountFromSeed(seed[:32])
+
1
2
3

BIP 44

		mnemonic := "neither lonely flavor argue grass remind eye tag avocado spot unusual intact"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		path := `m/44'/501'/0'/0'`
+		derivedKey, _ := hdwallet.Derived(path, seed)
+		account, _ := types.AccountFromSeed(derivedKey.PrivateKey)
+
1
2
3
4
5

Full Code

package main
+
+import (
+	"fmt"
+
+	"github.com/blocto/solana-go-sdk/pkg/hdwallet"
+	"github.com/blocto/solana-go-sdk/types"
+	"github.com/mr-tron/base58"
+	"github.com/tyler-smith/go-bip39"
+)
+
+func main() {
+	// create a new account
+	{
+		account := types.NewAccount()
+		fmt.Println(account.PublicKey.ToBase58())
+		fmt.Println(base58.Encode(account.PrivateKey))
+	}
+
+	// from a base58 pirvate key
+	{
+		account, _ := types.AccountFromBase58("28WJTTqMuurAfz6yqeTrFMXeFd91uzi9i1AW6F5KyHQDS9siXb8TquAuatvLuCEYdggyeiNKLAUr3w7Czmmf2Rav")
+		fmt.Println(account.PublicKey.ToBase58())
+	}
+
+	// from a private key bytes
+	{
+		account, _ := types.AccountFromBytes([]byte{
+			56, 125, 59, 118, 230, 173, 152, 169, 197, 34,
+			168, 187, 217, 160, 119, 204, 124, 69, 52, 136,
+			214, 49, 207, 234, 79, 70, 83, 224, 1, 224, 36,
+			247, 131, 83, 164, 85, 139, 215, 183, 148, 79,
+			198, 74, 93, 156, 157, 208, 99, 221, 127, 51,
+			156, 43, 196, 101, 144, 104, 252, 221, 108,
+			245, 104, 13, 151,
+		})
+		fmt.Println(account.PublicKey.ToBase58())
+	}
+
+	// from bip 39 (solana cli tool)
+	{
+		mnemonic := "pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		account, _ := types.AccountFromSeed(seed[:32])
+		fmt.Println(account.PublicKey.ToBase58())
+	}
+
+	// from bip 44 (phantom)
+	{
+		mnemonic := "neither lonely flavor argue grass remind eye tag avocado spot unusual intact"
+		seed := bip39.NewSeed(mnemonic, "") // (mnemonic, password)
+		path := `m/44'/501'/0'/0'`
+		derivedKey, _ := hdwallet.Derived(path, seed)
+		account, _ := types.AccountFromSeed(derivedKey.PrivateKey)
+		fmt.Printf("%v => %v\n", path, account.PublicKey.ToBase58())
+
+		// others
+		for i := 1; i < 10; i++ {
+			path := fmt.Sprintf(`m/44'/501'/%d'/0'`, i)
+			derivedKey, _ := hdwallet.Derived(path, seed)
+			account, _ := types.AccountFromSeed(derivedKey.PrivateKey)
+			fmt.Printf("%v => %v\n", path, account.PublicKey.ToBase58())
+		}
+		/*
+			m/44'/501'/0'/0' => 5vftMkHL72JaJG6ExQfGAsT2uGVHpRR7oTNUPMs68Y2N
+			m/44'/501'/1'/0' => GcXbfQ5yY3uxCyBNDPBbR5FjumHf89E7YHXuULfGDBBv
+			m/44'/501'/2'/0' => 7QPgyQwNLqnoSwHEuK8wKy2Y3Ani6EHoZRihTuWkwxbc
+			m/44'/501'/3'/0' => 5aE8UprEEWtpVskhxo3f8ETco2kVKiZT9SS3D5Lcg8s2
+			m/44'/501'/4'/0' => 5n6afo6LZmzH1J4R38ZCaNSwaztLjd48nWwToLQkCHxp
+			m/44'/501'/5'/0' => 2Gr1hWnbaqGXMghicSTHncqV7GVLLddNFJDC7YJoso8M
+			m/44'/501'/6'/0' => BNMDY3tCyYbayMzBjZm8RW59unpDWcQRfVmWXCJhLb7D
+			m/44'/501'/7'/0' => 9CySTpi4iC85gMW6G4BMoYbNBsdyJrfseHoGmViLha63
+			m/44'/501'/8'/0' => ApteF7PmUWS8Lzm6tJPkWgrxSFW5LwYGWCUJ2ByAec91
+			m/44'/501'/9'/0' => 6frdqXQAgJMyKwmZxkLYbdGjnYTvUceh6LNhkQt2siQp
+		*/
+	}
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/create-mint.html b/tour/create-mint.html new file mode 100644 index 00000000..07118986 --- /dev/null +++ b/tour/create-mint.html @@ -0,0 +1,108 @@ + + + + + + + + + Create Mint | Solana Development With Go + + + + +

Create Mint

create a new token

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// create an mint account
+	mint := types.NewAccount()
+	fmt.Println("mint:", mint.PublicKey.ToBase58())
+
+	// get rent
+	rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(
+		context.Background(),
+		token.MintAccountSize,
+	)
+	if err != nil {
+		log.Fatalf("get min balacne for rent exemption, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      mint.PublicKey,
+					Owner:    common.TokenProgramID,
+					Lamports: rentExemptionBalance,
+					Space:    token.MintAccountSize,
+				}),
+				token.InitializeMint(token.InitializeMintParam{
+					Decimals:   8,
+					Mint:       mint.PublicKey,
+					MintAuth:   alice.PublicKey,
+					FreezeAuth: nil,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, mint},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/create-token-account.html b/tour/create-token-account.html new file mode 100644 index 00000000..03a9056a --- /dev/null +++ b/tour/create-token-account.html @@ -0,0 +1,166 @@ + + + + + + + + + Create Token Account | Solana Development With Go + + + + +

Create Token Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/associated_token_account"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	ata, _, err := common.FindAssociatedTokenAddress(alice.PublicKey, mintPubkey)
+	if err != nil {
+		log.Fatalf("find ata error, err: %v", err)
+	}
+	fmt.Println("ata:", ata.ToBase58())
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				associated_token_account.Create(associated_token_account.CreateParam{
+					Funder:                 feePayer.PublicKey,
+					Owner:                  alice.PublicKey,
+					Mint:                   mintPubkey,
+					AssociatedTokenAccount: ata,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send raw tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62

Random

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	aliceRandomTokenAccount := types.NewAccount()
+	fmt.Println("alice token account:", aliceRandomTokenAccount.PublicKey.ToBase58())
+
+	rentExemptionBalance, err := c.GetMinimumBalanceForRentExemption(context.Background(), token.TokenAccountSize)
+	if err != nil {
+		log.Fatalf("get min balacne for rent exemption, err: %v", err)
+	}
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				system.CreateAccount(system.CreateAccountParam{
+					From:     feePayer.PublicKey,
+					New:      aliceRandomTokenAccount.PublicKey,
+					Owner:    common.TokenProgramID,
+					Lamports: rentExemptionBalance,
+					Space:    token.TokenAccountSize,
+				}),
+				token.InitializeAccount(token.InitializeAccountParam{
+					Account: aliceRandomTokenAccount.PublicKey,
+					Mint:    mintPubkey,
+					Owner:   alice.PublicKey,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, aliceRandomTokenAccount},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/get-mint.html b/tour/get-mint.html new file mode 100644 index 00000000..4f05854a --- /dev/null +++ b/tour/get-mint.html @@ -0,0 +1,64 @@ + + + + + + + + + Get Mint | Solana Development With Go + + + + +

Get Mint

get detail from a exist mint

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	getAccountInfoResponse, err := c.GetAccountInfo(context.TODO(), mintPubkey.ToBase58())
+	if err != nil {
+		log.Fatalf("failed to get account info, err: %v", err)
+	}
+
+	mintAccount, err := token.MintAccountFromData(getAccountInfoResponse.Data)
+	if err != nil {
+		log.Fatalf("failed to parse data to a mint account, err: %v", err)
+	}
+
+	fmt.Printf("%+v\n", mintAccount)
+	// {MintAuthority:9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde Supply:0 Decimals:8 IsInitialized:true FreezeAuthority:<nil>}
+}
+
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
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/get-sol-balance.html b/tour/get-sol-balance.html new file mode 100644 index 00000000..bb2040ac --- /dev/null +++ b/tour/get-sol-balance.html @@ -0,0 +1,55 @@ + + + + + + + + + Get Balance | Solana Development With Go + + + + +

Get Balance

get sol balance

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	balance, err := c.GetBalance(
+		context.TODO(),
+		"9qeP9DmjXAmKQc4wy133XZrQ3Fo4ejsYteA7X4YFJ3an",
+	)
+	if err != nil {
+		log.Fatalf("failed to request airdrop, err: %v", err)
+	}
+	fmt.Println(balance)
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

TIP

1 SOL = 10^9 lamports

Last Updated:
Contributors: yihau
+ + + diff --git a/tour/get-token-account.html b/tour/get-token-account.html new file mode 100644 index 00000000..349ea77f --- /dev/null +++ b/tour/get-token-account.html @@ -0,0 +1,62 @@ + + + + + + + + + Get Token Account | Solana Development With Go + + + + +

Get Token Account

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// token account address
+	getAccountInfoResponse, err := c.GetAccountInfo(context.TODO(), "HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL")
+	if err != nil {
+		log.Fatalf("failed to get account info, err: %v", err)
+	}
+
+	tokenAccount, err := token.TokenAccountFromData(getAccountInfoResponse.Data)
+	if err != nil {
+		log.Fatalf("failed to parse data to a token account, err: %v", err)
+	}
+
+	fmt.Printf("%+v\n", tokenAccount)
+	// {Mint:F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo Owner:9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde Amount:100000000 Delegate:<nil> State:1 IsNative:<nil> DelegatedAmount:0 CloseAuthority:<nil>}
+}
+
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
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/get-token-balance.html b/tour/get-token-balance.html new file mode 100644 index 00000000..e036c4c2 --- /dev/null +++ b/tour/get-token-balance.html @@ -0,0 +1,63 @@ + + + + + + + + + Get Token Balance | Solana Development With Go + + + + +

Get Token Balance

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// should pass a token account address
+	balance, decimals, err := c.GetTokenAccountBalance(
+		context.Background(),
+		"HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL",
+	)
+	if err != nil {
+		log.Fatalln("get balance error", err)
+	}
+	// the smallest unit like lamports
+	fmt.Println("balance", balance)
+	// the decimals of mint which token account holds
+	fmt.Println("decimals", decimals)
+
+	// if you want use a normal unit, you can do
+	// balance / 10^decimals
+}
+
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
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/mint-to.html b/tour/mint-to.html new file mode 100644 index 00000000..c0847011 --- /dev/null +++ b/tour/mint-to.html @@ -0,0 +1,94 @@ + + + + + + + + + Mint To | Solana Development With Go + + + + +

Mint To

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+var aliceTokenRandomTokenPubkey = common.PublicKeyFromString("HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL")
+
+var aliceTokenATAPubkey = common.PublicKeyFromString("J1T6kAPowNFcxFh4pmwSqxQM9AitN7HwLyvxV2ZGfLf2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				token.MintToChecked(token.MintToCheckedParam{
+					Mint:     mintPubkey,
+					Auth:     alice.PublicKey,
+					Signers:  []common.PublicKey{},
+					To:       aliceTokenRandomTokenPubkey,
+					Amount:   1e8,
+					Decimals: 8,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("generate tx error, err: %v\n", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send raw tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/request-airdrop.html b/tour/request-airdrop.html new file mode 100644 index 00000000..1d468eb2 --- /dev/null +++ b/tour/request-airdrop.html @@ -0,0 +1,56 @@ + + + + + + + + + Request Airdrop | Solana Development With Go + + + + +

Request Airdrop

Request some airdrop for testing.

package main
+
+import (
+	"context"
+	"fmt"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/rpc"
+)
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+	sig, err := c.RequestAirdrop(
+		context.TODO(),
+		"9qeP9DmjXAmKQc4wy133XZrQ3Fo4ejsYteA7X4YFJ3an", // address
+		1e9, // lamports (1 SOL = 10^9 lamports)
+	)
+	if err != nil {
+		log.Fatalf("failed to request airdrop, err: %v", err)
+	}
+	fmt.Println(sig)
+}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/token-transfer.html b/tour/token-transfer.html new file mode 100644 index 00000000..f9075676 --- /dev/null +++ b/tour/token-transfer.html @@ -0,0 +1,95 @@ + + + + + + + + + Token Transfer | Solana Development With Go + + + + +

Token Transfer

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/token"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+var mintPubkey = common.PublicKeyFromString("F6tecPzBMF47yJ2EN6j2aGtE68yR5jehXcZYVZa6ZETo")
+
+var aliceTokenRandomTokenPubkey = common.PublicKeyFromString("HeCBh32JJ8DxcjTyc6q46tirHR8hd2xj3mGoAcQ7eduL")
+
+var aliceTokenATAPubkey = common.PublicKeyFromString("J1T6kAPowNFcxFh4pmwSqxQM9AitN7HwLyvxV2ZGfLf2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	res, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("get recent block hash error, err: %v\n", err)
+	}
+
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: res.Blockhash,
+			Instructions: []types.Instruction{
+				token.TransferChecked(token.TransferCheckedParam{
+					From:     aliceTokenRandomTokenPubkey,
+					To:       aliceTokenATAPubkey,
+					Mint:     mintPubkey,
+					Auth:     alice.PublicKey,
+					Signers:  []common.PublicKey{},
+					Amount:   1e8,
+					Decimals: 8,
+				}),
+			},
+		}),
+		Signers: []types.Account{feePayer, alice},
+	})
+	if err != nil {
+		log.Fatalf("failed to new tx, err: %v", err)
+	}
+
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("send raw tx error, err: %v\n", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55
56
57
58
59
60
61
62
Last Updated:
Contributors: yihau
+ + + diff --git a/tour/transfer.html b/tour/transfer.html new file mode 100644 index 00000000..2a98b7a8 --- /dev/null +++ b/tour/transfer.html @@ -0,0 +1,88 @@ + + + + + + + + + Transfer | Solana Development With Go + + + + +

Transfer

We will build a transaction to transfer our SOL out.

A quick guide for a transaction is that:

  1. a transactions is composed by some signatures + a message
  2. a message is composed by one or more instructions + a blockhash

Full Code

package main
+
+import (
+	"context"
+	"log"
+
+	"github.com/blocto/solana-go-sdk/client"
+	"github.com/blocto/solana-go-sdk/common"
+	"github.com/blocto/solana-go-sdk/program/system"
+	"github.com/blocto/solana-go-sdk/rpc"
+	"github.com/blocto/solana-go-sdk/types"
+)
+
+// FUarP2p5EnxD66vVDL4PWRoWMzA56ZVHG24hpEDFShEz
+var feePayer, _ = types.AccountFromBase58("4TMFNY9ntAn3CHzguSAvDNLPRoQTaK3sWbQQXdDXaE6KWRBLufGL6PJdsD2koiEe3gGmMdRK3aAw7sikGNksHJrN")
+
+// 9aE476sH92Vz7DMPyq5WLPkrKWivxeuTKEFKd2sZZcde
+var alice, _ = types.AccountFromBase58("4voSPg3tYuWbKzimpQK9EbXHmuyy5fUrtXvpLDMLkmY6TRncaTHAKGD8jUg3maB5Jbrd9CkQg4qjJMyN6sQvnEF2")
+
+func main() {
+	c := client.NewClient(rpc.DevnetRPCEndpoint)
+
+	// to fetch recent blockhash
+	recentBlockhashResponse, err := c.GetLatestBlockhash(context.Background())
+	if err != nil {
+		log.Fatalf("failed to get recent blockhash, err: %v", err)
+	}
+
+	// create a transfer tx
+	tx, err := types.NewTransaction(types.NewTransactionParam{
+		Signers: []types.Account{feePayer, alice},
+		Message: types.NewMessage(types.NewMessageParam{
+			FeePayer:        feePayer.PublicKey,
+			RecentBlockhash: recentBlockhashResponse.Blockhash,
+			Instructions: []types.Instruction{
+				system.Transfer(system.TransferParam{
+					From:   alice.PublicKey,
+					To:     common.PublicKeyFromString("2xNweLHLqrbx4zo1waDvgWJHgsUpPj8Y8icbAFeR4a8i"),
+					Amount: 1e8, // 0.1 SOL
+				}),
+			},
+		}),
+	})
+	if err != nil {
+		log.Fatalf("failed to new a transaction, err: %v", err)
+	}
+
+	// send tx
+	txhash, err := c.SendTransaction(context.Background(), tx)
+	if err != nil {
+		log.Fatalf("failed to send tx, err: %v", err)
+	}
+
+	log.Println("txhash:", txhash)
+}
+
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
51
52
53
54
55

TIP

  1. fee payer and from can be different wallets but both of them need to sign the transaction
  2. a transaction can composed by many instructions so you can do something like A => B, B => C, C => A and D is the fee payer.
Last Updated:
Contributors: yihau
+ + +