ABI字符串不工作



我正在编写一个程序,该程序使用c#获取以太坊合约ABI字符串,并使用它调用一个函数,该函数允许我使用以太坊与智能合约进行交互。当我使用一个较小的ABI字符串时,我能够使它工作,但由于某种原因,它不能与这个较长的字符串或任何其他超过小示例ABI长度的ABI一起工作。当我编译下面的代码时,我得到错误消息(请记住,我已经尝试过JSON反序列化,但仍然会产生相同的错误):

类型为'Newtonsoft.Json '的异常。在Newtonsoft.Json.dll中发生了JsonReaderException,但未在用户代码中处理

附加信息:解析值后遇到意外字符:t. Path '[0].outputs[0].name',第3行,位置20.

protected void init()
{
    web3 = new Nethereum.Web3.Web3();
    string abi = @"[{'constant':false,'inputs':[{'name':'username','type':'string'},
    {'name':'location','type':'string'}],'name':'addUser','outputs':
    [{'name':','type':'string'}],'type':'function'},{'constant':false,'inputs'
    :[],'name':'burnCoins','outputs':[{'name':','type':'uint256'}],'type':'function'},
    {'constant':false,'inputs':[{'name':'vendor','type':'address'},
    {'name':'recipient','type':'address'}],'name':'trade','outputs':[],
    'type':'function'},{'constant':false,'inputs':[{'name':'vendor','type':'address'},
    {'name':'isPositive','type':'bool'},{'name':'message','type':'string'}],
    'name':'giveReputation','outputs':[],'type':'function'},{'constant':false,'inputs':
    [{'name':'user','type':'address'}],'name':'showBurnedCoins','outputs':[{'name':
    ','type':'uint256'}],'type':'function'},{'constant':false,'inputs':[{'name':'user',
    'type':'address'}],'name':'viewReputation','outputs':[{'name':','type':'uint256'},
    {'name':','type':'uint256'},{'name':','type':'uint256'}],'type':'function'},
    {'anonymous':false,'inputs':[{'indexed':true,'name':'user','type':'address'},
    {'indexed':true,'name':'amountBurned','type':'uint256'}],'name':'_coinsBurned',
    'type':'event'},{'anonymous':false,'inputs':[{'indexed':true,'name':'user',
    'type':'address'},{'indexed':true,'name':'message','type':'string'}],'
    name':'_positiveReputation','type':'event'},{'anonymous':false,'inputs'
    :[{'indexed':true,'name':'user','type':'address'},{'indexed':true,'name':'message'
    ,'type':'string'}],'name':'_negativeReputation','type':'event'},
    {'anonymous':false,'inputs':[{'indexed':true,'name':'username','type':'string'},
    {'indexed':true,'name':'location','type':'string'},{'indexed':true,'name':
    'user','type':'address'}],'name':'_addUser','type':'event'},{'anonymous':false,
    'inputs':[{'indexed':true,'name':'vendor','type':'address'},{'indexed':true,
    'name':'buyer','type':'address'}],'name':'_newTrade','type':'event'},{'anonymous':
    false,'inputs':[{'indexed':true,'name':'user','type':'address'},{'indexed':true,
    'name':'positive','type':'uint256'},{'indexed':true,'name':'negative','type':'uint256'},
    {'indexed':false,'name':'total','type':'uint256'}],'name':'_viewedReputation',
    'type':'event'}]";
    string contractAddress = "0xd53c3dc2f3fcf1779b68ea8e441d857b4af5a413";
    Reputation = web3.Eth.GetContract(abi, contractAddress);
}

From my comment:

错误是由于'name':'showBurnedCouns', 'outputs':[{'name':','type':'uint256'}]行。输出块中缺少'

请参阅diiN_评论我的问题,因为这回答了问题。愚蠢的我!

最新更新