Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ABIDecodeCmd = &cobra.Command{ Use: "decode Contract.abi", Short: "Parse an ABI and print the encoded signatures.", Long: "", RunE: func(cmd *cobra.Command, args []string) error { rawData, err := getInputData(cmd, args) if err != nil { return err } buf := bytes.NewReader(rawData) abi, err := gethabi.JSON(buf) if err != nil { return err } for _, meth := range abi.Methods { fmt.Printf("Selector:%s\tSignature:%s%s\n", hex.EncodeToString(meth.ID), meth.Sig, getReturnSignature(meth.Outputs)) } if *inputData != "" { id, callData, err := parseContractInputData(*inputData) fmt.Printf("id: %x, %x\n", id, callData) if err != nil { return err } meth, err := abi.MethodById(id) if err != nil { return err } if meth == nil { return fmt.Errorf("the function selector %s wasn't matched in the given abi", hex.EncodeToString(id)) } inputVals := make(map[string]any, 0) err = meth.Inputs.UnpackIntoMap(inputVals, callData) if err != nil { return err } fmt.Println("Input data:") prettyInput, _ := json.MarshalIndent(inputVals, "", " ") fmt.Println(string(prettyInput)) unpackedCallData, err := meth.Inputs.UnpackValues(callData) if err != nil { return err } fmt.Println("Signature and Input") fmt.Printf("%s%s", meth.Sig, getReturnSignature(meth.Outputs)) for _, unpackedCallDataArg := range unpackedCallData { fmt.Printf(" %v", unpackedCallDataArg) } fmt.Println() } return nil }, Args: func(cmd *cobra.Command, args []string) error { return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.