I am writing a program which takes an ethereum contract ABI string in C# and uses it to call a function which allows me to interact with the smart contract using nethereum. When I use a smaller ABI string I am able to make it work but for some reason it won't work with this longer string or any other ABI which exceeds the length of a small example ABI. When I compile the code below I get the error message ( bare in mind that I have tried JSON deserializing but that still makes the same error) :
An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: After parsing a value an unexpected character was encountered: t. Path '[0].outputs[0].name', line 3, position 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:
The error is because of the line 'name':'showBurnedCouns', 'outputs':[{'name':','type':'uint256'}]
. A '
is missing inside the outputs block.
See diiN_ comment on my question as this answers the question. Silly me!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.