ExecuteScriptAtBlockID Access API Method
पैरामीटर
Script
डोरी
आवश्यक
लोड हो रहा है...
Arguments
डोरी
आवश्यक
लोड हो रहा है...
BlockId
डोरी
आवश्यक
लोड हो रहा है...
रिटर्न
कीमत
डोरी
लोड हो रहा है...
अनुरोध
1पैकेज मुख्य23आयात (4"प्रसंग"5"एफएमटी"6"लकड़ी का लट्ठा"7"strconv"89"github.com/onflow/flow/protobuf/go/flow/access"10)111213समारोह मुख्य ( ) {1415// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.16client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")17ctx := context.Background()18यदि त्रुटि != शून्य {19log.Fatalf("err: %v", err)20}21// Get Latest (sealed) block22latestResp, err := client.GetLatestBlock(ctx, &access.GetLatestBlockRequest{IsSealed: true})23यदि त्रुटि != शून्य {24log.Fatal("Get latest block failed: ", err)25}26fmt.Println("Latest block height: ", latestResp.Block.Height)2728// execute script at latest block ID29script := []byte(`30pub fun main(a: Int): Int {31return a + 1032}33`)3435// Convert integer to JSON-CDC (Cadence JSON)36arg := 1037// JSON-CDC representation of an integer is a JSON object with "type" and "value" fields38jsonCDC := fmt.Sprintf(`{"type":"Int","value":"%s"}`, strconv.Itoa(arg))3940// Create script arguments41args := [][]byte{[]byte(jsonCDC)}4243valueHeightResp, err := client.ExecuteScriptAtBlockID(ctx, &access.ExecuteScriptAtBlockIDRequest{Script: script, Arguments: args, BlockId: latestResp.Block.Id})44यदि त्रुटि != शून्य {45log.Fatal("execute script at block ID failed: ", err)46}47fmt.Printf("executed script , returned %s \n", string(valueHeightResp.Value))4849}
1पैकेज मुख्य23आयात (4"प्रसंग"5"एफएमटी"6"लकड़ी का लट्ठा"7"strconv"89"github.com/onflow/flow/protobuf/go/flow/access"10)111213समारोह मुख्य ( ) {1415// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.16client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")17ctx := context.Background()18यदि त्रुटि != शून्य {19log.Fatalf("err: %v", err)20}21// Get Latest (sealed) block22latestResp, err := client.GetLatestBlock(ctx, &access.GetLatestBlockRequest{IsSealed: true})23यदि त्रुटि != शून्य {24log.Fatal("Get latest block failed: ", err)25}26fmt.Println("Latest block height: ", latestResp.Block.Height)2728// execute script at latest block ID29script := []byte(`30pub fun main(a: Int): Int {31return a + 1032}33`)3435// Convert integer to JSON-CDC (Cadence JSON)36arg := 1037// JSON-CDC representation of an integer is a JSON object with "type" and "value" fields38jsonCDC := fmt.Sprintf(`{"type":"Int","value":"%s"}`, strconv.Itoa(arg))3940// Create script arguments41args := [][]byte{[]byte(jsonCDC)}4243valueHeightResp, err := client.ExecuteScriptAtBlockID(ctx, &access.ExecuteScriptAtBlockIDRequest{Script: script, Arguments: args, BlockId: latestResp.Block.Id})44यदि त्रुटि != शून्य {45log.Fatal("execute script at block ID failed: ", err)46}47fmt.Printf("executed script , returned %s \n", string(valueHeightResp.Value))4849}
अब तक कोई खाता नहीं है?
अपना बनाएँ Quicknode endpoint कुछ ही सेकंड में निर्माण शुरू करें
मुफ़्त में शुरुआत करें