These are chat archives for Nethereum/Nethereum

7th
Oct 2018
Culé
@ngocketit_twitter
Oct 07 2018 10:19
Does anyone know how to call contract function that returns multiple values? This doesn't seem to work: var tokenId = await tokenOfOwnerByIndex.CallAsync<object[]>(activeAddress, index);
Culé
@ngocketit_twitter
Oct 07 2018 10:50
No worry, I figured it out with CallDeserializingToObjectAsync
Juan Blanco
@juanfranblanco
Oct 07 2018 10:50
that is the one :)
if you are using unityrequests
Culé
@ngocketit_twitter
Oct 07 2018 10:51
Thanks to this video https://www.youtube.com/watch?v=o8UC96K0rg8&feature=youtu.be @juanfranblanco ! Thanks a lot!
for unity classic
Thanks @ngocketit_twitter need to make other videos when 3.0 is out
:)
@TarrahArshad you can use Eth.GasPrice
or you can put your own
@spied001 if you are working on your own private chain you should not have any security problem as such, there won't be any one doing a ddos
Culé
@ngocketit_twitter
Oct 07 2018 10:54
Awesome :)
Juan Blanco
@juanfranblanco
Oct 07 2018 10:55
so I would not worry too much
@spied001 so obviously you are reaching limits there
you could try spinning more clients and targeting all of them
but yet again you will have the limits of how many transactions you can put in a block
Culé
@ngocketit_twitter
Oct 07 2018 11:44
@juanfranblanco Should I use HexBigInteger or C# BigInteger to represent a ERC721 token ID? What's the differences between them?
Juan Blanco
@juanfranblanco
Oct 07 2018 11:48
hexbiginteger is used for rpc
so that in a contract use the latter
Culé
@ngocketit_twitter
Oct 07 2018 11:49
Gracias!
Juan Blanco
@juanfranblanco
Oct 07 2018 11:50
De nada !!! :D
Culé
@ngocketit_twitter
Oct 07 2018 11:55
My Unity is going crazy. I imported System.Numerics and use BigInteger and now it's complaining that: error CS0433: The imported typeSystem.Numerics.BigInteger' is defined multiple times`
Culé
@ngocketit_twitter
Oct 07 2018 12:03
Ok, I removed System.Numerics DLL and it works :)
Juan Blanco
@juanfranblanco
Oct 07 2018 12:04
yeah in .net351 i have created our own BigInteger
"created" is mainly a mixture implementation of mono / .net core
Culé
@ngocketit_twitter
Oct 07 2018 12:05
I'm using .net461 so I guess that's not needed
Juan Blanco
@juanfranblanco
Oct 07 2018 12:06
yeah it will use then the .net one already
Culé
@ngocketit_twitter
Oct 07 2018 12:40
Do you know what could be wrong with this code? var gas = await makeBidFunc.EstimateGasAsync(tokenId, priceWei); var receiptFirstAmountSend = await makeBidFunc.SendTransactionAndWaitForReceiptAsync(sender, gas, priceWei, null, tokenId);
I got: Error CS1503: Argument 2: cannot convert from 'Nethereum.Hex.HexTypes.HexBigInteger' to 'System.Threading.CancellationTokenSource' in the SendTransactionAndWaitForReceiptAsync() function call
Though the signature seems to be correct
Juan Blanco
@juanfranblanco
Oct 07 2018 12:41
yes you are mainly adding too many parameters
hence the new typed way is preferred
check this sample
it gets rather complex with all the parameter order etc
your issue is that is picking a different overload
Culé
@ngocketit_twitter
Oct 07 2018 12:46
but I don't see any overload that takes 5 parameters and CancellationTokenSource as the second param
so the one I used is this: public Task SendTransactionAndWaitForReceiptAsync (string from, HexBigInteger gas, HexBigInteger value, CancellationTokenSource receiptRequestCancellationToken = default(CancellationTokenSource), params object[] functionInput);
Juan Blanco
@juanfranblanco
Oct 07 2018 13:01
what type is TokenId?
Culé
@ngocketit_twitter
Oct 07 2018 13:01
It's BigInteger
Juan Blanco
@juanfranblanco
Oct 07 2018 13:02
and gas, priceWei HexBigIntegers?
Culé
@ngocketit_twitter
Oct 07 2018 13:03
oh, maybe that's the problem. I think I haven't converted the priceWei to HexBigInteger
btw, I'm converting the code to the new way you mentioned above
so in 3.0.0-rc1, the GetContractTransactionHandler expects a param of type TContractFunctionMessage right?
Juan Blanco
@juanfranblanco
Oct 07 2018 13:04
you can use vscode to code generate your service and function messages, deployment etc
Culé
@ngocketit_twitter
Oct 07 2018 13:04
the normal FunctionMessage doesn't seem to work
Juan Blanco
@juanfranblanco
Oct 07 2018 13:05
yes to get a TransactionHandler you will the FunctionMessage
the pattern used for Code generation is to use inheritance and partials so you can extend it without worrying about code gen
although the idea is that you should not need either code gen (if not wanted) but saves on the typing :)
Culé
@ngocketit_twitter
Oct 07 2018 13:07
Screen Shot 2018-10-07 at 16.07.03.png
I got error. It seems to expect a TContractFunctionMessage
Juan Blanco
@juanfranblanco
Oct 07 2018 13:08
yeah MakeBidFunction needs to inherit from FunctioMessage
Culé
@ngocketit_twitter
Oct 07 2018 13:08
Screen Shot 2018-10-07 at 16.08.20.png
Juan Blanco
@juanfranblanco
Oct 07 2018 13:08
so you will have something like
Culé
@ngocketit_twitter
Oct 07 2018 13:08
Sorry, I fixed that but now got a new error
Here is the MakeBidFunction: [Function("makeBid")] private class MakeBidFunction : FunctionMessage { [Parameter("uint256", "_tokenId", 1)] public BigInteger TokenId { get; set; } }
Juan Blanco
@juanfranblanco
Oct 07 2018 13:09
yes you dont need to await that
yeah that is cool
Culé
@ngocketit_twitter
Oct 07 2018 13:09
oh yeah, many thanks for that :)
I must be mad as I've been coding for a day now :(
Juan Blanco
@juanfranblanco
Oct 07 2018 13:10
oh i know the feeling
Culé
@ngocketit_twitter
Oct 07 2018 13:11
Thanks! And sorry that I've been bothering you at the weekend
Juan Blanco
@juanfranblanco
Oct 07 2018 13:11
ah don't worry
Culé
@ngocketit_twitter
Oct 07 2018 13:11
We have a hackathon and this's gonna our company first game on blockchain ever, so :D
Juan Blanco
@juanfranblanco
Oct 07 2018 13:12
btw starting the other way you mainly get an understanding of the encoding / decoding also you go the idea of the different types for rpc etc.. so it is all good :)
nice !!!
if you look at FunctionMessage
that includes the Gas
Culé
@ngocketit_twitter
Oct 07 2018 13:13
yeah
Juan Blanco
@juanfranblanco
Oct 07 2018 13:13
GasPrice, FromAccount, AmountToSend
Culé
@ngocketit_twitter
Oct 07 2018 13:13
and the msg.value in Solidity is the AmountToSend I guess?
Juan Blanco
@juanfranblanco
Oct 07 2018 13:13
yes correct
Culé
@ngocketit_twitter
Oct 07 2018 13:13
cool
Juan Blanco
@juanfranblanco
Oct 07 2018 13:13
there was so much confusion with Value so i made it a bit implicit
Culé
@ngocketit_twitter
Oct 07 2018 13:27
So I think I got it to work. Here is the code:
    public async Task<bool> BuyToken(BigInteger tokenId, decimal price) {
        var contract = GetAuctionContract();
        var makeBidFunc = contract.GetFunction("makeBid");
        var priceWei = Web3.Convert.ToWei(price);
        var sender = wallet.ActiveAccount.Address;
        var makeBidHandler = web3.Eth.GetContractTransactionHandler<MakeBidFunction>();

        var makeBidMessage = new MakeBidFunction
        {
            TokenId = tokenId,
            FromAddress = sender,
            AmountToSend = priceWei,
            GasPrice = Web3.Convert.ToWei(25, UnitConversion.EthUnit.Gwei)
        };

        Debug.Log("Sender:" + sender);

        var gas = await makeBidHandler.EstimateGasAsync(contract.Address, makeBidMessage);
        makeBidMessage.Gas = gas;

        var makeBidReceipt = await makeBidHandler.SendRequestAndWaitForReceiptAsync(contract.Address, makeBidMessage);
        Debug.Log("Receipt:" + makeBidReceipt);
        return true;
    }
I'm using the HD wallet. I guess I don't have to provide private key and sign transaction, right? Does SendRequestAndWaitForReceiptAsync handles that automatically?
Juan Blanco
@juanfranblanco
Oct 07 2018 14:07
for the hd wallet you need to something as this
Culé
@ngocketit_twitter
Oct 07 2018 14:28
Thanks! I'll check that.