How to properly pass params in go sdk ? #683
-
Discord user IDNo response Describe your question in detail.I have a view function that requires one input parameter
Essentially params is an array of hex values. address := &aptos.AccountAddress{}
err = address.ParseStringRelaxed("MY_CONTRACT_ADDRESS")
param := "d6bf000332000"
decodedBytes, err := hex.DecodeString(param)
viewResponse, err := client.View(&aptos.ViewPayload{
Module: aptos.ModuleId{Address: *address, Name: "MODULE_NAME"},
Function: "get_result",
ArgTypes: []aptos.TypeTag{},
Args: [][]byte{decodedBytes},
}) I convert the hex string into bytes and provide it as Args, however getting I also tried with direct RPC calls, and it works curl --request POST \
--url https://api.testnet.aptoslabs.com/v1/view\
--header 'Content-Type: application/json' \
--data '{
"function": "MY_CONTRACT_ADDRESS::MODULE_NAME::get_result",
"type_arguments": [
],
"arguments": [["0xd6bf000332000"]]
}' What error, if any, are you getting?Failed to execute function: VMError { major_status: ABORTED What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?macOS Which SDK or tool are you using? (if any)N/A Describe your environment or tooling in detailaptos-go-sdk v1.5.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Resolved. For vector<vector> I needed the length of full items and length of each individual vector in the bytes. |
Beta Was this translation helpful? Give feedback.
Resolved. For vector<vector> I needed the length of full items and length of each individual vector in the bytes.
For example
d6bf000332000
gets encoded to[214 191 0 3 50 0]
but the function required[1 6 214 191 0 3 50 0]
. The first byte being the length of items and second actual length of paras