Created
November 28, 2022 17:55
-
-
Save algochoi/eb7eab3d10d1ece405a251bdfbc4526d to your computer and use it in GitHub Desktop.
Disassemble endpoint Go SDK test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/base64" | |
"fmt" | |
"strings" | |
"github.com/algorand/go-algorand-sdk/client/v2/algod" | |
) | |
var ( | |
kmdAddress = "http://localhost:4002" | |
kmdToken = strings.Repeat("a", 64) | |
algodAddress = "http://localhost:4001" | |
algodToken = strings.Repeat("a", 64) | |
) | |
func main() { | |
// Create an algod client | |
algodClient, err := algod.MakeClient(algodAddress, algodToken) | |
if err != nil { | |
fmt.Printf("failed to make algod client: %s\n", err) | |
return | |
} | |
// Print algod status | |
nodeStatus, err := algodClient.Status().Do(context.Background()) | |
if err != nil { | |
fmt.Printf("error getting algod status: %s\n", err) | |
return | |
} | |
fmt.Printf("algod last round: %d\n", nodeStatus.LastRound) | |
teal := []byte("#pragma version 7\nint 1\nint 1\n+\n") | |
response, _ := algodClient.TealCompile(teal).Do(context.Background()) | |
fmt.Println(response.Result) | |
b, _ := base64.StdEncoding.DecodeString(response.Result) | |
res, _ := algodClient.TealDisassemble(b).Do(context.Background()) | |
fmt.Println(res.Result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment