These are chat archives for Nethereum/Nethereum

3rd
May 2016
Juan Blanco
@juanfranblanco
May 03 2016 05:00
if you can show us the contract you are publishing we might be able to give you some pointers
rickzanux
@rickzanux
May 03 2016 07:19

contract Vivnot {
address owner;

function Vivnot(){
    owner = msg.sender; 
}

// In case you sent funds by accident
function empty(){
 uint256 balance = address(this).balance;
 address(owner).send(balance);
}

function newDocument(bytes32 hash) returns (bool success){
    if (documentExists(hash)) {
        success = false;
    }else{

        createHistory(hash, msg.sender, msg.sender);
        usedHashes[hash] = true;
        success = true;
    }
    return success;
}
function createHistory (bytes32 hash, address from, address to) internal{
        ++latestDocument;
        documentHashMap[hash] = to;
        usedHashes[hash] = true;
        history[latestDocument] = DocumentTransfer(block.number, hash, from, to);
        DocumentEvent(block.number, hash, from,to);
}

function transferDocument(bytes32 hash, address recipient) returns (bool success){
    success = false;

    if (documentExists(hash)){
        if (documentHashMap[hash] == msg.sender){
            createHistory(hash, msg.sender, recipient);
            success = true;
        }
    }

    return success;
}

function documentExists(bytes32 hash) constant returns (bool exists){
    if (usedHashes[hash]) {
        exists = true;
    }else{
        exists= false;
    }
    return exists;
}

function getDocument(uint docId) constant returns (uint blockNumber, bytes32 hash, address from, address to){
    DocumentTransfer doc = history[docId];
    blockNumber = doc.blockNumber;
    hash = doc.hash;
    from = doc.from;
    to = doc.to;
}

event DocumentEvent (uint blockNumber, bytes32 indexed hash, address indexed from, address indexed to);

struct DocumentTransfer {
    uint blockNumber;
    bytes32 hash;
    address from;
    address to;
}

function getLatest() constant returns (uint latest){
    return latestDocument;
}

uint latestDocument;

mapping(uint => DocumentTransfer) public history;
mapping(bytes32 => bool) public usedHashes;
mapping(bytes32 => address) public documentHashMap;

}

thanks
Juan Blanco
@juanfranblanco
May 03 2016 07:22
on a train at the moment, so as quick thought check your event defenitiion for number of parameters, and your indexed params, and order
rickzanux
@rickzanux
May 03 2016 07:23
ok. no problem. and thanks again
i tried also with yourt contract and your code as it is and gave me the same error
Juan Blanco
@juanfranblanco
May 03 2016 07:27
put your indexed parameters at the beginning
are you passing a block number?
to create a filter?
are you testing on your own testnet?
is your contract deployed without errors?
Juan Blanco
@juanfranblanco
May 03 2016 07:34
top of my head... btw..
ill have a look tonight
rickzanux
@rickzanux
May 03 2016 07:34
testing on ky testnet
contract deployed with solidity browsr (copied by anothe rcontract....)
Juan Blanco
@juanfranblanco
May 03 2016 07:35
ok
rickzanux
@rickzanux
May 03 2016 07:35
no passing any block number
Juan Blanco
@juanfranblanco
May 03 2016 07:35
maybe you are not using enough gas
to deploy it
rickzanux
@rickzanux
May 03 2016 07:36
contract is deplyed becasue the contract.GetFilter works
geth --genesis d:/ethereumGo14/genesis.json --datadir D:/ethereumGo14/data14/ --networkid 1959 --nodiscover --maxpeers 0 --rpc --rpcaddr="localhost" --rpcport="8545" --rpccorsdomain="*" --ipcapi "admin,eth,miner,personal" --rpcapi "admin,eth,net,web3,personal,rpc,debug,miner,txpool" --etherbase "0xf60a8344760726debe222d5e07f150d19969e75d"
eth.getBalance("0xf60a8344760726debe222d5e07f150d19969e75d")
1.0756e+23
{
"nonce": "0xdeadbeefdeadbeef",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {"0xf60a8344760726debe222d5e07f150d19969e75d": {
"balance": "100000000000000000000"
}
}
}
genesis.json
        var abi = @"[{""constant"":true,""inputs"":[{""name"":"""",""type"":""bytes32""}],""name"":""documentHashMap"",""outputs"":[{""name"":"""",""type"":""address""}],""type"":""function""},{""constant"":false,""inputs"":[{""name"":""hash"",""type"":""bytes32""}],""name"":""newDocument"",""outputs"":[{""name"":""success"",""type"":""bool""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":""docId"",""type"":""uint256""}],""name"":""getDocument"",""outputs"":[{""name"":""blockNumber"",""type"":""uint256""},{""name"":""hash"",""type"":""bytes32""},{""name"":""from"",""type"":""address""},{""name"":""to"",""type"":""address""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":"""",""type"":""uint256""}],""name"":""history"",""outputs"":[{""name"":""blockNumber"",""type"":""uint256""},{""name"":""hash"",""type"":""bytes32""},{""name"":""from"",""type"":""address""},{""name"":""to"",""type"":""address""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":"""",""type"":""bytes32""}],""name"":""usedHashes"",""outputs"":[{""name"":"""",""type"":""bool""}],""type"":""function""},{""constant"":true,""inputs"":[],""name"":""getLatest"",""outputs"":[{""name"":""latest"",""type"":""uint256""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":""hash"",""type"":""bytes32""}],""name"":""documentExists"",""outputs"":[{""name"":""exists"",""type"":""bool""}],""type"":""function""},{""constant"":false,""inputs"":[{""name"":""hash"",""type"":""bytes32""},{""name"":""recipient"",""type"":""address""}],""name"":""transferDocument"",""outputs"":[{""name"":""success"",""type"":""bool""}],""type"":""function""},{""constant"":false,""inputs"":[],""name"":""empty"",""outputs"":[],""type"":""function""},{""inputs"":[],""type"":""constructor""},{""anonymous"":false,""inputs"":[{""indexed"":false,""name"":""blockNumber"",""type"":""uint256""},{""indexed"":true,""name"":""hash"",""type"":""bytes32""},{""indexed"":true,""name"":""from"",""type"":""address""},{""indexed"":true,""name"":""to"",""type"":""address""}],""name"":""DocumentEvent"",""type"":""event""}]";

        var contractAddress = "0x0148c5453ee93a64bcba21f7b83bd701f344d008";

        var contract = eth.GetContract(abi, contractAddress);

        var docEvent = contract.GetEvent("DocumentEvent");

        var filterAllContract = await contract.CreateFilterAsync();


        var filterDocEvent = await docEvent.CreateFilterAsync();
rickzanux
@rickzanux
May 03 2016 07:41
the first filter works. the second give all that errors
Juan Blanco
@juanfranblanco
May 03 2016 07:48
redeploy the contract again and in the transaction receipt, check how much gas it has been used and the code of the contract
(connection keeps dropping)
Juan Blanco
@juanfranblanco
May 03 2016 07:53
^^^ that is my mobile connection btw nothing to do with Ethereum
you might be able to create a filter on an address (contract), but your issue might be when trying to access an event from the contract if not deployed correctly that will fail. (there is no bytecode)
rickzanux
@rickzanux
May 03 2016 08:03
ok. but this happen also with multiply contract
Juan Blanco
@juanfranblanco
May 03 2016 08:03
what version of geth are you using?
can you call multiply?
(just checking your setup now)
rickzanux
@rickzanux
May 03 2016 08:04
version: {
api: "0.15.3",
ethereum: "0x3f",
network: "1959",
node: "Geth/v1.5.0-unstable-0f722df2/windows/go1.6.1",
yes the contract multiply behave in the same way: the not-conmtract filter give error
did you download the latest stable from here ^^^
rickzanux
@rickzanux
May 03 2016 08:14
ok. i try with that one asap
rickzanux
@rickzanux
May 03 2016 08:25
ok. now is opwrking but giving an empty logs
this is the only way to have back the result form a transaction, right?
Juan Blanco
@juanfranblanco
May 03 2016 08:25
yes
rickzanux
@rickzanux
May 03 2016 08:25
var docEvent = contract.GetEvent("DocumentEvent");
var filterDocEvent = await docEvent.CreateFilterAsync();
r eventLogsAll = await docEvent.GetFilterChanges<EventDoc>(filterDocEvent);
var eventLogsAll = await docEvent.GetFilterChanges<EventDoc>(filterDocEvent);
Juan Blanco
@juanfranblanco
May 03 2016 08:27
cool
but have you send something?
rickzanux
@rickzanux
May 03 2016 08:27
yes
var multiplyFunction = contract.GetFunction("newDocument");
          resultUA = await web3.Personal.UnlockAccount.SendRequestAsync("0xf60a8344760726debe222d5e07f150d19969e75d", "uno due tre", new HexBigInteger(600));
        var transaction69 = await multiplyFunction.SendTransactionAsync(addressFrom, "hashhashhash" + DateTime.Now.Millisecond.ToString());
make hash in this way so basically is almos always different. if it is equal dont write in the data
Juan Blanco
@juanfranblanco
May 03 2016 08:28
and is mined... and the filter is created before sending it
u are using getFilterChanges
so those are changes since you created the filter
rickzanux
@rickzanux
May 03 2016 08:29
this is the wait for the mining (everythiong copied from you ;)
Nethereum.RPC.Eth.DTOs.TransactionReceipt receiptTransaction = null;
            while (receiptTransaction == null)
            {
                await Task.Delay(5000);
                receiptTransaction = await transactions.GetTransactionReceipt.SendRequestAsync(transaction69);


            }
        var tLogs = receiptTransaction.Logs;
Juan Blanco
@juanfranblanco
May 03 2016 08:30
k
rickzanux
@rickzanux
May 03 2016 08:32
var abi = @"[{""constant"":true,""inputs"":[{""name"":"""",""type"":""bytes32""}],""name"":""documentHashMap"",""outputs"":[{""name"":"""",""type"":""address""}],""type"":""function""},{""constant"":false,""inputs"":[{""name"":""hash"",""type"":""bytes32""}],""name"":""newDocument"",""outputs"":[{""name"":""success"",""type"":""bool""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":""docId"",""type"":""uint256""}],""name"":""getDocument"",""outputs"":[{""name"":""blockNumber"",""type"":""uint256""},{""name"":""hash"",""type"":""bytes32""},{""name"":""from"",""type"":""address""},{""name"":""to"",""type"":""address""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":"""",""type"":""uint256""}],""name"":""history"",""outputs"":[{""name"":""blockNumber"",""type"":""uint256""},{""name"":""hash"",""type"":""bytes32""},{""name"":""from"",""type"":""address""},{""name"":""to"",""type"":""address""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":"""",""type"":""bytes32""}],""name"":""usedHashes"",""outputs"":[{""name"":"""",""type"":""bool""}],""type"":""function""},{""constant"":true,""inputs"":[],""name"":""getLatest"",""outputs"":[{""name"":""latest"",""type"":""uint256""}],""type"":""function""},{""constant"":true,""inputs"":[{""name"":""hash"",""type"":""bytes32""}],""name"":""documentExists"",""outputs"":[{""name"":""exists"",""type"":""bool""}],""type"":""function""},{""constant"":false,""inputs"":[{""name"":""hash"",""type"":""bytes32""},{""name"":""recipient"",""type"":""address""}],""name"":""transferDocument"",""outputs"":[{""name"":""success"",""type"":""bool""}],""type"":""function""},{""constant"":false,""inputs"":[],""name"":""empty"",""outputs"":[],""type"":""function""},{""inputs"":[],""type"":""constructor""},{""anonymous"":false,""inputs"":[{""indexed"":false,""name"":""blockNumber"",""type"":""uint256""},{""indexed"":true,""name"":""hash"",""type"":""bytes32""},{""indexed"":true,""name"":""from"",""type"":""address""},{""indexed"":true,""name"":""to"",""type"":""address""}],""name"":""DocumentEvent"",""type"":""event""}]";
        var contractAddress = "0x0148c5453ee93a64bcba21f7b83bd701f344d008";

        var contract = eth.GetContract(abi, contractAddress);

        var docEvent = contract.GetEvent("DocumentEvent");
        var filterDocEvent = await docEvent.CreateFilterAsync();
          var multiplyFunction = contract.GetFunction("newDocument");

          resultUA = await web3.Personal.UnlockAccount.SendRequestAsync("0xf60a8344760726debe222d5e07f150d19969e75d", "uno due tre", new HexBigInteger(600));
        var transaction69 = await multiplyFunction.SendTransactionAsync(addressFrom, "hashhashhash" + DateTime.Now.Millisecond.ToString());
         Nethereum.RPC.Eth.DTOs.TransactionReceipt receiptTransaction = null;

            while (receiptTransaction == null)
            {
                await Task.Delay(5000);
                receiptTransaction = await transactions.GetTransactionReceipt.SendRequestAsync(transaction69);


            }
        var tLogs = receiptTransaction.Logs
         var eventLogsAll = await docEvent.GetFilterChanges<EventDoc>(filterDocEvent);
so this is all the code in one shot
Juan Blanco
@juanfranblanco
May 03 2016 08:35
that looks good
how does it look EventDoc?
rickzanux
@rickzanux
May 03 2016 08:36
oops! where I find it?
Juan Blanco
@juanfranblanco
May 03 2016 08:37
your typed class
for the event
rickzanux
@rickzanux
May 03 2016 08:37
public class EventDoc
{
[Parameter("uint", "blockNumber", 1, true)]
public int BlockNumber { get; set; }
            [Parameter("bytes32", "hash", 2, true)]
            public string  Hash { get; set; }

            [Parameter("address", "from", 3, false)]
            public string IndexedFrom { get; set; }


            [Parameter("address", "to", 4, false)]
            public string IndexedTo { get; set; }

        }
Juan Blanco
@juanfranblanco
May 03 2016 08:38
your indexing does not match the contract
rickzanux
@rickzanux
May 03 2016 08:39
what do i have to change?
Juan Blanco
@juanfranblanco
May 03 2016 08:40
look at the contract above and the parameters and indexed
rickzanux
@rickzanux
May 03 2016 08:41
sorry but i dont see it
Juan Blanco
@juanfranblanco
May 03 2016 08:41
in your contract
rickzanux
@rickzanux
May 03 2016 08:42
event DocumentEvent (uint blockNumber, bytes32 indexed hash, address indexed from, address indexed to);
see four fields as in EventDoc
Juan Blanco
@juanfranblanco
May 03 2016 08:48
indexed flag does not macth does it?
rickzanux
@rickzanux
May 03 2016 08:49
please tell me what is wrong and how to fix it. Never arrived to use events til now
Juan Blanco
@juanfranblanco
May 03 2016 08:50
my connection keeps dropping
rickzanux
@rickzanux
May 03 2016 08:50
ok
no problem
Juan Blanco
@juanfranblanco
May 03 2016 08:50
either way you should have a result with your log and error decoding
rickzanux
@rickzanux
May 03 2016 08:51
tried also that but always 0 logs : var xxx = await docEvent.GetAllChanges<EventDoc>(filterDocEvent);
Juan Blanco
@juanfranblanco
May 03 2016 08:52
ok now go back to deployment, can you tripple check your contract is deployed
correctly?
redeploy it again
rickzanux
@rickzanux
May 03 2016 08:53
just done
blob
Juan Blanco
@juanfranblanco
May 03 2016 08:54
yes but.. can you inspect the transaction receipt and validate if you have some gas used and code deployed?
rickzanux
@rickzanux
May 03 2016 08:54
just that
blob
and now I reexceute the transation
Juan Blanco
@juanfranblanco
May 03 2016 08:56
can you deploy it using code?
as in .net / javascript
rickzanux
@rickzanux
May 03 2016 08:56
blob
Juan Blanco
@juanfranblanco
May 03 2016 08:56
and check your receipt
rickzanux
@rickzanux
May 03 2016 08:56
this is the receipt
just executed
Juan Blanco
@juanfranblanco
May 03 2016 08:57
cool
now use that contract :)
rickzanux
@rickzanux
May 03 2016 08:57
thsi is the reciept of using the contract with the trnasactyion
rickzanux
@rickzanux
May 03 2016 09:04
redone everything: deply contract and used with transaction with code. nothing change
Juan Blanco
@juanfranblanco
May 03 2016 09:05
im back could not connect
right you have deployed the contract now using .net
rickzanux
@rickzanux
May 03 2016 09:06
deployed and used uding net
Juan Blanco
@juanfranblanco
May 03 2016 09:06
as opposed the solidity compiler
rickzanux
@rickzanux
May 03 2016 09:06
yes
usgin bytecode and ABI from the compiler-browser
Juan Blanco
@juanfranblanco
May 03 2016 09:06
yes that is fine :)
so when deploying it did you inspect the receipt?
you should have a contract address
gas used > 0
and you should be able to get the contract code
rickzanux
@rickzanux
May 03 2016 09:08
this is the receipt of deplycontract
blob
this is the last part of the ABI about the event: it is right ? {"anonymous":false,"inputs":[{"indexed":false,"name":"blockNumber","type":"uint256"},{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"}],"name":"DocumentEvent","type":"event"}]
y esto es el receipt de la trransaction
blob
Juan Blanco
@juanfranblanco
May 03 2016 09:15
en espanol ?
rickzanux
@rickzanux
May 03 2016 09:16
sorry. living in barcelona and i'm speaking with other guys here
and im italian. so sometimes i make a mix
Juan Blanco
@juanfranblanco
May 03 2016 09:17
nada, no te preocupes.. don't worry
Juan Blanco
@juanfranblanco
May 03 2016 10:02
ill have a quick look tonight at the hotel at your issue... your event is not firing.. you could check if you get a return by using a call
rickzanux
@rickzanux
May 03 2016 10:02
ok. dont worry. i also making more tests
Juan Blanco
@juanfranblanco
May 03 2016 10:03
at least your setup seems fine
top of my head... as I mentioned before.. put the all the indexed parameters at the beginning, I cannot remember if you need to put them first.
as just do it as matter of pattern
rickzanux
@rickzanux
May 03 2016 10:05
ok
in the contract, yes?
Juan Blanco
@juanfranblanco
May 03 2016 10:05
yes
what happens with events
the topics are matched to indexed parameters
the rest are data items
rickzanux
@rickzanux
May 03 2016 10:07
ok
Juan Blanco
@juanfranblanco
May 03 2016 10:07
topics come first, then data
rickzanux
@rickzanux
May 03 2016 10:07
and in the contract betterto put mapping at beginning or not
Juan Blanco
@juanfranblanco
May 03 2016 10:08
well that is just like a variable so it is nicer there
rickzanux
@rickzanux
May 03 2016 10:08
ok
rickzanux
@rickzanux
May 03 2016 11:48
just you to know: i make a call to retrieve the variable of number of lastestDocs and it is always 0...... var getLastestFunctionAfter = contract.GetFunction("getLatest");
var resultGetLastestAfter = await getLastestFunctionAfter.CallAsync<int>();
I maked befor and after call the transactions newDocument.
reallyu strange
rickzanux
@rickzanux
May 03 2016 12:58
ok. it is a poblem of thje contract. i add another function that just rise the event and add 1 to the value of latewstfield and its working.....
this function function testcon(bytes32 hasht)
{
    DocumentEvent( hasht, msg.sender,msg.sender,block.number);
     ++latestDocument;
}
this works. the newDocument not
thnks for all and sorry for the lost time
Juan Blanco
@juanfranblanco
May 03 2016 13:32
:+1:
glad to help, it is good to go through all the steps / issues as I want to put them as part of the documentation.
rickzanux
@rickzanux
May 03 2016 13:36
if I can help, let me know
the simple transaction is owrking. the other one not. hav you any idea? var transaction69 = await multiplyFunction.SendTransactionAsync(addressFrom, hashInput);
there is some parameter missing?
Juan Blanco
@juanfranblanco
May 03 2016 13:40
maybe you are using the same hash as before?
rickzanux
@rickzanux
May 03 2016 13:40
no. i get a simple string and milliseconds. can be the same but probability are low
Juan Blanco
@juanfranblanco
May 03 2016 13:41
have you done a call? to validate it works?
rickzanux
@rickzanux
May 03 2016 13:41
more the simple function is working with the right hash. and I take out any test if the hash is exoistog before adding to the mapping
Juan Blanco
@juanfranblanco
May 03 2016 13:41
break it into smaller steps
rickzanux
@rickzanux
May 03 2016 13:42
now i want to go through all the instructions executing one by one (changing the function anytime) to see where it stops
Juan Blanco
@juanfranblanco
May 03 2016 13:42
you could create unit tests using dapple but that will take you a long time to setup
rickzanux
@rickzanux
May 03 2016 13:42
dont worry. i will find it now that i see that a simpler one is working
i prefer using c#diretly
Juan Blanco
@juanfranblanco
May 03 2016 13:43
k
rickzanux
@rickzanux
May 03 2016 13:43
let you know if I find something valuable
Juan Blanco
@juanfranblanco
May 03 2016 13:46
yes or what the issue is out of curiosity
either way add more gas to your call
you never know
rickzanux
@rickzanux
May 03 2016 13:51
How?
Juan Blanco
@juanfranblanco
May 03 2016 13:52
on the transaction call one of the parameters
rickzanux
@rickzanux
May 03 2016 14:16
you were right. question of gas.......
Juan Blanco
@juanfranblanco
May 03 2016 14:18
well, so it was the wrong version of geth (unstable) and gas :)
rickzanux
@rickzanux
May 03 2016 14:18
yes. he wrong version made logs not working and insufficien gas made transaction not executing.
I suspect that low gas is number one reason transactions are not executed
Juan Blanco
@juanfranblanco
May 03 2016 14:19
either way you have gone through all the possible options for something to be wrong
I suspect that low gas is number one reason transactions are not executed
^^^ correct
rickzanux
@rickzanux
May 03 2016 14:19
as somebody can say: "now I have experience!"
just for curiosity: where are you now?
Juan Blanco
@juanfranblanco
May 03 2016 14:20
I arrived to work now
UK
(work... hq)
rickzanux
@rickzanux
May 03 2016 14:21
but you are living in...?
Juan Blanco
@juanfranblanco
May 03 2016 14:21
oh I live in Newcastle but I'm from Spain
rickzanux
@rickzanux
May 03 2016 14:21
from where in Spain?
Juan Blanco
@juanfranblanco
May 03 2016 14:21
Madrid
you are in Barcelona aren't you?
rickzanux
@rickzanux
May 03 2016 14:22
ok. I ahve a cousin living in London and I'm trying to find a job there. to go with all my family
Juan Blanco
@juanfranblanco
May 03 2016 14:24
Im miles away from London... but I guess in the crypto world if you can get a job it does not matter where you live.
rickzanux
@rickzanux
May 03 2016 14:39
what im looking is for CTO. Im CTO from 15 years in startups
Juan Blanco
@juanfranblanco
May 03 2016 14:45
good luck with that ! let me know when you find something :)
rickzanux
@rickzanux
May 03 2016 15:21
of course