These are chat archives for Nethereum/Nethereum

9th
Nov 2017
Tatigo
@tatigo
Nov 09 2017 03:43
ok, so I'm using Eth.DeployContract and I get the transactionHash but when I try to get a receipt using Eth.Transactions.GetTransactionReceipt it's empty
anything I'm missing?
Juan Blanco
@juanfranblanco
Nov 09 2017 04:45
@tatigo @veikkoeeva
so what exactly you want / need ?
Picking questions from the top:
Tatigo
@tatigo
Nov 09 2017 04:46
Hey Juan, for right now I just need to deploy the contract, seems the recepit is empty. I'm not sure why.
Juan Blanco
@juanfranblanco
Nov 09 2017 04:47
Testrpc is a simulator chain (which is very fast as there is no mining consensus), so it is good for testing
Tatigo
@tatigo
Nov 09 2017 04:47
I'm using my own private network in azure
when deploying I'm getting the hash back but no receipt
Juan Blanco
@juanfranblanco
Nov 09 2017 04:48
Also geth / parity implement Proof of Authority, this is what it is used for testing and in workbooks now (this did not exists before TestRpc embedded)
PoA is also very fast, but runs in the final client
mixing all TestRpc / Geth / Parity PoA might be a normal solution
Sorry @tatigo
that is strange
mainly this indicates that your txn has not been mined, and is in the pending queue
can connected to geth and check for pending transactions?
is it mining?
(ignore the that is strange, as it happens :D)
Tatigo
@tatigo
Nov 09 2017 04:51
one sec
i'm using this in my code
this.Geth = new Web3Geth(this.RpcClient);
...
var mineResult = await this.Geth.Miner.Start.SendRequestAsync();
mineResult is false
Juan Blanco
@juanfranblanco
Nov 09 2017 04:52
ah
this actually does not indicates much now, as geth does not return true now
can you connect to the geth console?
Tatigo
@tatigo
Nov 09 2017 04:52
ok
Juan Blanco
@juanfranblanco
Nov 09 2017 04:52
mainly is easier
you can just check
eth.isMining
eth.pendingTransactions
just do eth, it returns all the info
Tatigo
@tatigo
Nov 09 2017 04:55
I'm getting mining true
Juan Blanco
@juanfranblanco
Nov 09 2017 04:55
any pending transactions?
Tatigo
@tatigo
Nov 09 2017 04:56
no
empty there
Juan Blanco
@juanfranblanco
Nov 09 2017 04:56
so it should have been mined
have you checked again?
Tatigo
@tatigo
Nov 09 2017 04:56
blob
ok, so right now I get pending transaction there
receipt is still null. should I increase the wait time maybe?
Juan Blanco
@juanfranblanco
Nov 09 2017 05:00
ah yes
you need to loop through it until mined
mainly you are waiting
there is a new method
Tatigo
@tatigo
Nov 09 2017 05:00
what if it never mined ? :)
Juan Blanco
@juanfranblanco
Nov 09 2017 05:01
then you should put Cancellation request
put a*
if you look at SendRequestAndWaitForReceiptAsync
you can pass a CancellationToken
mainly what this does
is a generic implementation of the polling process
you can replace it if you want
but that is another story
@KevinSmall that is really interesting and cool
Tatigo
@tatigo
Nov 09 2017 05:04
oh I see it in the code. ok, great, i'll try that. no not going to replace :)
Juan Blanco
@juanfranblanco
Nov 09 2017 05:04
mainly if you just call SendRequestAndWaitForReceiptAsync
or the equivelant when deploying
it should do the job for you
if you want to include more than one transaction in the block then no :)
Tatigo
@tatigo
Nov 09 2017 05:06
i just need to deploy the contract , get it's address and save it somewhere for later
Juan Blanco
@juanfranblanco
Nov 09 2017 05:06
ok
are you not creating unittests?
to me the lifecycle is very different
there is a solidity part
and there is the integration part
when you finish with the solidity
you can code generate your service
and from there create the integration tests
"Code generation using https://github.com/Nethereum/abi-code-gen, it includes currently the default template for Nethereum service, dtos generation. (Open 'contractName.json' after compilation from the bin folder. Press F1 and press Solidity: Code generate from compilation output..) Please contribute more templates."
Tatigo
@tatigo
Nov 09 2017 05:10
yes, that what i was doing
but the thing needs to be automated later
Juan Blanco
@juanfranblanco
Nov 09 2017 05:10
ah cool
well depends on your automation point
different streams
of work
Tatigo
@tatigo
Nov 09 2017 05:10
actually I can expalin the goal, maybe I'mlooking at it all wrong..
Juan Blanco
@juanfranblanco
Nov 09 2017 05:11
i assume you are looking for a ci perspective
Tatigo
@tatigo
Nov 09 2017 05:11
so, I have companies, say lisence providers
Juan Blanco
@juanfranblanco
Nov 09 2017 05:11
yes
Tatigo
@tatigo
Nov 09 2017 05:11
they will need to add the license
which contract = license
Juan Blanco
@juanfranblanco
Nov 09 2017 05:11
ok
so in that scenario
you will have only one contract bytecode
which you can deploy
when needed
and i guess this can be put in a registry too
Tatigo
@tatigo
Nov 09 2017 05:13
but each company has many lisences, so I need to change the contract names
Juan Blanco
@juanfranblanco
Nov 09 2017 05:13
but that is a constructor stuff
nothing to do with the bytecode
Tatigo
@tatigo
Nov 09 2017 05:15

pragma solidity ^0.4.11;

import './Owned.sol';
import "./CertificateUser.sol";

contract Certificate is Owned {

enum CertStatus {
    Created, 
    Active, 
    Expired, 
    Revoked
}

//Represents Certificate
struct Cert {
    uint256 certId;
    string name;
    string certContent;
    uint dateExpire;
    uint dateCreated;
    CertStatus status;
}
Cert cert;
mapping (uint256 => Cert) certificatesMap; //certId => Cert
mapping (address => uint256) certificatesByIssuerMap; //owner => certId

CertificateUser[] users;
mapping (uint256 => uint256) certificatesByUserIdMap; //userId => certId

event CertStatusChanged(address indexed certificate, CertStatus status);

//constructor - runs once upon contract creation
function Certificate(string _name, uint _certId) ownerOnly public {
    cert.name = _name;
    cert.certId = _certId;
    cert.dateCreated = now;
    cert.status = CertStatus.Created;

    certificatesMap[_certId] = cert;
    certificatesByIssuerMap[owner] = _certId;

    users.length = 0;

       CertStatusChanged(this, cert.status);
}

function addUser(uint _userId, uint _managerId, string _companyName, string _jobTitle, string _firstName, string _lastName) ownerOnly public {

    certificatesByUserIdMap[_userId] = cert.certId;

    users.push(new CertificateUser(_userId, _managerId, _companyName, _jobTitle, _firstName, _lastName)); 
}

}

Juan Blanco
@juanfranblanco
Nov 09 2017 05:15
@l-vitall you need to add more gas, you contract was not deployed succesful due to gas
@tatigo yes that is cool (quick glance)
your bytecode will be always the same
well i don't understand the onlyowned part on the constructor
Tatigo
@tatigo
Nov 09 2017 05:17
so contract = Certificate , when the certificate provider calls my API and asks to add new certificate and provides the name of it, I would rename that contract to be contract Certificate12334
and that contract will have it's own memory to maintain the users etc
Juan Blanco
@juanfranblanco
Nov 09 2017 05:18
yes sure
so you will create the contracts beforehand?
Tatigo
@tatigo
Nov 09 2017 05:18
ok, so when the rename happens, the bytecode not the same anymore right
Juan Blanco
@juanfranblanco
Nov 09 2017 05:19
no it is always the same
Tatigo
@tatigo
Nov 09 2017 05:19
really???
Juan Blanco
@juanfranblanco
Nov 09 2017 05:19
the constructor parameter
just changes the state of the contract
if you hardcode the contract name
yeah
Tatigo
@tatigo
Nov 09 2017 05:19
I thought the name of the contract will change the byte code
Juan Blanco
@juanfranblanco
Nov 09 2017 05:19
no
Tatigo
@tatigo
Nov 09 2017 05:20
so contract ABC is the same as contract DFG?
Juan Blanco
@juanfranblanco
Nov 09 2017 05:20
in your code yes
test it :)
Tatigo
@tatigo
Nov 09 2017 05:20
OMG
so what does the byte code is then?
Juan Blanco
@juanfranblanco
Nov 09 2017 05:21
the executable
and the hardcoded state
it is a class
not an instance of a class
Tatigo
@tatigo
Nov 09 2017 05:21
you just opened my eyes
Juan Blanco
@juanfranblanco
Nov 09 2017 05:21
(the bytecode part)
when you create a contract
you create an instance of that class
Tatigo
@tatigo
Nov 09 2017 05:22
so when I deploy it then it's an instance
Juan Blanco
@juanfranblanco
Nov 09 2017 05:22
yes
Tatigo
@tatigo
Nov 09 2017 05:22
so i'll get different addresses every time
Juan Blanco
@juanfranblanco
Nov 09 2017 05:23
yes
like your classes have a different pointer
and constructor parameters
Tatigo
@tatigo
Nov 09 2017 05:23
ok, so I should have a mapping table to map the cert name with the deployed contract address
Juan Blanco
@juanfranblanco
Nov 09 2017 05:23
yes
on chain that is a registry
@KevinSmall transaction processor gets all the data
and if you want all the operations for a specific contract you can repeat the execution
using tracing
Veikko Eeva
@veikkoeeva
Nov 09 2017 07:34
@juanfranblanco This is more like arranging myself again back to business, so to speak, and how to do that. Writing code with VS Code is OK and it appears compiling with it (or command line) and then reading the compiled bytecode and deploying it in a test. Would this appear to be an OK workflow?
Kevin Small
@KevinSmall
Nov 09 2017 08:44
Thanks Juan re the blockchain storage and processor. So the purpose might be for debugging? This effectively lets us replay and debug transaction processing from any point back in time. That is pretty amazing when I think about it, not many environments can do that.
l-vitall
@l-vitall
Nov 09 2017 12:52
@juanfranblanco, 08:15
"@l-vitall you need to add more gas, you contract was not deployed succesful due to gas" - I tried different values. If gas is too low then I have an error, if gas is too high then I have another error. Currently used code: var gas = new HexBigInteger(300000);
var balance = new HexBigInteger(120); var txHash = web3.Eth.DeployContract.SendRequestAsync(abi, abiCode, senderAddress, gas: gas, value: balance, values: multiplier).Result; I'm getting receipt.ContractAddress when mined
Juan Blanco
@juanfranblanco
Nov 09 2017 12:53
@veikkoeeva yes, you could add truffle to the mix to do the compilation, testing, etc
but all depends on your needs
and how many people you have on your team
ie.. smart contract developers, integration, ui, etc
@KevinSmall the vm processing (not the transaction) it allows you to "debug" well step through the different instructions that occurred when interacting with a contract.
It is not debug as such as you won't be able to edit the variables, etc
having a mapping of the different opcodes etc, to solidity allows you to examine the different values
(but that is another story)
@veikkoeeva thanks for the link, I could not got to devcon this year
Kevin Small
@KevinSmall
Nov 09 2017 12:58
I see, thanks. It is pretty amazing, being able to step through and see / replay code as it existed a day, a week, a year ago.
Juan Blanco
@juanfranblanco
Nov 09 2017 12:58
Burella is awesome with his blog posts, even if you go there, as you may miss some sessions
@KevinSmall yes true, mind blowing
it will get better and better
it is like intellitrace in visual studio but at worldwide scale :)
@l-vitall yes that is about it, too low it fails, too high it wont fit in a block
you could use EstimateGasAsync but geth for deployment is not very accurate
l-vitall
@l-vitall
Nov 09 2017 13:03
So what could be the reason I'm getting the zero result?
Juan Blanco
@juanfranblanco
Nov 09 2017 13:03
when the code has been deployed
sorry 0x
when you getCode
you either have ran out of gas
or has been a deployment error
l-vitall
@l-vitall
Nov 09 2017 13:04
is my call correct? var code = web3.Eth.GetCode.SendRequestAsync(receipt.ContractAddress).Result;
Juan Blanco
@juanfranblanco
Nov 09 2017 13:04
(ran out of gas, it is a deployment error)
yes
looks fine to me
l-vitall
@l-vitall
Nov 09 2017 13:05
I'm using the testchain, hardly it is out of gas
Juan Blanco
@juanfranblanco
Nov 09 2017 13:05
why?
you can ran out of gas anywhere
if you don't supply enough
l-vitall
@l-vitall
Nov 09 2017 13:05
Every time it is started it clears the state
Juan Blanco
@juanfranblanco
Nov 09 2017 13:05
and
that is nothing to do with the amount of Ether you have
l-vitall
@l-vitall
Nov 09 2017 13:06
ok, should these values be enough? var gas = new HexBigInteger(300000);
var balance = new HexBigInteger(120);
i guess so
there is plenty gas there
l-vitall
@l-vitall
Nov 09 2017 13:09
thanks for link. Other question: should it be enough to have only the Nethereum.Web3 nuget package referenced? I saw more references in old youtube example
Juan Blanco
@juanfranblanco
Nov 09 2017 13:10
yes, that pulls down all the other ones
l-vitall
@l-vitall
Nov 09 2017 13:11
also, I have no Miner.Start() code like it is in video because testnet seems to have miner already started. Is it correct?
Juan Blanco
@juanfranblanco
Nov 09 2017 13:12
yes, now the miner is part of Nethereum.Geth
as it is specific to Geth
but if your miner has started already, don't use it
you don't really need to in a real environment
l-vitall
@l-vitall
Nov 09 2017 13:14
I see.. it is strange why it is not working then.
Juan Blanco
@juanfranblanco
Nov 09 2017 13:15
if you got a transaction receipt
it has been mined anyway
check your solidity code
it might have errored
l-vitall
@l-vitall
Nov 09 2017 13:15
ok, I'll check it again, thanks
Juan Blanco
@juanfranblanco
Nov 09 2017 13:15
check on remix
do you have any initialisation code in the constructor
any parameters?
l-vitall
@l-vitall
Nov 09 2017 13:17
ok. By the way, Visual Studio Code writes this: "gasEstimates": {
"creation": [
20134,
37400
] Can I use it to estimate gas required for contract deployment?
yes, single ctor parameter like in video.
Juan Blanco
@juanfranblanco
Nov 09 2017 13:18
no those parameters don't match the whole transaction
i mean the gas parameters
l-vitall
@l-vitall
Nov 09 2017 13:18
I see
l-vitall
@l-vitall
Nov 09 2017 14:08
I tested code from Nethereum.Tutorials\Deployment\Deployment.cs and it worked! After that I compiled the same contract from example in my Visual Studio Code and it stopped working, I'm having 0 again. I compared abi and bytecode from example with my ones for the same contract and found that they are very different. Must be this is the reason of my issue. How can I make it work?
Tatigo
@tatigo
Nov 09 2017 19:19
Are there any examples on how to deploy cotract with params? I'm having trouble with that
Tatigo
@tatigo
Nov 09 2017 19:23
yee all the examples are with 1 integer param
Juan Blanco
@juanfranblanco
Nov 09 2017 19:23
you can have many
including an address, etc
Tatigo
@tatigo
Nov 09 2017 19:23
something is not right there, getting convertion errors
is there example how to map c# to sol ?
Juan Blanco
@juanfranblanco
Nov 09 2017 19:24
use named params, it might be an issue
Tatigo
@tatigo
Nov 09 2017 19:24
ok, will try
Juan Blanco
@juanfranblanco
Nov 09 2017 19:24
what at abi level?
you can use cqs or function message
Tatigo
@tatigo
Nov 09 2017 19:25
cqs?
Tatigo
@tatigo
Nov 09 2017 19:27
thanks
Juan Blanco
@juanfranblanco
Nov 09 2017 19:28
:)
ill be creating generators for cqs soon
i think it is much simpler to work with messages
dtos
as they are easier to upgrade
and separate concerns for the whole contract
Tatigo
@tatigo
Nov 09 2017 19:52
can i do deployment in 2 steps? getting the hash first. then when needed asking for the receipt with that hash?
I don't want to wait till the pending transaction is processed
Juan Blanco
@juanfranblanco
Nov 09 2017 19:52
yes
of course
specially if you want to send more than one transaction at a time