这些天你好,我正在使用.net core 2.2和nethereum库创建一个去中心化的Web api。 现在,我处于紧急状态,因为当我尝试通过nethereum调用具有多个输入和输出参数的智能合约的函数时,发生了以下错误。
处理请求时发生未处理的异常。
NotSupportedException:不支持System.Int32
Nethereum.ABI.Decoders.StringTypeDecoder.Decode(byte []编码,类型 类型)
我在Google上搜索了此内容,但发现的任何文章都无助于我解决此问题。因此,如果有人可以帮助我,我将非常感激。
这是我的智能合约功能
function test(string memory x,uint256 y,bool z) public view returns(string memory _x,uint256 _y,bool _z){
return(x,y,z);
}
这是我使用.net core调用函数的方法
[FunctionOutput]
public class Test : IFunctionOutputDTO
{
[Parameter("string","_x",1)]
private string X { get; set; }
[Parameter("uint256","_y",2)]
private bool Y { get; set; }
[Parameter("bool","_z",3)]
private bool Z { get; set; }
[Function("test")]
public class TestFunction : Functionmessage
{
[Parameter("string","x",1)]
public string X { get; set; }
[Parameter("uint256","y",2)]
public string Y { get; set; }
[Parameter("bool","z",3)]
public bool Z { get; set; }
}
在我的服务范围内,我致电合同
public async Task<Test> Test(TestBody body)
{
var dataset = new TestFunction
{
X = body.x,Y = body.y,Z = body.z
};
var testHandler = web3.Eth.getcontractQueryHandler<TestFunction>();
var response = await testHandler.QueryDeserializingToObjectAsync<Test>(dataset,contractAddress);
return response;
}
在这里 body 只是带有
的请求正文映射类的对象public string x;
public BigInteger y;
public bool z;