aptos-core
aptos-core copied to clipboard
Failed to send script payload tranasction with vector<T> parameter
❓ Questions and Help
Please note that this issue tracker is not a help form and this issue will be closed.
Please contact the development team on Discord
Hey all, I tried to send a script payload transaction with parameter type like vector<String>
or vector<address>
but failed.
Here is my transaction in devnet: https://explorer.aptoslabs.com/txn/0xfd72d4243815bcadcf7b15871e752aaa9dd3aa9d713b3cfce421d588d6339d87
As we can see, the script needs "vector<0x1::string::String>"
as param, I bring "0x0201610162"
as argument (the actual value I want is ["a","b"]
). But it raised error Transaction Executed and Committed with Error FAILED_TO_DESERIALIZE_ARGUMENT
.
I wonder if it's possible to send vector<T>
as parameter for script payload transaction? Is there any examples in Rust or other sdk? For example, if I want to submit a script payload transaction to call 0x3::token::create_token_script
, how to pass the required vector<String>
param by client ?
Discord link: https://discord.com/channels/945856774056083548/946123778793029683/1035104379419758602
@davidiw please advice when you have time. Thanks :)
Unfortunately the existing script API is extremely limited. You'll notice that it only accepts TransactionArgument types. The Python code demonstrates this: https://github.com/aptos-labs/aptos-core/blob/b7d6e5eb7b3992eb30ad0eed442b1b57317960ff/ecosystem/python/sdk/aptos_sdk/transactions.py#L241
We could expand and support additional types, but that would require versioning this API ... e.g., ScriptV2 where we remove this TransactionArgument / ScriptArgument construct and rely on decoding the script functions interface...
@davidiw Thank you for your reply! I also have a further question. I have seen module 0x1::from_bcs
which can help to convert value in std::bcs
to basic types. Is there any module supported to deserialize byte array to vector<T> or read ULEB128 in Move?
Unfortunately not at this point in time. We definitely would benefit from some form of program assisted deserialization in Move. Let me bring it up with the team.
OK, thanks for your help and reply!
gonna close this out and note that we need to track a ScriptV2 that eliminates these arbitrary restrictions.