Skip to content Skip to sidebar Skip to footer

Typeerror Cannot Read Property 'stdin' of Undefined Ethereum Solidity

Ane relatively clean fashion to test if a struct is initialized is to ascertain a bool in it (isSet) and set up it to true before pushing the struct to the mapping

I see. So if struct Upshot {uint id; bool processed}I could do a if (results[key].processed == false)?

no demand for the == false as it'southward a bool, just that'due south the thought

in other words - if (!results[cardinal].candy)

@yudilevi Yeah, true. Thank you!

Of course, the bool will take up infinite, so if id tin never be 0, that's a cheaper bank check.

Did anyone else notice initializing an external contract and executing one of its function is extremely expensive (relatively speaking)?

@chriseth I don't call up I'g sending ether with the creation of the contract. I'thousand just using gas: web3.eth.estimateGas({ data: bytecode })... how would I send ether? Are ether and gas the same thing? By the way, I solved my trouble by multiplying the gas guess by 10. I came on here to ask if there was whatsoever downside to doing that.

Yes, you'll finish upwards trying to transport more than than the gas limit. A much smaller margin should piece of work.

Eg, an extra 20k, or 10%, or and then - depends on your contract.

@Arachnid Okay. What happens if I send more the gas limit? Volition I lose money?

No, you'll get an immediate error that 'transaction exceeds block gas limit'

If y'all send a smaller corporeality that'south still manner more than than you need, it'll piece of work, but information technology'll likely take longer for your transaction to exist included in a cake.

I as well believe (correct me if I'm incorrect) that if the contract creation throws an exception, you lose all the gas yous sent?

Ok, breaking news: Yesterday's geth release fixes estimateGas, so you lot tin can try information technology without the extra gas.

Any idea when fixed betoken support is finally out?

Now I'm trying to understand how geth fits into my workflow. I'1000 using testrpc and web3.js, and would similar to use the new fixed estimateGas.

@Arachnid practice yous have info what the problem was ?

I'm not interested in Go per se.

@adridadou In short, estimating gas is turing complete :P

it wasn't halting after some point ?

Suppose your contract calls some other contract, passing 50k gas. The contract returns having only used 25k. If estimateGas returns the amount used, it volition return 25k, and the call will neglect - considering information technology tries to send 50k gas in the call. So y'all accept to send as much as is demanded by any nested calls, not just the corporeality actually used.

But suppose estimateGas works based on the 'low watermark'; then you have contracts that call other contracts with all of their gas (less some small amount). So when called on those contracts, estimateGas will e'er render about the amount of gas it started the estimate with.

@karalabe fixed this recently by implementing a binary search; estimateGas now runs your transaction repeatedly with dissimilar gas numbers, and returns the lowest gas amount that doesn't neglect.

Roman Mandeleil

@romanman


Guys we are looking for solidity developers
to try our new Solidity Debugger, kudos and bounties
are promised :smiling: :smile: :smile:

Dave Appleton

@DaveAppleton

@romanman you mean that y'all can save me my three days I merely wasted due to calling the wrong function? Count me in.

Mahesh Murthy

@maheshmurthy

@romanman sign me upward!

Roman Mandeleil

@romanman

@DaveAppleton @maheshmurthy mail me on roman@ether.camp
to release here

The Solidity docs imply that other contracts can write to a public variable. Is that and so?

The keyword public automatically generates a part that allows y'all to admission the current value of the state variable. Without this keyword, other contracts accept no mode to access the variable and only the code of this contract can write to it.

I'd like to know how each modifier (like public) affects whether a variable tin exist read or written to by another contract or a user. Is there something like a matrix of this information?

"access" here simply means read access

@chriseth It's the "and just the code of this contract tin write to it." fleck that I'k thinking about.

Thanks for the link. Didn't observe with search.

y'all are correct, it is misleading :-)

@chriseth how's ufixed type support coming forth?

@Arachnid Was following your advice about size of gas margin, but upwards to 30% wasn't working (no contract created in testrpc). Went up to 100% and it worked. Is something incorrect?

@willnwhite Take you lot tried the latest geth release? As I mentioned earlier, it fixes estimateGas.

@Arachnid I'm non using geth, just testrpc and web3 from node. Is geth built into truffle or something?

I guess I could just start using geth, in whatever way!

Okay, in that case you can't rely on testrpc's estimate gas :)

How much extra you need depends on what your contract does - what calls it makes, whether it specifies explicit gas, and whether it does anything that tin can cause a refund, like deleting stuff from storage.

Okay, cheers. I'll conduct on with my setup for at present at least. Is there some reading I could do about gas?

Apart from official docs.

Lefteris Karapetsas

@LefterisJP

Hey @chriseth @axic ... I've got an effect with the new manner solc v.0.4.9 format the returned json lexicon. You are at present calculation the filename:ContractName as the key to the returned json dictionary.

I accept modified the python lawmaking to be able to piece of work with that ... merely I have ii questions.

  1. Why is this being done? I can't imagine any possible situation where you would like to take multiple files with the same contract names in them. That would indicate bad naming conventions on the developer's side.
  2. What should ethereum clients similar geth do when compiling a contract completely via the console but as is shown in the greeter contract tutorial?
    https://www.ethereum.org/greeter
    The tutorial is at present broken since with solc v0.4.9. this is what solc would return: http://pastebin.com/hYGaxWc1
    Observe the <stdin>:greeter every bit central of the dictionary.

I want to call a function with a list of addresses and for the function to measure out the number of addresses in the list. I've got

                                                office                  myFunction                  (address[] addresses)                {                var                numberOfAddresses = addresses.length;   ...            

but I'm getting TypeError: Cannot read property 'length' of undefined in node. In node, addresses.length is 8.

sladevaniffew.blogspot.com

Source: https://gitter.im/ethereum/solidity?at=589332be1e4d4bd962c5f87c

Enregistrer un commentaire for "Typeerror Cannot Read Property 'stdin' of Undefined Ethereum Solidity"