cnyskl815
2 months ago  Karma: 17
With Loom Unity SDK(EVM-based contract), How to get multiple output?

In the docs there is a part Reading data from a DAppChain tells that the EvmContract.StaticCall...Async() family of methods can read data, and I tried to use CallDtoTypeOutputAsync() to get multiple output, but failed.

Codes here:
contract:


function TestStore2(uint key) public view returns(uint, string) { ... }

*Unity: *

```
public async Task TestStore2()
{
await ConnectToContract();
MultiOutputData _mod = await this.contract.CallDtoTypeOutputAsync("TestStore2", ...inputdata...);
...
}

public class MultiOutputData
{
[Parameter("int", "id", 1)]
public int ID { get; set; }

[Parameter("string", "des", 2)]
public string DES { get; set; }
}
```

and I got an error :
ArgumentException: Generic Type should have a Function Ouput Attribute
Loom.Nethereum.ABI.FunctionEncoding.FunctionCallDecoder.DecodeFunctionOutputT (at :0)
......

Maybe I could get some help here, thank you guys.

en
#Unity
#loom-sdk
cnyskl815
2 months ago  Karma: 17
With Loom Unity SDK(EVM-based contract), How to get multiple output?

In the docs there is a part Reading data from a DAppChain tells that the EvmContract.StaticCall...Async() family of methods can read data, and I tried to use CallDtoTypeOutputAsync() to get multiple output, but failed.

Codes here:
contract:


function TestStore2(uint key) public view returns(uint, string) { ... }

*Unity: *

```
public async Task TestStore2()
{
await ConnectToContract();
MultiOutputData _mod = await this.contract.CallDtoTypeOutputAsync("TestStore2", ...inputdata...);
...
}

public class MultiOutputData
{
[Parameter("int", "id", 1)]
public int ID { get; set; }

[Parameter("string", "des", 2)]
public string DES { get; set; }
}
```

and I got an error :
ArgumentException: Generic Type should have a Function Ouput Attribute
Loom.Nethereum.ABI.FunctionEncoding.FunctionCallDecoder.DecodeFunctionOutputT (at :0)
......

Maybe I could get some help here, thank you guys.

en
#Unity
#loom-sdk

ONE ANSWER
cnyskl815
2 months ago Karma: 17

Finally I get it! It need the following code before the MultiOutputData class, hope that can help you.

[FunctionOutput]

Finally I get it! It need the following code before the MultiOutputData class, hope that can help you.

[FunctionOutput]

Earn tokens by posting and answering questions about blockchain!
Karma to eth
YOUR ANSWER