ExecuteScriptAtLatestBlock Access API Method
पैरामीटर
Script
डोरी
आवश्यक
लोड हो रहा है...
Arguments
डोरी
आवश्यक
लोड हो रहा है...
रिटर्न
कीमत
डोरी
लोड हो रहा है...
अनुरोध
1पैकेज मुख्य23आयात (4"प्रसंग"5"एनकोडिंग/जेसन"6"एफएमटी"7"लकड़ी का लट्ठा"8"strconv"910"github.com/onflow/flow/protobuf/go/flow/access"11)121314समारोह मुख्य ( ) {1516// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.17client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")18ctx := context.Background()19यदि त्रुटि != शून्य {20log.Fatalf("err: %v", err)21}2223// Execute Script at Latest Block24script := []byte(`25pub fun main(a: Int): Int {26return a + 1027}28`)2930// Convert integer to JSON-CDC (Cadence JSON)31arg := 1032// JSON-CDC representation of an integer is a JSON object with "type" and "value" fields33jsonCDC := fmt.Sprintf(`{"type":"Int","value":"%s"}`, strconv.Itoa(arg))3435// Create script arguments36args := [][]byte{[]byte(jsonCDC)}3738req := &access.ExecuteScriptAtLatestBlockRequest{39Script: script,40Arguments: args,41}4243valueResp, err := client.ExecuteScriptAtLatestBlock(ctx, req)44respJSON, err := json.Marshal(valueResp)45यदि त्रुटि != शून्य {46log.Fatal("err: ", err)47}48fmt.Println("ExecuteScriptAtLatestBlock response:", string(respJSON))4950}
1पैकेज मुख्य23आयात (4"प्रसंग"5"एनकोडिंग/जेसन"6"एफएमटी"7"लकड़ी का लट्ठा"8"strconv"910"github.com/onflow/flow/protobuf/go/flow/access"11)121314समारोह मुख्य ( ) {1516// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.17client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")18ctx := context.Background()19यदि त्रुटि != शून्य {20log.Fatalf("err: %v", err)21}2223// Execute Script at Latest Block24script := []byte(`25pub fun main(a: Int): Int {26return a + 1027}28`)2930// Convert integer to JSON-CDC (Cadence JSON)31arg := 1032// JSON-CDC representation of an integer is a JSON object with "type" and "value" fields33jsonCDC := fmt.Sprintf(`{"type":"Int","value":"%s"}`, strconv.Itoa(arg))3435// Create script arguments36args := [][]byte{[]byte(jsonCDC)}3738req := &access.ExecuteScriptAtLatestBlockRequest{39Script: script,40Arguments: args,41}4243valueResp, err := client.ExecuteScriptAtLatestBlock(ctx, req)44respJSON, err := json.Marshal(valueResp)45यदि त्रुटि != शून्य {46log.Fatal("err: ", err)47}48fmt.Println("ExecuteScriptAtLatestBlock response:", string(respJSON))4950}
अब तक कोई खाता नहीं है?
अपना बनाएँ Quicknode endpoint कुछ ही सेकंड में निर्माण शुरू करें
मुफ़्त में शुरुआत करें