These are chat archives for Nethereum/Nethereum

7th
Jun 2018
Truong Dang Nghia
@DangNghia123_twitter
Jun 07 2018 03:26
hi, i want to create a mew wallet and i have used this code but it thrown an exceptiion Method Not Allowed, please help me
public async Task<string> CreateNewEthereumAddressAsync(string password)
{
return await web3.Personal.NewAccount.SendRequestAsync(password);
}
Edgar Herrador
@eherrador
Jun 07 2018 03:32
I'm working with Kaleido and I want access Kaleido using Nethereum but I have problems to access a node and a smart contract deployed on Kaleido (using truffle), however If I make a deployment using Nethereum code I can access the smart contract and call it. @juanfranblanco do you have an example to access Kaleido using Nethereum when the smart contract was deployed it?
hardik-dhankecha1
@hardik-dhankecha1
Jun 07 2018 05:04
Hii all,
hardik-dhankecha1
@hardik-dhankecha1
Jun 07 2018 05:12
Hello all, I have developed a smart contract using NEO platform and my token name is "AKT". Now I want to develop an API in C# from where user can exchange their AKT token to ETH and BTC. Here my question is that is their any external API which I can use it in my external code directly? and through which user can exchange their token with ETH.
Third party provide the APIs but all have limitations also.
Also I want continues monitoring on ETH address also which I will generate for users.
Please help me.
Thank you.
Juan Blanco
@juanfranblanco
Jun 07 2018 05:13
@DangNghia123_twitter if you are creating a new wallet for Geth you need to enable personal
if you use the keystore you don't need to do it
that will create the file for you
@eherrador I don't have any sample using Kaleido
Juan Blanco
@juanfranblanco
Jun 07 2018 05:21

@mvdv posted this sample on the requirements on authentication, I haven't got any samples

public static Web3 Web3
{
get
{
if (Variables.ContainsKey("ETH_RPC_USER") && Variables.ContainsKey("ETH_RPC_PWD"))
{
var basicAuth = Convert.ToBase64String(
Encoding.ASCII.GetBytes(
string.Format("{0}:{1}", Variables["ETH_RPC_USER"], Variables["ETH_RPC_PWD"])));

                var authHeader = new AuthenticationHeaderValue("basic", basicAuth);
                var endpoint = new Uri(Variables.RpcEndpoint);
                var client = new RpcClient(endpoint, authHeader);
                var web3 = new Web3(client);
                return web3;
            }
            else
            {
                return new Web3(Variables.RpcEndpoint);
            }
        }
    }
mainly you need some basic authentication
@hardik-dhankecha1 so you mainly want to create an oracle to do an exchange?
hardik-dhankecha1
@hardik-dhankecha1
Jun 07 2018 05:25
@juanfranblanco Yes exactly, I am familiar with NEO platform and I want external API of Ether in my application for an exchange. So is there any way to solve this ?
Thank you.
Juan Blanco
@juanfranblanco
Jun 07 2018 05:26
well you can start by checking this sample
you can run it with xamarin workbooks
hardik-dhankecha1
@hardik-dhankecha1
Jun 07 2018 05:28
@juanfranblanco Thank you. Let me check it.
Juan Blanco
@juanfranblanco
Jun 07 2018 05:28
the sample using the standard token contract
so that covers deployment, check balance and transfer
hardik-dhankecha1
@hardik-dhankecha1
Jun 07 2018 05:29
ok...Thank you.
wtlab
@wtlab
Jun 07 2018 10:43
Screen Shot 2018-06-07 at 15.41.57.png
Standard erc20
Juan Blanco
@juanfranblanco
Jun 07 2018 10:44
you need to put more gas ?
wtlab
@wtlab
Jun 07 2018 10:45
Screen Shot 2018-06-07 at 15.45.01 1.png
Juan Blanco
@juanfranblanco
Jun 07 2018 10:46
hmm interesting
mainly the estimation is not working
which chain are you pointing at?
wtlab
@wtlab
Jun 07 2018 10:47
ropsten
Screen Shot 2018-06-07 at 15.46.56.png
TokenAmount and transactionMessage.Gas log
hash
0x4ab88920b45fcee602bd813b798a518d4547fe82daeed49c6a3824b2899259b2
Juan Blanco
@juanfranblanco
Jun 07 2018 10:50
let me check rinkeby
same code
is your contract custom?
wtlab
@wtlab
Jun 07 2018 10:52
I have my own OurTestToken12 (OTT12) erc20 contract, deployed on an account. I try to send To this contract From generated address(c#). And have error above. But if i send from metamask - all work
Juan Blanco
@juanfranblanco
Jun 07 2018 10:55
did you enter your own estimate? there
metamask
is there any custom logic that might increase the gas?
is there a custom logic that might throw an error and might be reported out of gas?
nethereum just calls estimate gas on the chain
wtlab
@wtlab
Jun 07 2018 10:56
@juanfranblanco all no
@juanfranblanco
did you enter your own estimate? there
metamask no and no
also
Screen Shot 2018-06-07 at 15.46.56.png
Juan Blanco
@juanfranblanco
Jun 07 2018 10:58
what version of Nethereum are you using?
wtlab
@wtlab
Jun 07 2018 10:58
this log show contract message values but
wtlab
@wtlab
Jun 07 2018 10:58
Screen Shot 2018-06-07 at 15.58.35.png
Juan Blanco
@juanfranblanco
Jun 07 2018 10:59
just send one to rinkeby
what version of Nethereum are you using?
wtlab
@wtlab
Jun 07 2018 11:00
last nuget
Juan Blanco
@juanfranblanco
Jun 07 2018 11:00
2.5.1
wtlab
@wtlab
Jun 07 2018 11:00
latest
Juan Blanco
@juanfranblanco
Jun 07 2018 11:01
just checking as 2.5.0 there was an issue with .netcore21
wtlab
@wtlab
Jun 07 2018 11:01
oops 2.4.0
ok, but what about transfering ethers - no token
is this same?
Juan Blanco
@juanfranblanco
Jun 07 2018 11:03
transfering ether yes is similar
you mainly create a transactionInput and put the value
wtlab
@wtlab
Jun 07 2018 11:11
questions
  1. If i want to send all ethers from an address to token contract address, i have balance and put value to TokenAmount, then check estimate gas for example:
    var estimate = await transferHandler.EstimateGasAsync(transactionMessage, receiverAddress);
    a) why second argument is "receiverAddress" ( =contract address, without ethers on balance )
    b) may be before sending request a i need TokenAmount -= (BigInteger)estimate.Value
b) - for full balance transfering
Juan Blanco
@juanfranblanco
Jun 07 2018 11:14
to send the whole balance from 1 address to other you need to calculate the cost and substract it from it
currentAmount = currentAmount - (web3.TransactionManager.DefaultGas * web3.TransactionManager.DefaultGasPrice);
something like that
although you may want to adjust the price :)
wtlab
@wtlab
Jun 07 2018 11:53
(web3.TransactionManager.DefaultGas * web3.TransactionManager.DefaultGasPrice);
but we need actual value now
Juan Blanco
@juanfranblanco
Jun 07 2018 11:53
currentAmount
  • feees
damn..
currentAmount - fees
wtlab
@wtlab
Jun 07 2018 11:55
i understand it) i dont undesratant how to get actual fees like: var fees = await blabla.GetFees(addsresses(?));
Juan Blanco
@juanfranblanco
Jun 07 2018 11:56
you want previous fees?
you can calculate that from the transactionreceipt and actual gas etc
wtlab
@wtlab
Jun 07 2018 12:00
i just want to send the whole balance) why is it so not obvious..
like await SendAll(address from,address to);
without fuc$$ng calcualates gases/feees/estimates when all crashed and failed from tx to tx
:) all day i cant send whole balance, omg
^^
well there is not a transfer the whole balance function as it depends on the cost you are going to pay
Enigmatic
@EnigmaticUnreal_twitter
Jun 07 2018 12:20
@wtlab - That's in fact the beauty of ethereum since there's a dynamic fee market, you don't need to pay high prices per transaction as the price of ethers increase, but you can adjust it downwards.
wtlab
@wtlab
Jun 07 2018 12:27
yes, we can) and then all stuck
but we can
Psilon
@Pzixel
Jun 07 2018 13:03
@juanfranblanco nethereum is using HTTP?
Psilon
@Pzixel
Jun 07 2018 13:13
Could it work via websockets?
Psilon
@Pzixel
Jun 07 2018 13:18
I see an old issue
but no examples
Nethereum/Nethereum#25
should work starting 1.1:)
Juan Blanco
@juanfranblanco
Jun 07 2018 13:21
websockets is only for subscriptions
and is specific for parity and geth (different implementations)
and yes it is in the todo list :)
Psilon
@Pzixel
Jun 07 2018 13:23
I now in a hard situation
@tbaut (parity guy) says that this could be a limitation of HTTP API
but it seems that I can't use anything else
wtlab
@wtlab
Jun 07 2018 13:25
@juanfranblanco var txn = await web3.Eth.TransactionManager.SendTransactionAsync(pool.Wallet.Address, pool.TokenContractAdress, new HexBigInteger(currentAmount)); thats work partialy
Screen Shot 2018-06-07 at 18.24.48.png
instead
Screen Shot 2018-06-07 at 18.25.32.png
Juan Blanco
@juanfranblanco
Jun 07 2018 13:26
hmm you are making a transfer
have you tried other chain?
wtlab
@wtlab
Jun 07 2018 13:26
so var transferReceipt = await transferHandler.SendRequestAsync(transactionMessage, receiverAddress); didnt work for me in this case
Juan Blanco
@juanfranblanco
Jun 07 2018 13:27
well that is completely different
that is to transfer tokens
or any action with any smart contract
@Pzixel yeah i need to find time to do ws :)
Psilon
@Pzixel
Jun 07 2018 13:28
@juanfranblanco I'm on burning ship)
I have to ship somethinh working in several days
but
Juan Blanco
@juanfranblanco
Jun 07 2018 13:28
so what is your problem
Psilon
@Pzixel
Jun 07 2018 13:28
it just fails to send 100 parallel transactions
Juan Blanco
@juanfranblanco
Jun 07 2018 13:28
ah that is not the websockets i was thinking of :)
i am thinking of the subscriptions websockets
Psilon
@Pzixel
Jun 07 2018 13:29
nope
@Tbaut
Using web3 and a WS interface should work flawlessly IMO
No idea what Nethereum is using and not sure it's not linked..
Juan Blanco
@juanfranblanco
Jun 07 2018 13:29
so you have 100 transactions in parallel
using http
Psilon
@Pzixel
Jun 07 2018 13:29
yes, and then network starts to behave weird
wtlab
@wtlab
Jun 07 2018 13:29
@juanfranblanco so i need only add gas to this method? web3.Eth.TransactionManager.SendTransactionAsync(pool.Wallet.Address, pool.TokenContractAdress, new HexBigInteger(currentAmount)); and all will work?
@juanfranblanco which?
Juan Blanco
@juanfranblanco
Jun 07 2018 13:30
@wtlab you are transferring ether
wtlab
@wtlab
Jun 07 2018 13:30
i need transfering ether!
Psilon
@Pzixel
Jun 07 2018 13:30
with some code
Juan Blanco
@juanfranblanco
Jun 07 2018 13:30
in theory all transaction tranfers cost the same
wtlab
@wtlab
Jun 07 2018 13:30
but SendTransactionAsync work but need gas
and SendRequestAsync didntwork
Psilon
@Pzixel
Jun 07 2018 13:32
I'l wait until you finish here
Juan Blanco
@juanfranblanco
Jun 07 2018 13:32
@wtlab there are two different things one is for a smart contract the other is for transfer ether
@Pzixel so the issue is http on their side
Psilon
@Pzixel
Jun 07 2018 13:33
probably
Juan Blanco
@juanfranblanco
Jun 07 2018 13:33
and think that websockets will improve that
Psilon
@Pzixel
Jun 07 2018 13:33
I have no guarantees or solid information
Juan Blanco
@juanfranblanco
Jun 07 2018 13:33
not blaming.. just thinking about ws :)
Psilon
@Pzixel
Jun 07 2018 13:33
just thoughts
I'm fine
Juan Blanco
@juanfranblanco
Jun 07 2018 13:33
so one simple thing would be
Psilon
@Pzixel
Jun 07 2018 13:33
I'm just trying to find any workaround
Juan Blanco
@juanfranblanco
Jun 07 2018 13:33
to create different nodes
Psilon
@Pzixel
Jun 07 2018 13:34
except slowdown the network for 1 req/sec
Juan Blanco
@juanfranblanco
Jun 07 2018 13:34
and split the tasks around them
so if you start 10 nodes
Psilon
@Pzixel
Jun 07 2018 13:34
well, in my expirience it didn't work well
but
Juan Blanco
@juanfranblanco
Jun 07 2018 13:34
each one could get 100 at a time
Psilon
@Pzixel
Jun 07 2018 13:34
This is a good idea
I'l test it now. Thank you
Juan Blanco
@juanfranblanco
Jun 07 2018 13:34
ha ha another todo thing is to do bulk loading :D
wtlab
@wtlab
Jun 07 2018 13:34
@juanfranblanco Ok, now i want transfer ether to the contract address. And i need to add gas to this method right? web3.Eth.TransactionManager.SendTransactionAsync(pool.Wallet.Address, pool.TokenContractAdress, new HexBigInteger(currentAmount))
Juan Blanco
@juanfranblanco
Jun 07 2018 13:35
yeah if it is failing using the default gas then increase it
wtlab
@wtlab
Jun 07 2018 13:35
Screen Shot 2018-06-07 at 18.24.48.png
Juan Blanco
@juanfranblanco
Jun 07 2018 13:35
you can create a transactionInput that has all the paramters
parameters
Psilon
@Pzixel
Jun 07 2018 13:36

ha ha another todo thing is to do bulk loading :D

I don't believe it's doable on your side

it's how ethereum works itself
Juan Blanco
@juanfranblanco
Jun 07 2018 13:36
yeah but some kind of sample / procedure
wtlab
@wtlab
Jun 07 2018 13:36
where i can find full sample?) because i try " create a transactionInput.." before writing here :)
Juan Blanco
@juanfranblanco
Jun 07 2018 13:37
well it is one of the overloads
wtlab
@wtlab
Jun 07 2018 13:37
yes
Juan Blanco
@juanfranblanco
Jun 07 2018 13:37
new TransactionInput(){}
wtlab
@wtlab
Jun 07 2018 13:37
i know how it creates!)
Juan Blanco
@juanfranblanco
Jun 07 2018 13:37
:)
have you tried to test it in a local testnet?
wtlab
@wtlab
Jun 07 2018 13:38
i need example like this
Juan Blanco
@juanfranblanco
Jun 07 2018 13:39
so you can use one of those to experiment
some ideas
kind of busy at the moment so i cannot create the whole sample
var transactionInput = new TransactionInput();
transactionInput.From = "youraddress";
transactionInput.To = "theirAddress";
transactionInput.Value = "amount in wei";
transactionInput.Gas = "??"; // for transfers should be the default
transactionInput.GasPrice = "your wei price calculated from gwei";
web3.Eth.TransactionManager.SendTransactionAsync()
that is about it ^^^
wtlab
@wtlab
Jun 07 2018 13:50
i dont understand only
transactionInput.Gas = "??"; // for transfers should be the default
transactionInput.GasPrice = "your wei price calculated from gwei";
Juan Blanco
@juanfranblanco
Jun 07 2018 13:50
right the gas for a normal transfer will always be the same
wtlab
@wtlab
Jun 07 2018 13:50
"default"? how can i get this value in ropsten test ne
same as what??
Juan Blanco
@juanfranblanco
Jun 07 2018 13:51
well Nethereum provides the default value
each transaction that it does a transfer cost the same
so if you leave it blank it should in theory not be an issue
Now
if your smart contract is doing something when receiving the ether
by using a default function
wtlab
@wtlab
Jun 07 2018 13:52
doing
it sending Tokens
Juan Blanco
@juanfranblanco
Jun 07 2018 13:52
then you will need to provide extra gas to accommodate for it
ah..
wtlab
@wtlab
Jun 07 2018 13:53
ah?
Juan Blanco
@juanfranblanco
Jun 07 2018 13:53
well that is your problem
wtlab
@wtlab
Jun 07 2018 13:54
continue, I beg you...
:)
looking for some info that can help you
estimate won't work in this situation at least in Nethereum as you are using the fallback function
so as an experiment increase the gas and validate how much is used and use it as an indication of how much gas is necessary
wtlab
@wtlab
Jun 07 2018 13:57
but why metamask can do it with default values?
Juan Blanco
@juanfranblanco
Jun 07 2018 13:58
well they will have increased the amount
just use those values
there is nothing different
at the end of the pipe you have the chain
wtlab
@wtlab
Jun 07 2018 14:22
Screen Shot 2018-06-07 at 19.18.45.png
@juanfranblanco i understand what for me actual increasing of values (gas gasPrice)
what order of numbers? 1 or 1000000000?
Juan Blanco
@juanfranblanco
Jun 07 2018 14:24
that gives you an idea of the current price
the unit is gwei
so you need to convert it to wei
using Web3.Convert.ToWei
wtlab
@wtlab
Jun 07 2018 14:27
Screen Shot 2018-06-07 at 19.26.32.png
web3.Conver.ToWei(11) ?
GasPrice = web3.Conver.ToWei(11) ?
Juan Blanco
@juanfranblanco
Jun 07 2018 14:28
you need to put the unit from
in this scenario is Gwei
next parameter
wtlab
@wtlab
Jun 07 2018 14:29
ok, and gas used 75000
Gas = web3.Conver.ToWei(75000) ?
what unit here, is all right in my logic?:)
Juan Blanco
@juanfranblanco
Jun 07 2018 14:32
the gas is fine
no need to change
wtlab
@wtlab
Jun 07 2018 14:34
Gas = new HexBigInteger(75000),
or Gas = web3.Conver.ToWei(75000) ?
Juan Blanco
@juanfranblanco
Jun 07 2018 14:35
the first one
wtlab
@wtlab
Jun 07 2018 14:44
Unhandled Exception: Nethereum.JsonRpc.Client.RpcResponseException: insufficient funds for gas * price + value
Screen Shot 2018-06-07 at 19.44.51.png
ohhhhh...
got between the eyes, did not see)
wtlab
@wtlab
Jun 07 2018 14:51
Screen Shot 2018-06-07 at 19.51.02.png
now all right?
wtlab
@wtlab
Jun 07 2018 14:57
yes