These are chat archives for Nethereum/Nethereum

22nd
Aug 2017
David Burela
@DavidBurela
Aug 22 2017 02:08

Using Nethereum for the first time. having a REALLY hard time getting started. Read the Github readme, looked through https://nethereum.readthedocs.io
All I'm trying to do to start off is call web3.eth.accounts or web3.eth.currentBlock
But in Nethereum those aren't methods (and .currentBlock doesn't exist). Can't figure out how to trigger them.

So there must be a way you need to package them up to tell Nethereum to execute...

Been taking a lot of notes on my getting started experience. It isn't a simple switch from using web3.js directly, to jumping over to use Nethereum
David Burela
@DavidBurela
Aug 22 2017 02:17
Downloaded a couple sample apps, managed to find it web3.Eth.Accounts.SendRequestAsync()
But the getting started guide needs some updating. I'll send notes through later
thishe
@thisdhe_twitter
Aug 22 2017 03:40
https://etherscan.io/address/0x670eafb71578c1ccfc610cb940e1db572818c8b7, i call this contract, it is error:can call ,but "Warning! Error encountered during contract execution [Out of gas] ", such as https://etherscan.io/tx/0xc2e202fdcda6b56edbb583ae52a58b6ed1dd0aebea6fb39f156a95d3d6683aa3
    public async void TestMyChinese(int gas, string subject, string body)
    {
        var web3 = new Web3(ClientFactory.GetClient());
        var result = web3.Personal.UnlockAccount.SendRequestAsync(Account, Password, 60);
        result.Wait();
        if (!result.Result)
        {
            return;
        }

        var pollingService = new TransactionReceiptPollingService(web3);
        var coinService = new Nethereum.Web3.Tests.Issues. EventAddressIntString.CoinService(web3, ContractAddress);

        var input = new Nethereum.Web3.Tests.Issues.EventAddressIntString.SaveInput()
        {
            _subject = subject,
            _body = body,
            _orderNum = "*"
        };

        var txn = await coinService.RaiseEventMetadataAsync(Account,  input, new HexBigInteger(gas), new HexBigInteger(CallSaveFee));
        var receipt = await pollingService.PollForReceiptAsync(txn);
        string s = receipt.TransactionHash;

        System.Console.WriteLine(s);
    }
    //[Function(Name = "save")]
    //public class SaveInput
    //{
    //    [Parameter("string", "_subject", 1, false)]
    //    public string _subject { get; set; }

    //    [Parameter("string", "_body", 2, false)]
    //    public string _body { get; set; }

    //    [Parameter("string", "_orderNum", 3, false)]
    //    public string _orderNum { get; set; }


    //}
[{"constant":true,"inputs":[],"name":"index","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"userRefund","outputs":[{"name":"_result","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"int256"}],"name":"userDataOf","outputs":[{"name":"userAddr","type":"address"},{"name":"subject","type":"string"},{"name":"body","type":"string"},{"name":"createTime","type":"uint256"},{"name":"amount","type":"uint256"},{"name":"orderNumSha3","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"subjectMaxLen","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"int256"}],"name":"getUserData","outputs":[{"name":"_subject","type":"string"},{"name":"_body","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_subject","type":"string"},{"name":"_body","type":"string"},{"name":"_orderNum","type":"string"}],"name":"save","outputs":[{"name":"_result","type":"int256"}],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"bodyMaxLen","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newPrice","type":"uint256"}],"name":"setPrice","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_subject","type":"string"},{"name":"_body","type":"string"}],"name":"save","outputs":[{"name":"_result","type":"int256"}],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_subject","type":"string"},{"name":"_body","type":"string"},{"name":"_orderNum","type":"string"}],"name":"save","outputs":[{"name":"_result","type":"int256"}],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"price","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"coder","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newBodyMaxLen","type":"uint256"}],"name":"setBodyMaxLen","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"userRefund","outputs":[{"name":"_result","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newSubjectMaxLen","type":"uint256"}],"name":"setSubjectMaxLen","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newCoder","type":"address"}],"name":"transferCodership","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"int256"}],"name":"deleteUD","outputs":[{"name":"_result","type":"bool"}],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"}]
so, please look , and thanks.
David Burela
@DavidBurela
Aug 22 2017 04:49
another oddity
var currentBlock = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();
var blockDetails1 = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(currentBlock); // works
var blockDetails2 = await web3.Eth.Blocks.GetBlockTransactionCountByNumber.SendRequestAsync(currentBlock); // runtime exception
Juan Blanco
@juanfranblanco
Aug 22 2017 07:33
@DavidBurela yes the docs are being updated at the moment. Feel free to push anything you want. Check the videos to get started. All RPC methods are based on the core RPC, not web3js.
David Burela
@DavidBurela
Aug 22 2017 07:34
:thumbsup: yeah I'm taking down notes to make sure that I can help improve the onboarding process later :)
Juan Blanco
@juanfranblanco
Aug 22 2017 07:36
Awesome, it will be great to see your perspective :)
Juan Blanco
@juanfranblanco
Aug 22 2017 07:44
@DavidBurela and yes those block numbers need some overloads, hexbiginteger or blockparameter
David Burela
@DavidBurela
Aug 22 2017 07:50
Once you get past that initial bump, works well. Within 4 hours managed to build a UWP app that grabs the last 5 blocks, and charts the gas used. Nethereum works well
image.png
Juan Blanco
@juanfranblanco
Aug 22 2017 07:51
Nice!!
Check Nethereum
Blockstorage
Also let me know how you get on with keystore, account and contracts
(if you fancy it ) :)
Juan Blanco
@juanfranblanco
Aug 22 2017 07:56
It will be great feedback
Juan Blanco
@juanfranblanco
Aug 22 2017 08:14
@thisdhe_twitter can you post your contract?
Juan Blanco
@juanfranblanco
Aug 22 2017 09:01
@kaista82_twitter cool you got it solved. I think function DTOs might be a good pattern (eventually) for a big code base to avoid those issues. Too much implied information with order of parameters
Thanks btw, half way through on the road trip.
kai
@kaista82_twitter
Aug 22 2017 09:02
yeah, that would be a good idea with the DTO's, you could map them like your event objects with attributes, dynamic's may also work I'm not sure
oh still ont he road trip, awesome, i hope you're enjoying it
Juan Blanco
@juanfranblanco
Aug 22 2017 09:04
Have to think about dynamics
kai
@kaista82_twitter
Aug 22 2017 09:04
yeah I'm totally not sure, but its a single parameter then
purely thinking out loud
thishe
@thisdhe_twitter
Aug 22 2017 11:34

pragma solidity ^0.4.11;

contract PersistentWord {

address public owner;

address public coder =  0xaDA9C28ebF0D37d3E4966E67Ec3340A984A8d93F;

function PersistentWord() {
    owner = msg.sender;
}

modifier onlyOwner {
    require (msg.sender == owner);
    _;
}

 modifier onlyCoder {
    require (msg.sender == coder);
    _;
}

function transferOwnership(address _newOwner) onlyOwner {
    owner = _newOwner;
}

function transferCodership(address _newCoder) onlyCoder {
    coder = _newCoder;
}    

function () payable 
{
    balanceOf[msg.sender] += msg.value;
}

uint256 public price = 0.005 ether;

function setPrice(uint256 _newPrice) onlyOwner{
    price = _newPrice;
}

uint256 private constant deletePrice = 10 ether;

uint public subjectMaxLen = 64;
function setSubjectMaxLen(uint256 _newSubjectMaxLen) onlyOwner{
    subjectMaxLen = _newSubjectMaxLen;
}

uint public bodyMaxLen = 512;
function setBodyMaxLen(uint256 _newBodyMaxLen) onlyOwner{
    bodyMaxLen = _newBodyMaxLen;
}

mapping (int256 => UserData) public userDataOf;  
mapping (address => uint256) public balanceOf;    

int256 public index = 0;    

struct   UserData{
    //int256 indexNo;  
    address userAddr;       
    string subject; 
    string body;
    uint256 createTime;
    uint256 amount; 
    bytes32 orderNumSha3;   
    //bool isDeleted;
}

function getUserData(int256 _index) returns (string _subject, string _body){
    if (_index < index){
        var ud = userDataOf[_index];
        _subject = ud.subject;
        _body = ud.body;
        return;
    }
    else
    {
        _subject = "";
        _body = "";
        return;
    }
}

function deleteUD(int256 _index) payable returns (bool _result){
      balanceOf[msg.sender] += msg.value;
      var ud = userDataOf[_index];
      if(_index < index && ud.userAddr == msg.sender &&  balanceOf[msg.sender] > deletePrice)
      {
            var emptyUd = UserData({
                userAddr: msg.sender,
                subject: "",
                body : "",
                createTime: now,
                amount:deletePrice,
                orderNumSha3: ""
            });

           userDataOf[_index] = emptyUd;    

           balanceOf[msg.sender] -= deletePrice;
           balanceOf[coder] += deletePrice * 50 / 100; 
           balanceOf[owner] += deletePrice * 50 / 100;
           return true;         
      }
      return false;
}

function save(string _subject, string _body) payable returns (int256 _result)
{
    address _user = msg.sender;
    return save(_user,   _subject, _body,  "");
}

function save(string _subject, string _body, string _orderNum) payable returns (int256 _result)
{
    address _user = msg.sender;
    return save(_user,   _subject, _body, _orderNum);
}

function save(address _user,   string _subject, string _body, string _orderNum) payable returns (int256 _result)
{
    _result = 0;
    balanceOf[_user] += msg.value;

    //UTF-8 是变长的,1-6个字节,少数是汉字每个占用3个字节,多数占用4个字节。
    if (bytes(_subject).length > subjectMaxLen  * 4 || bytes(_body).length > bodyMaxLen * 4)
    {
        return -1;   
    }

    if(balanceOf[_user] >= price)
    {
        bytes32 on = sha3(_orderNum);

        var ud = UserData({
            userAddr: _user,
            subject: _subject,
            body : _body,
            createTime: now,
            amount:price,
            orderNumSha3: on
        });

        userDataOf[index] = ud;
         _result = index;
        index++;

        balanceOf[_user] -=  price;
        balanceOf[coder] += price * 5 / 100; 
        b

balanceOf[coder] += price 5 / 100;
balanceOf[owner] += price
95 / 100;
return;
}
else
{
return -2;
}
}

function userRefund() returns(bool _result) {
    return userRefund(msg.sender);
}

function userRefund(address _to) returns(bool _result){
    uint256 amount = balanceOf[_to];    //bug!!!  uint256 amount = balanceOf[msg.sender];
    if(amount>0){
        balanceOf[msg.sender] = 0;
        _to.transfer(amount); 
        return true;
    }
    return false;
}

}

Over the longest
twice
thishe
@thisdhe_twitter
Aug 22 2017 12:19
i guess : “data” has some wrong
Juan Blanco
@juanfranblanco
Aug 22 2017 13:11
@kaista82_twitter dynamic types are not supported with aot on iOS and future web assembly. Btw the initial mono + webassembly has been released.
kai
@kaista82_twitter
Aug 22 2017 13:12
what was mono + webassembly for again html based UI?
ahh gutted about dynamic would have been great
maybe tuple?
i just like params[] though
its so smooth
but if that first param is matching the last actual param for he method signature boom you get what i got
Juan Blanco
@juanfranblanco
Aug 22 2017 13:14
Yeah removed all dynamic stuff for iOS
kai
@kaista82_twitter
Aug 22 2017 13:15
that's a real shame
Juan Blanco
@juanfranblanco
Aug 22 2017 13:15
Yep luckily most of the types are hexbiginteger
(normally)
Yep wasm / mono is to make "compiled" programs for the web
kai
@kaista82_twitter
Aug 22 2017 13:17
erm
mvc is compiled web app
whats the difference
maybe i can find this somewhere to read
Juan Blanco
@juanfranblanco
Aug 22 2017 13:18
Unity is moving webgl to webassembly
kai
@kaista82_twitter
Aug 22 2017 13:18
OH
so you get web based desktop style apps
gpu usage etc
direct x
open gl
so not stateless?
i will read
Juan Blanco
@juanfranblanco
Aug 22 2017 13:18
No
kai
@kaista82_twitter
Aug 22 2017 13:18
rather than ask lots of questions lol
watching...
Juan Blanco
@juanfranblanco
Aug 22 2017 13:19
Ok :)
kai
@kaista82_twitter
Aug 22 2017 13:20
oh so c# version of javascript on steroids is what im seeing so far... i will continue to atch
kai
@kaista82_twitter
Aug 22 2017 13:25
ok not quite that but exciting, i will watch some vids
Juan Blanco
@juanfranblanco
Aug 22 2017 13:26
Yep mainly that, or even JavaScript, c++, ... Version of JavaScript on steroids
kai
@kaista82_twitter
Aug 22 2017 13:26
yeah its assembly for the web, clues in the name I'm getting it, still though makes the .net IL -> runtime situation so powerful
with this and all the mono stuff etc etc
really is getting good
Juan Blanco
@juanfranblanco
Aug 22 2017 13:27
Yep exactly
.net has already the IL and many supported languages. It might become a subset of netstandard
kai
@kaista82_twitter
Aug 22 2017 13:29
may I ask you
.net core and standard
i thought standard was a "standard" i.e. we promise to implement these things
so what is core
i know its web mainly and console for cross platform
but i saw core as similar to say mvc
where as standard is someone saying my implentation has all of the above features required to be called .net standard
Hanselman has created an awesome reference
kai
@kaista82_twitter
Aug 22 2017 13:33
.net standard is a promise of functionality which the runtimes should implement and core is a runtime
i thought core would be killed by standard you see
in time
but I must have been wrong
kai
@kaista82_twitter
Aug 22 2017 13:42
anyway webassembly then, sandboxed compiled client side apps on steroids that browsers will run in a nice secure environment but give access to the metal and other areas of the os
sounds amazing
I will keep watching
Juan Blanco
@juanfranblanco
Aug 22 2017 13:44
Yes lot of confusion about netstandard / core
Also xamlstandard is coming now
kai
@kaista82_twitter
Aug 22 2017 13:46
xamlstandard i kind of understand
for forms 3
and core i get, its just cut down version of .net without the bells and whistles so its easily implemented on different platforms
or xf2 (i think its 2 not 3)
Juan Blanco
@juanfranblanco
Aug 22 2017 13:47
Yep and different types of aligned netstandards to support different runtimes and platforms
kai
@kaista82_twitter
Aug 22 2017 13:48
yeah then it dont matter if mono or whatever as long as its covering the promise of a .net standard its all good
Juan Blanco
@juanfranblanco
Aug 22 2017 13:48
Yes 3 is coming
kai
@kaista82_twitter
Aug 22 2017 13:48
yeah so excited man
Juan Blanco
@juanfranblanco
Aug 22 2017 13:50
Yes great times, it got a bit messy over the years
But great lesson learnt
kai
@kaista82_twitter
Aug 22 2017 14:07
webassembly is what flash should have been hehe
i need to watch how the ui is done in webassembly or if its directx / open gl etc but thanks for letting me know about these advances
gets me reading!
kai
@kaista82_twitter
Aug 22 2017 14:45
wtf you can push .net core into your browser
wow
Alexander Yarushin
@aayarushin
Aug 22 2017 20:37
Hei guys!
Please somebody help. Have beeen sittting for hours do not understand what causes the error:
this is where the error is described
kai
@kaista82_twitter
Aug 22 2017 21:59
Do other tests suceed that use rpc?