These are chat archives for Nethereum/Nethereum

15th
Dec 2017
Michael Herman (Toronto)
@mwherman2000
Dec 15 2017 01:46
I'm following Juan's youtube https://www.youtube.com/watch?v=4t5Z3eX59k4&t=820s&index=1&list=PLU-rWqHm5p47MzWY_uHwk-P8gux5pMSMM and I'm trying to convert the sample into a) a Windows Console app that b) uses the Rinkeby test network.
This is a Windows 10 machine and I'm getting the following error:

SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8545

api modules: Post http://localhost:8545: dial tcp [::1]:8545: connectex: No connection could be made because the target machine actively refused it.

Any ideas?
Michael Herman (Toronto)
@mwherman2000
Dec 15 2017 01:57
Fixed: I needed to run geth.exe with --rpc
Juan Blanco
@juanfranblanco
Dec 15 2017 06:41
@mwherman2000 in here you can find 2 configured private testnets https://github.com/Nethereum/Nethereum.Workbooks/tree/master/testchain
one for parity PoA and the for Geth PoA (clique)
just launch them using the batch files
TarrahArshad
@TarrahArshad
Dec 15 2017 15:33
@juanfranblanco i lost decimal values after use this (decimal)Web3.Web3.Convert.FromWeiToBigDecimal(wei,token.NumberOfDecimalPlaces);
Juan Blanco
@juanfranblanco
Dec 15 2017 15:34
yes if you cast a decimal from BigDecimal it is going to lose precission
BigDecimal is bigger than a decimal
TarrahArshad
@TarrahArshad
Dec 15 2017 15:34
how to i keep ?
Juan Blanco
@juanfranblanco
Dec 15 2017 15:35
use a string and convert that to a bigdecimal later
depends what you want to do with it
but this is the same problem as with any financial system
as you can see BigDecimal is part of Nethereum
so it is not even part of the .net framework
TarrahArshad
@TarrahArshad
Dec 15 2017 15:37
i think this is wrong for get decimal precission : var wei = await service.GetBalanceOfAsync<BigInteger>(accountInfo.Address);
Juan Blanco
@juanfranblanco
Dec 15 2017 15:37
wei in ethereum is the lowest unit
TarrahArshad
@TarrahArshad
Dec 15 2017 15:38
biginterger is contain precission ?
Juan Blanco
@juanfranblanco
Dec 15 2017 15:38
if you convert that to Ether (depending on how much ether you have) you should be ok with decimal
biginteger is an integer
integers do now have decimals
TarrahArshad
@TarrahArshad
Dec 15 2017 15:44
@juanfranblanco always in balance i get 8 precission , right ? ( 8 is my token decimal number )
Juan Blanco
@juanfranblanco
Dec 15 2017 15:45
I would suggest your token to have the same as Ether which is 18
but if you have 8 is fine :)
mainly most of the ERC20 contracts do the same as it is easier
TarrahArshad
@TarrahArshad
Dec 15 2017 15:45
so if i insert "." char before 8 number of end i have correct value , right ?
Juan Blanco
@juanfranblanco
Dec 15 2017 15:45
but when you are storing it you need to convert it to not have any decimal values
no
sorry yes
TarrahArshad
@TarrahArshad
Dec 15 2017 15:46
always ether reponse full number with all precession , right ?
Juan Blanco
@juanfranblanco
Dec 15 2017 15:47
wei it is the whole number lowest unit
smart contracts do not store decimals
they store integers upto int256
hence using BigIntegers
TarrahArshad
@TarrahArshad
Dec 15 2017 15:49
ok
i can use ur crossplatform for my token ? this code is secure ?
@juanfranblanco ؟
Juan Blanco
@juanfranblanco
Dec 15 2017 15:50
yes it is cross platform
TarrahArshad
@TarrahArshad
Dec 15 2017 15:52
for send token need client privatekey , right ?
how to store this very secure data ?
Juan Blanco
@juanfranblanco
Dec 15 2017 15:52
yes you need to
well that depends on your architecture
TarrahArshad
@TarrahArshad
Dec 15 2017 15:53
but mobile apps is unprotect decompile
Juan Blanco
@juanfranblanco
Dec 15 2017 15:53
that will be the users private key
they can store it using the keystorage definition
or integrate with uport
or multisig
but each one needs its own architecture design
TarrahArshad
@TarrahArshad
Dec 15 2017 15:55
so its better we save encrypted string database decode from password user and use for send token
TarrahArshad
@TarrahArshad
Dec 15 2017 16:16
@juanfranblanco my problem for send token is still
my code is var s1 = standardTokenServicek.TransferAsync(senderAddress, addressTo, 100000000000000);
Juan Blanco
@juanfranblanco
Dec 15 2017 16:27
@tuyen-vuduc did you solve your problem? did the sample helped you?
@TarrahArshad you need to await the call
you do have the sample already just use the same
TarrahArshad
@TarrahArshad
Dec 15 2017 16:45
i see in in my ether wallete 0 value transfer in 3 time but i no see token transfered
@juanfranblanco i'm stil in send token i have a problem
@juanfranblanco plz check this screen http://snap.ashampoo.com/InEocLwi
Juan Blanco
@juanfranblanco
Dec 15 2017 16:50
what is the address of your token
in etherscan
TarrahArshad
@TarrahArshad
Dec 15 2017 16:51
@juanfranblanco address is main account on contract deployed
sender = 0xbA6cF056103D7E57fb904c4451F7F0fD94F3f22B
_to = 0x8035F249712Fca8d1270b0ecF9afd27Cf6E3408d
Juan Blanco
@juanfranblanco
Dec 15 2017 16:52
can you point me to the address in etherscan
in what testnet network or mainnet
Juan Blanco
@juanfranblanco
Dec 15 2017 16:54
so this is your contract 0x251730162E853e831F1dd40636FAa620b0E1fAde
TarrahArshad
@TarrahArshad
Dec 15 2017 16:54
yes
Juan Blanco
@juanfranblanco
Dec 15 2017 16:58
so you want to send from 0xbA6cF056103D7E57fb904c4451F7F0fD94F3f22B
some irc tokens to 0x8035F249712Fca8d1270b0ecF9afd27Cf6E3408d
and you have already created a smart contract
which you have sent some already in 2 different transactions
well mainly if you follow the steps from the other day you should be fine
and yes the irn token has 8 decimal places
so if you are transferring 1 irc token
that will be 100000000
ignoring the deployment code
and using the address "https://mainnet.infura.io"
it is the same
only thing is the conversion of units
which you can do manually
or use something like Web3.Convert.ToWei(value, 8)
that is top of my head do a test
or other example provided will be very similar, the above includes gas estimation
TarrahArshad
@TarrahArshad
Dec 15 2017 17:10
@juanfranblanco i sent 2 transaction before from contract wallet manualy no in code
Juan Blanco
@juanfranblanco
Dec 15 2017 17:11
yes i have seen
TarrahArshad
@TarrahArshad
Dec 15 2017 17:12
@juanfranblanco so what is my problem ? problem is gas ?
Juan Blanco
@juanfranblanco
Dec 15 2017 17:12
i don't know post a full gist of your code
TarrahArshad
@TarrahArshad
Dec 15 2017 17:12
its my static StandardTokenService standardTokenServicek = new StandardTokenService(web3, contractaddress);
tokenservice
Juan Blanco
@juanfranblanco
Dec 15 2017 17:12
using gist please
TarrahArshad
@TarrahArshad
Dec 15 2017 17:13
@juanfranblanco can i send inside ur private ?
@juanfranblanco gist ?
Juan Blanco
@juanfranblanco
Dec 15 2017 17:13
just paste it here
TarrahArshad
@TarrahArshad
Dec 15 2017 17:13
its contain privatekey
Juan Blanco
@juanfranblanco
Dec 15 2017 17:13
don' t put the privatekey
everything else should be ok
even if you dm me don't put the private key either
TarrahArshad
@TarrahArshad
Dec 15 2017 17:14
class Program
{
static string[] urlNetework = new string[] {
"https://ropsten.infura.io/jAj4Ji3YulA9EO2qDj0Z ",
"https://mainnet.infura.io/jAj4Ji3YulA9EO2qDj0Z",
"https://mainnet.infura.io/"
};
   static string privateKey = "-";
   static string senderAddress = "0xbA6cF056103D7E57fb904c4451F7F0fD94F3f22B";

    static string _to = "0x8035F249712Fca8d1270b0ecF9afd27Cf6E3408d";
    static Account account = new Account(privateKey);
   static Web3 web3 = new Web3(account, urlNetework[2]);
   static string contractaddress = "0x251730162e853e831f1dd40636faa620b0e1fade";
   static StandardTokenService standardTokenServicek = new StandardTokenService(web3, contractaddress);

    static void Main(string[] args)
    {
        //GetBalance(senderAddress);
        //GetBalanceToken("0x8035F249712Fca8d1270b0ecF9afd27Cf6E3408d");
        SendToken(senderAddress,_to, 100000000000000);


        Console.ReadKey();
    }

    static async Task GetBalance(string address)
    {
        var balance = await web3.Eth.GetBalance.SendRequestAsync(address);
        var etherAmount = Web3.Convert.FromWei(balance.Value);


        Console.Write("ETH : " + etherAmount.ToString());           
    }
    static async Task SendToken(string _from,string _to, BigInteger value)
    {
        var s =await standardTokenServicek.TransferAsync(_from, _to, value);

        if (s != null)
        {
            Console.WriteLine(s.ToString());
        }

    }


    static async Task GetBalanceToken(string address)
    {
        Console.Write("start\n");


        Console.Write("wait\n");

        var s =await standardTokenServicek.GetBalanceOfAsync<BigInteger>(address);


        Console.Write(s.ToString()+"\n");            

    }
}
@juanfranblanco its ful code
Juan Blanco
@juanfranblanco
Dec 15 2017 17:22
First thing you need to on SendToken(senderAddress,_to, 100000000000000);
add Wait();
SendToken(senderAddress,_to, 100000000000000).Wait();
as you are in the console and main does not include the async keyword (only supported from 7.1)
then you need to include some gas
await standardTokenServicek.TransferAsync(_from, _to, value)
TarrahArshad
@TarrahArshad
Dec 15 2017 17:34
@juanfranblanco gas ? how to use this ?
@juanfranblanco i can use this class :smile:
class WorkaroundStandardTokenService : StandardTokenService
{
public WorkaroundStandardTokenService(Web3 web3, string address) : base(web3, address)
{
    }

    public new async Task<bool> TransferAsyncCall<T>(string addressFrom, string addressTo, T value)
    {
        var function = GetTransferFunction();

        var gas = await function.EstimateGasAsync(addressFrom, null, null, addressTo, value);
        var tx = await function.SendTransactionAndWaitForReceiptAsync(addressFrom, gas, null, null, addressTo, value);

        return true;
    }
}
check this out, yet another version.
TarrahArshad
@TarrahArshad
Dec 15 2017 17:48
@juanfranblanco why TokenAmount is INT ? we can't add decimal
Juan Blanco
@juanfranblanco
Dec 15 2017 17:49
change it to BigInteger
TarrahArshad
@TarrahArshad
Dec 15 2017 17:49
[Parameter("uint256", "_value", 2)]
            public BigInteger TokenAmount { get; set; }
Juan Blanco
@juanfranblanco
Dec 15 2017 17:49
correct
TarrahArshad
@TarrahArshad
Dec 15 2017 17:51
we can call transfer and close ? this task sent to Network and we can later track ?
right ?
Juan Blanco
@juanfranblanco
Dec 15 2017 17:51
oh in this scenario waits for the receipt
but you can also..
var transactionHash = await transferHandler.SendRequestAsync(transactionMessage, contractAddress);
TarrahArshad
@TarrahArshad
Dec 15 2017 17:54

one question :smile:
in my contract token i see showed
Value per Token: $0

when its increase ? and how to i can set this value in USD ?

@juanfranblanco ?
Juan Blanco
@juanfranblanco
Dec 15 2017 17:55
that is etherscan that pulls the prices from somewhere
like coinmarketcap
or maybe etherdelta
TarrahArshad
@TarrahArshad
Dec 15 2017 17:57
@juanfranblanco so its not my option to set ? right
Juan Blanco
@juanfranblanco
Dec 15 2017 17:57
no that is driven by the real price on exchanges
TarrahArshad
@TarrahArshad
Dec 15 2017 17:58
if i delete contract token lost from users ?
@juanfranblanco ?
Juan Blanco
@juanfranblanco
Dec 15 2017 17:58
yes
TarrahArshad
@TarrahArshad
Dec 15 2017 17:59
@juanfranblanco oh , this is very bad , i think ether network must remove action delete contract from developer option. its for protect users tokens
@juanfranblanco minuts .wait() is stil , when finish ?
TarrahArshad
@TarrahArshad
Dec 15 2017 18:05
token sent
now i can send and check balance
for get transaction how to handle >?
Juan Blanco
@juanfranblanco
Dec 15 2017 18:09
the Wait is necessary for the program to run, as it is async
your transactionhash is in the receipt
i need to go and have dinner
TarrahArshad
@TarrahArshad
Dec 15 2017 18:10
@juanfranblanco thank u juan , u really helped me ,