From 47ba99307c657bfba21958817f6f9fdda13787e5 Mon Sep 17 00:00:00 2001 From: Huan-Cheng Chang Date: Fri, 6 Sep 2024 10:19:49 +0100 Subject: [PATCH] update --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 92013ba..70d6e41 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,8 @@ err := val.Unmarshal(&transfer) ```go import ( - "github.com/trilitech/tzgo/micheline" + "context" + "github.com/trilitech/tzgo/rpc" "github.com/trilitech/tzgo/tezos" ) @@ -280,17 +281,22 @@ import ( addr := tezos.MustParseAddress("KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9") // init RPC client -c, _ := rpc.NewClient("https://rpc.tzstats.com", nil) +c, _ := rpc.NewClient("https://rpc.tzpro.io", nil) +ctx := context.TODO() // fetch the contract's script and most recent storage script, _ := c.GetContractScript(ctx, addr) -// bigmap pointers as []int64 -ids := script.BigmapsById() - // bigmap pointers as named map[string]int64 (names from type annotations) -named := script.BigmapsByName() +// Note that if a bigmap is anonymous, e.g. in a list, a temporary name will +// be returned here +named := script.Bigmaps() +// bigmap pointers as []int64 +ids := []int64{} +for _, v := range named { + ids = append(ids, v) +} ``` #### Fetch and decode bigmap values