These are chat archives for Nethereum/Nethereum

19th
Jan 2018
Brennan Hatton
@BrennanHatton_twitter
Jan 19 2018 02:57

@juanfranblanco . I ran the demo in 2017.3. DecodeData.cs gave an error at line 25 Debug.Log(web3.Eth.Blocks.GetBlockNumber.SendRequestAsync().Result.Value.ToString());

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

Full error: https://pastebin.com/XMUQqcv0

Vũ Đức Tuyến
@tuyen-vuduc
Jan 19 2018 03:44
@everyone, I just published my sample Xamarin.Forms application using NEthereum. It might be worth for someone :) https://github.com/NAXAM/cryptallet-xamarin-forms
Chris Misztur
@cmisztur
Jan 19 2018 05:40
@BrennanHatton_twitter what are you trying to do? I can help you with Unity in the AM. It's almost midnight now.
Juan Blanco
@juanfranblanco
Jan 19 2018 05:58
@BrennanHatton_twitter this assumes you have a testnet running on your localhost
Chris Misztur
@cmisztur
Jan 19 2018 05:59
And you'll want to move the web3 constructor out of the Update and into Start.
Juan Blanco
@juanfranblanco
Jan 19 2018 05:59
Lol yeah ;) it was ac quick sample
Slap hand ;)
Brennan Hatton
@BrennanHatton_twitter
Jan 19 2018 06:52

Thanks Chris Juan,

Chris, I'm just trying to get an example/demo setup in Unity.
I will go setup the testnet on my localhost. Just found the docs for settingup the testnet

bluuman
@bluuman
Jan 19 2018 07:13
Successfully sent a transaction, but I got an exception "known transaction".
shareworlds
@shareworlds
Jan 19 2018 14:14

Given:

event Transfer(address indexed _from, address indexed _to, uint256 _value);

I want to filter out all events that it's "to address" is "0x00cc0bf7744197f78c46c0746b7a6277d6657e24",

My code is:

string[] toAddress = new string[] { "0x00cc0bf7744197f78c46c0746b7a6277d6657e24" };
var filterTopic = await depositMadeEvent.CreateFilterAsync(null, null, toAddress);
var logs = await depositMadeEvent.GetAllChanges<TransferEvent>(filterTopic);
var count = logs.count;

But the count always is 0, actually the data contains this address. Does someone know where is the bug?

Juan Blanco
@juanfranblanco
Jan 19 2018 14:41
@shareworlds you need to pass a block range
Sean Finnegan
@cowtrix
Jan 19 2018 14:41
@cowtrix
hey all
had a quick question
I want to have a type of contract that is guaranteed to be unique on the blockchain
so if you try to create a new contract with the same values as an existing one, it fails
is there any way to do that?
I was wondering if it would be possible by having like a manager contract, that keeps a storage of all existing contracts it has spawned, but will that scale over time as the storage gets bigger and bigger?
or can I just store the time created and just take the one that is the oldest/
Juan Blanco
@juanfranblanco
Jan 19 2018 14:45
you could have a registry
and keep the each contract (address) in the registry
if you want each one to be uniquely identify, when a contract is added to the registry the registry also gives it a unique identity
the registry is the only one that can do that
Sean Finnegan
@cowtrix
Jan 19 2018 14:47
the registry being another contract? with a dynamic array of contracts? will that scale, if say I want to have thousands of unique contracts?
Juan Blanco
@juanfranblanco
Jan 19 2018 14:48
yes, but you only register the address
of the unique contract
the unique contract is unique as it is verified by the registry (somehow)
mainly by providing an id
for uniqueness
what are you trying to prevent?
Sean Finnegan
@cowtrix
Jan 19 2018 14:49
hmmm, the unique key in this would be a checksum
I want to guarantee that there is only one contract for a given checksum, and prevent double registry
Juan Blanco
@juanfranblanco
Jan 19 2018 14:50
well if a contract at the time of registry
has an interface
which allow to put a unique ide
id*
and retrieve it
also the address will be unique too
but i guess you are referring also to the contract itself
contract code
Sean Finnegan
@cowtrix
Jan 19 2018 14:51
yes, the contents of the contract itself should be unique
Juan Blanco
@juanfranblanco
Jan 19 2018 14:52
well but that can change with very little
ie the logic
Sean Finnegan
@cowtrix
Jan 19 2018 14:52
one specific variable that is, a checksum
Juan Blanco
@juanfranblanco
Jan 19 2018 14:52
exactly
hence what is the use case
if you just want to have a registry of contracts, each will be unique as each one will have the same address
Sean Finnegan
@cowtrix
Jan 19 2018 14:53
I want to be able to guarantee ownership over a thing that generates that checksum, so that a user can provably claim to have had that thing at the time of the contract creation
a proof-of-ownership
Juan Blanco
@juanfranblanco
Jan 19 2018 14:54
but anyone can copy the bytecode
Sean Finnegan
@cowtrix
Jan 19 2018 14:55
yes, but the contract would specify an address, as well as metadata about the owner (name, dob, contact info)
which only the owner of the contract would be able to change, to change ownership of the thing
Juan Blanco
@juanfranblanco
Jan 19 2018 14:55
but that can be achieved on the constructor and the state
and the registry
or you can create the contract first and at the time of registry
you supply the unique information of the state
Sean Finnegan
@cowtrix
Jan 19 2018 14:57
so this registry, say I end up with a million entries
Juan Blanco
@juanfranblanco
Jan 19 2018 14:57
that unique info.. you could hashed like a mulitiple key in a db
Sean Finnegan
@cowtrix
Jan 19 2018 14:57
will that cripple this system?
Juan Blanco
@juanfranblanco
Jan 19 2018 14:57
and use it for validation
well just put the unique information
that could be an ipfs hash
if you wanted to store it off chain
and the other contract have that hash too, with the combined info
Sean Finnegan
@cowtrix
Jan 19 2018 14:59
hmmm ok so the registry puts everything into buckets for quick duplicate checking
Juan Blanco
@juanfranblanco
Jan 19 2018 14:59
but in a similar way you can hash the key and unique key info (x,y,z fields)
yeah
then have a map for those hashes
to contract address
Sean Finnegan
@cowtrix
Jan 19 2018 15:00
does the mapping type implement a fast lookup with hashing? or will I have to do that muself?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:00
and when registering a contract, the registry updates those fields on the contract to avoid tampering
mapping is very fast
hashing is to prevent to store dupplicate data but ensure uniqueness
mainly separate logic of data
Sean Finnegan
@cowtrix
Jan 19 2018 15:01
ok, cool
Juan Blanco
@juanfranblanco
Jan 19 2018 15:02
so:
  1. create contract
  1. register contract (pass key info)
3) hash key info add to registry, with contract address
various ways to store
4) registry updates key info in contract
in between validate key info hash does not exist already
you should only store the contract address and key info hashed in the smart contract
Sean Finnegan
@cowtrix
Jan 19 2018 15:06
okay, sounds good
cheers!
Juan Blanco
@juanfranblanco
Jan 19 2018 15:06
:) you got me inspired
Sean Finnegan
@cowtrix
Jan 19 2018 15:06
whats the established practice on guaranteeing that there is only one registry, and verifying that registries authenticity?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:07
well that can get exponential
a registry of registries :)
uport comes to mind
Sean Finnegan
@cowtrix
Jan 19 2018 15:07
so does that require a trusted source? some 3rd party server saying "this is the registry"?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:08
yeah you are always going to get that
Veikko Eeva
@veikkoeeva
Jan 19 2018 15:08
Ah, registries. Is there a good source to read those, by the way? :)
Sean Finnegan
@cowtrix
Jan 19 2018 15:08
yeah I guess like if people want to make their own registries I can't stop them
Juan Blanco
@juanfranblanco
Jan 19 2018 15:08
with uport and identity you will be able to use reputation
Veikko Eeva
@veikkoeeva
Jan 19 2018 15:08
Jumping in the conversation... This could be of interest here too: https://medium.com/@lopp/the-challenges-of-building-ethereum-infrastructure-87e443e47a4b .
Juan Blanco
@juanfranblanco
Jan 19 2018 15:08
yeah exactly
Sean Finnegan
@cowtrix
Jan 19 2018 15:08
hmmm uport is interesting!
Veikko Eeva
@veikkoeeva
Jan 19 2018 15:09
The ought to use https://github.com/dotnet/orleans/ to build infrastructure. :P
Juan Blanco
@juanfranblanco
Jan 19 2018 15:09
yes reputation and identity
@veikkoeeva :)
nice to see it still very active (orleans) I mean
TarrahArshad
@TarrahArshad
Jan 19 2018 15:11
@juanfranblanco i have problem for get transaction from hash Tx can u help me ?
            var t = web3.Eth.Transactions.GetTransactionByHash(address);
not work
Veikko Eeva
@veikkoeeva
Jan 19 2018 15:13
Orleans is more active than ever, used more and more. Keeps me busy too, almost too busy occasionally. :)
Juan Blanco
@juanfranblanco
Jan 19 2018 15:14
await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(address);
@veikkoeeva ha ha cool
TarrahArshad
@TarrahArshad
Jan 19 2018 15:17
@juanfranblanco from this code we can know how much confirmated ?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:18
no you just get the transaction
TarrahArshad
@TarrahArshad
Jan 19 2018 15:24
@juanfranblanco so how to i can know how much confirmed ?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:27
substract the transaction blocknumber from the current block number
TarrahArshad
@TarrahArshad
Jan 19 2018 15:28
@juanfranblanco how to ?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:28
the transaction will have a blocknumber
and you have a current blocknumber on the chain
TarrahArshad
@TarrahArshad
Jan 19 2018 15:28
@juanfranblanco i have only Tx string
Juan Blanco
@juanfranblanco
Jan 19 2018 15:29
await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(address);
that gives you the transaction
confirmations are required to validate you are not in a fork
the more confirmations (blocks passed)
the more chances that the transaction is not in a forked chain
TarrahArshad
@TarrahArshad
Jan 19 2018 15:30
@juanfranblanco comfuze can u give me link to sample code ?
Juan Blanco
@juanfranblanco
Jan 19 2018 15:31
await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(address);
await web3.Eth.Blocks.GetBlockNumber (top of my head)
substract the transaction blocknumber from the current block number
TarrahArshad
@TarrahArshad
Jan 19 2018 15:33
(top of my head) ? @juanfranblanco
Juan Blanco
@juanfranblanco
Jan 19 2018 15:33
mainly check the autocomplete to get the right method
TarrahArshad
@TarrahArshad
Jan 19 2018 15:37
@juanfranblanco really i can't understand
i see in Block Height in etherscan information about confirmation
2452797 (32449 block confirmations)
here we have 2452797 and 32449 , i need know what is and how calc ?
that might be simpler
this is also good
TarrahArshad
@TarrahArshad
Jan 19 2018 15:46

@juanfranblanco
var conf = web3.Eth.Blocks.GetBlockNumber;

this not return number see :smile:

{
"MethodName": "eth_blockNumber",
"Client": {
"OverridingRequestInterceptor": null
}
}

TarrahArshad
@TarrahArshad
Jan 19 2018 15:53

@TarrahArshad

    web3.Eth.Blocks.GetBlockNumber 

this code no response

@TarrahArshad
Juan Blanco
@juanfranblanco
Jan 19 2018 15:57
web3.Eth.Blocks.GetBlockNumber.SendRequestAsync
like all the other Nethereum rpc methods
same pattern :)
TarrahArshad
@TarrahArshad
Jan 19 2018 15:58

i get this

{"Result":"0x25ec61","Id":110,"Exception":null,"Status":5,"IsCanceled":false,"IsCompleted":true,"CreationOptions":0,"AsyncState":null,"IsFaulted":false}

Juan Blanco
@juanfranblanco
Jan 19 2018 15:59
you need to await the call
TarrahArshad
@TarrahArshad
Jan 19 2018 16:03
@juanfranblanco i get this 0x25ec7a
HexBigInteger
        var s = BigInteger.Parse(t.BlockNumber.Value.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier);
workfine
but this can't convert
        var s2 = BigInteger.Parse(conf.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier);
Juan Blanco
@juanfranblanco
Jan 19 2018 16:05
no
the hexbiginteger has a value
that is the value you want
t.BlockNumber.Value
TarrahArshad
@TarrahArshad
Jan 19 2018 16:06
no need convert to biginteger for calc ?
@juanfranblanco
Juan Blanco
@juanfranblanco
Jan 19 2018 16:07
no
TarrahArshad
@TarrahArshad
Jan 19 2018 16:08
i get 289613727688207147
TarrahArshad
@TarrahArshad
Jan 19 2018 16:14
@juanfranblanco i get this
    [HttpGet]
    public async Task<object> GetTransaction(string address)
    {

        var web3 = new Web3(networkAddress);

        var t = await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(address);


        var conf =await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();// - t.BlockNumber;


        return t.Value - conf.Value;               


    }
this is my code but how to know confirmation count ?
32629 block confirmations
this is on etherscan
TarrahArshad
@TarrahArshad
Jan 19 2018 16:20
@juanfranblanco ?
Juan Blanco
@juanfranblanco
Jan 19 2018 16:25
that is your confirmation count
TarrahArshad
@TarrahArshad
Jan 19 2018 16:32
this 289613727688207147 ?
but this big number and in ether scan i see 32629 block confirmations
@juanfranblanco
@juanfranblanco
this 289613727688207147 ?
but this big number and in ether scan i see 32629 block confirmations
Juan Blanco
@juanfranblanco
Jan 19 2018 16:33
you have to reverse your substraction
you want to know
also you are substracting the transaction?
Value?
TarrahArshad
@TarrahArshad
Jan 19 2018 16:34
@juanfranblanco yes see top my code
Juan Blanco
@juanfranblanco
Jan 19 2018 16:35
it is wrong
TarrahArshad
@TarrahArshad
Jan 19 2018 16:35
@juanfranblanco so ?
Juan Blanco
@juanfranblanco
Jan 19 2018 16:35
mainly based on your code
conf.Value - t.BlockNumber.Value
did you read any of the stuff i send?
TarrahArshad
@TarrahArshad
Jan 19 2018 16:37
yes
Juan Blanco
@juanfranblanco
Jan 19 2018 16:37
cool
well the value
in a transaction is not the blocknumber
TarrahArshad
@TarrahArshad
Jan 19 2018 16:39
good
@juanfranblanco workfine now
thank u
Juan Blanco
@juanfranblanco
Jan 19 2018 16:41
well done
TarrahArshad
@TarrahArshad
Jan 19 2018 16:42
@juanfranblanco normally how much confirm is safe for show to user confimed transaction ?
Juan Blanco
@juanfranblanco
Jan 19 2018 16:42
good question, it all depends
She Jong Shon
@kkagill
Jan 19 2018 17:29

@juanfranblanco Hi Juan, too bad you skipped my questions. But

var result = await multiplyFunction.CallAsync<int>(7);

still returns 0 instead of 49. abi & byteCode copied from yours and all the other lines are working fine. What would be the problem?

Juan Blanco
@juanfranblanco
Jan 19 2018 17:31
sorry mate, it happens sometimes as i try to respond questions in batches to remain productive :)
can you verify that the smart contract was deployed correctly by checking
web3.Eth.GetCode.SendRequestAsync("smartcontrataddress")
She Jong Shon
@kkagill
Jan 19 2018 17:32
gotcha i'll try thanks juan
Juan Blanco
@juanfranblanco
Jan 19 2018 17:32
if it returns "0x"
it means that it did not deployed
correctly
also try running this workbook as the code is more upto date
She Jong Shon
@kkagill
Jan 19 2018 17:34
i'm supposed to try that with geth console right?
Juan Blanco
@juanfranblanco
Jan 19 2018 17:35
ah the code i send you is for Nethereum
She Jong Shon
@kkagill
Jan 19 2018 17:35
ok
Juan Blanco
@juanfranblanco
Jan 19 2018 17:35
in the console is web3.eth.getCode
She Jong Shon
@kkagill
Jan 19 2018 17:37
image.png
this is what it returns
image.png
and the geth console
She Jong Shon
@kkagill
Jan 19 2018 17:44

If I add a line

var testResult = test.Result;

then I get 0x606060405260043610603e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631df4f14481146043575b600080fd5b3415604d57600080fd5b60566004356068565b60405190815260200160405180910390f35b506000905600a165627a7a72305820b5f50780088314a911e350ceb893b82d6201da10f5399de0d35b8597dbf3296f0029

Juan Blanco
@juanfranblanco
Jan 19 2018 17:56
ah yea that helps
it is async
She Jong Shon
@kkagill
Jan 19 2018 17:58
juan i got 49
Juan Blanco
@juanfranblanco
Jan 19 2018 17:58
ah cool :)
She Jong Shon
@kkagill
Jan 19 2018 17:58
thanks for your help
Juan Blanco
@juanfranblanco
Jan 19 2018 18:00
nb
Mariano Conti
@nanexcool
Jan 19 2018 22:51
@juanfranblanco is there a way to read an account file (.json) like the ones from Geth/Parity and unlock with passphrase or do you have to use private keys?
kai
@kaista82_twitter
Jan 19 2018 23:26
You can account.loadfromfile