I'm trying to create an elrond smart contract that would allow multiple elements to be sent at once to reduce the number of transactions to send the initial information to the contract.
To do so, I'm using an endpoint that takes into an argument a VarArgs of MultiArg3
#[allow(clippy::too_many_arguments)]
#[only_owner]
#[endpoint(createMultipleNft)]
fn create_multipl_nft(
&self,
#[var_args] args: VarArgs<MultiArg3<ManagedBuffer, ManagedBuffer, AttributesStruct<Self::Api>>>,
) ->SCResult<u64> {
...
Ok(0u64)
}
And here is my AttributesStruct
#[derive(TypeAbi, NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub struct AttributesStruct<M: ManagedTypeApi> {
pub value1: ManagedBuffer<M>,
pub value2: ManagedBuffer<M>,
}
And here is my Mandos step (the rest of the steps works fine, they were all working with my previous implementation for a single element endpoint).
{
"step": "scCall",
"txId": "create-multiple-NFT-1",
"tx": {
"from": "address:owner",
"to": "sc:minter",
"function": "createMultipleNft",
"arguments": [
["str:NFT 1"],
["str:www.mycoolnft.com/nft1.jpg"],
[
["str:test1", "str:test2"]
]
],
"gasLimit": "20,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"1", "1", "1"
],
"status": "0",
"message": "",
"gas": "*",
"refund": "*"
}
}
I have also try this for the arguments :
"arguments": [
["str:NFT 1",
"str:www.mycoolnft.com/nft1.jpg",
["str:test1", "str:test2"]
]
And this :
"arguments": [
["str:NFT 1",
"str:www.mycoolnft.com/nft1.jpg",
"str:test1", "str:test2"
]
And this :
"arguments": [
["str:NFT 1",
"str:www.mycoolnft.com/nft1.jpg",
{
"0-value1":"str:test1",
"1-value2":"str:test2"
}
]
Here is the error message :
FAIL: result code mismatch. Tx create-multiple-NFT-1. Want: 0. Have: 4 (user error). Message: argument decode error (args): input too short
At the same time, I'm having some problems with the argument input of the struct with the ManagedBuffer. Am I doing something wrong with that? I'm trying to have a struct of argument for an NFT that contains multiple entries of strings that I can send as an argument to the smart contract.