These are chat archives for Nethereum/Nethereum

16th
Aug 2017
thishe
@thisdhe_twitter
Aug 16 2017 11:45
        string subject = @"中国,China";
        string body = @"中国,China";
        orderNum = @"OrderId";
        object[] functionInput = new object[] { subject, body, orderNum };
        var tx = multiplyFunction.SendTransactionAsync(Account, new HexBigInteger(1000000), new HexBigInteger(30000000), functionInput);
throw exception, public byte[] EncodeParameters(Parameter[] parameters, params object[] values), not support chinese ?
functionInput, EncodeParameters,
thishe
@thisdhe_twitter
Aug 16 2017 11:58
en, first hello,
Juan Blanco
@juanfranblanco
Aug 16 2017 12:43
UTF8
hello :D
so yest the chinese characters are not supported
@thisdhe_twitter ^
Juan Blanco
@juanfranblanco
Aug 16 2017 12:51
you could pass a byte[] if it only for storage
thishe
@thisdhe_twitter
Aug 16 2017 12:51
thanks. but , i think , if it is encoding, it can be fixted. utf8 is supported for chinese char. yes byte[] .
i try
Juan Blanco
@juanfranblanco
Aug 16 2017 12:57
yes they should work in UTF8
was just checking that
can you paste the text ?
so i can test it
Juan Blanco
@juanfranblanco
Aug 16 2017 13:11
it is ok, i created my own contract
thishe
@thisdhe_twitter
Aug 16 2017 13:26
thanks a lot,
thishe
@thisdhe_twitter
Aug 16 2017 14:05

Sol:
function save(string _subject, string _body) payable returns(int256 _result)

interface ,modified:

{
            "constant":false,
  "inputs":[
     {  
        "name":"_subject",
        "type":"bytes"  //string
     },
     {  
        "name":"_body",
        "type":"bytes"  //string
     }
  ],
  "name":"save",
  "outputs":[
     {  
        "name":"_result",
        "type":"int256"
     }
  ],
  "payable":true,
  "type":"function"

}

C# code:
var contract = web3.Eth.GetContract(ContractABI, ContractAddress);
var multiplyFunction = contract.GetFunction("save");

        byte[] sb = new System.Text.UTF8Encoding().GetBytes(subject);
        byte[] bb = new System.Text.UTF8Encoding().GetBytes(body);
        byte[] ob = new System.Text.UTF8Encoding().GetBytes(orderNum);
        object[] functionInput = new object[] { sb, bb, ob };
        var tx = multiplyFunction.SendTransactionAsync(Account, new HexBigInteger(Gas), new HexBigInteger(CallSaveFee), functionInput);
        tx.Wait();

throw Exception:
" 在 Nethereum.ABI.Encoders.IntTypeEncoder.Encode(Object value)\r\n 在 Nethereum.ABI.Encoders.AddressTypeEncoder.Encode(Object value)\r\n 在 Nethereum.ABI.ABIType.Encode(Object value)\r\n 在 Nethereum.ABI.FunctionEncoding.ParametersEncoder.EncodeParameters(Parameter[] parameters, Object[] values)\r\n 在 Nethereum.ABI.FunctionEncoding.FunctionCallEncoder.EncodeRequest(String sha3Signature, Parameter[] parameters, Object[] values)\r\n 在 Nethereum.Web3.Function.GetData(Object[] functionInput)\r\n 在 Nethereum.Web3.Function.SendTransactionAsync(String from, HexBigInteger gas, HexBigInteger value, Object[] functionInput)\r\n 在 GameEthereum.BLL.PersistentWord.Logic.SaveWord2Ethereum(String orderNum, String subject, String body) 位置 C:\TestLogic.cs:行号 104"

Juan Blanco
@juanfranblanco
Aug 16 2017 14:06
ah i see what is wrong
thishe
@thisdhe_twitter
Aug 16 2017 14:06
if contract is string param, only modify client call , it is not work. maybe contact should be modified.
Solidity funciton:
function save(string _subject, string _body) payable returns(int256 _result)
function save(bytes_subject, sbytes _body) payable returns(int256 _result)
Juan Blanco
@juanfranblanco
Aug 16 2017 14:08
you are adding an extra parameter?
thishe
@thisdhe_twitter
Aug 16 2017 14:08
nothing
Juan Blanco
@juanfranblanco
Aug 16 2017 14:08
ordernumber?
thishe
@thisdhe_twitter
Aug 16 2017 14:09
past err.
{
"constant":false,
"inputs":[
{
"name":"_subject",
"type":"bytes"
},
{
"name":"_body",
"type":"bytes"
},
{
"name":"_orderNum",
"type":"bytes"
}
],
"name":"save",
"outputs":[
{
"name":"_result",
"type":"int256"
}
],
"payable":true,
"type":"function"
}
Juan Blanco
@juanfranblanco
Aug 16 2017 14:09
also it is a "params"
you could something like
var tx = multiplyFunction.SendTransactionAsync(Account, new HexBigInteger(Gas), new HexBigInteger(CallSaveFee), subject, body, orderNumber);
you could do*
thishe
@thisdhe_twitter
Aug 16 2017 14:10
no, chinese char
Message = "Character '春' at index '2' is not valid alphanumeric character."
object[] functionInput = new object[] { subject, body, orderNum };
Juan Blanco
@juanfranblanco
Aug 16 2017 14:12
yes im testing that at the moment
Juan Blanco
@juanfranblanco
Aug 16 2017 14:22
no issues encoding
ill check now the decoding