These are chat archives for Nethereum/Nethereum

8th
Jul 2018
Juan Blanco
@juanfranblanco
Jul 08 2018 05:43
ah yeah @EstebanGameDevelopment I deployed that contract before
also note all the code is 3.5 compatible
if you use 4.x out of box Nethereum works
so here are more examples
for 3.5 you can use this...
so now it will be very self containted
these classes can be autogenerated
(the message / contractdeployment / functions)
revinfotech2
@revinfotech2
Jul 08 2018 06:28
@juanfranblanco I got this when I transfer the token from the owner to address "intrinsic gas too low"
Juan Blanco
@juanfranblanco
Jul 08 2018 06:29
you need to add more gas
what does your code look like? what is your current environment (ie chain)
revinfotech2
@revinfotech2
Jul 08 2018 06:30
I am connected to ropsten
Juan Blanco
@juanfranblanco
Jul 08 2018 06:31
snippet of the code?
revinfotech2
@revinfotech2
Jul 08 2018 06:31
Sure
here is a sample
revinfotech2
@revinfotech2
Jul 08 2018 06:32
var transactionMessage = new TransferFunction()
{
FromAddress = AdminAddress,
To = toAddress,
AmountToSend = new BigInteger(Amount),
Value = new BigInteger(Amount)
};
            var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();

       // this is done automatically so is not needed.
            var estimate = transferHandler.EstimateGasAsync(transactionMessage, ContractAddress).GetAwaiter().GetResult();
            transactionMessage.Gas = new BigInteger(gasEstimate.result);


            var transactionHash = transferHandler.SendRequestAsync(transactionMessage, ContractAddress).GetAwaiter().GetResult();
Juan Blanco
@juanfranblanco
Jul 08 2018 06:32
ah well :)
revinfotech2
@revinfotech2
Jul 08 2018 06:32
I am taking the reference from the same
Juan Blanco
@juanfranblanco
Jul 08 2018 06:32
are you using a console app?
not releated
but you can do this..
or mark it as async from 7.1 c#
revinfotech2
@revinfotech2
Jul 08 2018 06:34
Does GetAwaiter().GetResult() not work
Juan Blanco
@juanfranblanco
Jul 08 2018 06:35
yes it does but it saves you typing ;)
(passing thought)
ok let me try it in ropsten
damn the nethereum account is empty
revinfotech2
@revinfotech2
Jul 08 2018 06:40
Now I got this
"gas required exceeds allowance or always failing transaction"
In this line
var estimate = transferHandler.EstimateGasAsync(transactionMessage, ContractAddress).GetAwaiter().GetResult();
Juan Blanco
@juanfranblanco
Jul 08 2018 06:43
ahh
you are including Value
the same as the AmountToSend
revinfotech2
@revinfotech2
Jul 08 2018 06:44
Yes I am doing saem
Juan Blanco
@juanfranblanco
Jul 08 2018 06:44
just spotted..
revinfotech2
@revinfotech2
Jul 08 2018 06:44
same
Juan Blanco
@juanfranblanco
Jul 08 2018 06:44
one is the Ether
the other one is the Token
revinfotech2
@revinfotech2
Jul 08 2018 06:44
it means Value == ether
And token amount is actual token
Juan Blanco
@juanfranblanco
Jul 08 2018 06:45
so you are transfering both at the same time?
the token and the Ether?
The Ether to the smart contract
and the Token to the receiver address?
revinfotech2
@revinfotech2
Jul 08 2018 06:46
No token to the address
Juan Blanco
@juanfranblanco
Jul 08 2018 06:46
so you just want the token to the address
checking that..
revinfotech2
@revinfotech2
Jul 08 2018 06:46
I have remove the value. But still encounter the same problem
Yes I am aiming for the same
Juan Blanco
@juanfranblanco
Jul 08 2018 06:47
so transaction is failing on estimation
that means your code has an error
revinfotech2
@revinfotech2
Jul 08 2018 06:48
Let me give you the exact code
var _amount = unitConversion.ToWei(Amount, 18);
var web3 = new Web3(new Account(AdminPrivateKey), _parityURL);
            var transactionMessage = new TransferFunction()
            {
                FromAddress = AdminAddress,
                To = toAddress,
                AmountToSend = _amount,

            };



            var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();

            /// this is done automatically so is not needed.
            var estimate = transferHandler.EstimateGasAsync(transactionMessage, ContractAddress).GetAwaiter().GetResult();
            transactionMessage.Gas = estimate.Value;


            var transactionHash =  transferHandler.SendRequestAsync(transactionMessage, ContractAddress).GetAwaiter().GetResult();
I am using this
Juan Blanco
@juanfranblanco
Jul 08 2018 06:49
2 seconds i have now ether in ropsten
ill just do the same with the simple cqs to check if is parity
have you changed the token standard ?
ie is a different contract?
revinfotech2
@revinfotech2
Jul 08 2018 06:51
It is a Token contract
Juan Blanco
@juanfranblanco
Jul 08 2018 06:51
but they all can be different
the point is that it may have an error
that is causing the failure estimating
maybe is not payable hence it failed when sending an amount
btw AmountToSend is the Ether
revinfotech2
@revinfotech2
Jul 08 2018 06:53
0x61ED9FCE34dd1Ac7218619485618bbf2f00FfE8E
Oh
Juan Blanco
@juanfranblanco
Jul 08 2018 06:53
not the token amount
revinfotech2
@revinfotech2
Jul 08 2018 06:53
The above is token address
Juan Blanco
@juanfranblanco
Jul 08 2018 06:53
change that and it might work for you
and it might not be marked as payable
meaning that transferring Ether will fail
which the Estimation will fail
and hence you get an error
revinfotech2
@revinfotech2
Jul 08 2018 06:55
Wow
It is working
thanks man
Juan Blanco
@juanfranblanco
Jul 08 2018 06:56
cool :)
sorry about the slow analysis I was trying to get Ether for Ropsten in the background
Juan Blanco
@juanfranblanco
Jul 08 2018 07:16
Nethereum/Nethereum#379
on that note @revinfotech2
Juan Blanco
@juanfranblanco
Jul 08 2018 07:38
@topnguyen following the chat on Entities yesterday, further thoughts.. if you are going to focus only on storage you could have Entity specific smart contracts (although rather expensive on the mainnet)
these will be orchestrated by smart contracts (think of a service / ddd specific) layer
but in general the way i see a smart contract is as a Service
now structuring data storage (still note on the expensive side on public mainnet) in entities as readonly can be rather interesting
Gleb Skibitsky
@skibitsky
Jul 08 2018 10:43
Screen Shot 2018-07-08 at 13.35.53.png
@juanfranblanco I cannot build Nethereum libraries with Rider IDE on macOS.
Gleb Skibitsky
@skibitsky
Jul 08 2018 11:12
image.png
And I cannot build the latest release on Windows
Juan Blanco
@juanfranblanco
Jul 08 2018 16:06
yes Rider on a mac will be rather difficult
with the unity3d dependencies
and net451 targets
Windows.. ignore the portable
it only gets updated on release, it is mainly the same as the others..
linked files
although a task could be ran on CI
Roman Rudenko
@roman-rudenko
Jul 08 2018 21:11
Hi, could I do similar to hashPersonalMessage from ethereumjs-util using Nethereum?
Juan Blanco
@juanfranblanco
Jul 08 2018 22:17
yes
use the Nethereum.Signer
Roman Rudenko
@roman-rudenko
Jul 08 2018 23:24
I'm trying implement this code:
const { soliditySha3 } = require('web3-utils');
const {
  hashPersonalMessage,
  bufferToHex,
  toBuffer,
  ecsign
} = require('ethereumjs-util')
const { mapValues } = require('lodash');
const raw = soliditySha3({
  t: 'address',
  v: contractAddress
}, {
  t: 'address',
  v: tokenBuy
}, {
  t: 'uint256',
  v: amountBuy
}, {
  t: 'address',
  v: tokenSell
}, {
  t: 'uint256',
  v: amountSell
}, {
  t: 'uint256',
  v: expires
}, {
  t: 'uint256',
  v: nonce
}, {
  t: 'address',
  v: address
});
const salted = hashPersonalMessage(toBuffer(raw))
const {
  v,
  r,
  s
} = mapValues(ecsign(salted, privateKeyBuffer), (value, key) => key === 'v' ? value : bufferToHex(value));
Is Nethereum.Signer do the same as hashPersonalMessage or smth more extended?
Juan Blanco
@juanfranblanco
Jul 08 2018 23:27
it should be in theory the same
only thing is that I don't know internaly how is that Sha3 treating the json input
if it is as a string, then just hash it the same
also you need to know what type of signer is using
the Ethereum prefixed one (which is the default now) or the non prefixed one
Roman Rudenko
@roman-rudenko
Jul 08 2018 23:29
how to determine that?
Juan Blanco
@juanfranblanco
Jul 08 2018 23:31
just have a test..
this is what you need
assuming the json is treated as text