Merge pull request #447 from ethereum/Initialize_Contract_with_Wei_call

Update frequently-asked-questions.rst
This commit is contained in:
chriseth 2016-03-26 00:05:54 +01:00
commit 14d6b0b2d6

View File

@ -613,6 +613,7 @@ Note that the full code of the created contract has to be included in the creato
This also means that cyclic creations are not possible (because the contract would have
to contain its own code) - at least not in a general way.
How do you create 2-dimensional arrays?
=======================================
@ -647,6 +648,22 @@ gas and return your 20 Wei).
In the above example, the low-level function `call` is used to invoke another
contract with `p.data` as payload and `p.amount` Wei is sent with that call.
How do I initialize a contract with only a specific amount of wei?
==================================================================
Currently the approach is a little ugly, but there is little that can be done to improve it.
In the case of a `contract A` calling a new instance of `contract B`, parentheses have to be used around
`new B` because `B.value` would refer to a member of `B` called `value`.
You will need to make sure that you have both contracts aware of each other's presence.
In this example::
contract B {}
contract A {
address child;
function test() {
child = (new B).value(10)(); //construct a new B with 10 wei
}
}
Can a contract function accept a two-dimensional array?
=======================================================