aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-09-27 01:43:16 +0800
committerGitHub <noreply@github.com>2018-09-27 01:43:16 +0800
commit2a392aa8f9cdc8e01951360d9265b7ef4c5ccf4f (patch)
tree7ddd8726aa4221a2c257ddd3163ede96919e6b83 /docs
parentaa6fefc9a95243f1588cf8f99c81e82f00ce510d (diff)
parent754431caf630fd34d4ba4f56f83426779af94269 (diff)
downloaddexon-solidity-2a392aa8f9cdc8e01951360d9265b7ef4c5ccf4f.tar.gz
dexon-solidity-2a392aa8f9cdc8e01951360d9265b7ef4c5ccf4f.tar.zst
dexon-solidity-2a392aa8f9cdc8e01951360d9265b7ef4c5ccf4f.zip
Merge pull request #5085 from ethereum/updatefaq
[DOCS] Update FAQ
Diffstat (limited to 'docs')
-rw-r--r--docs/frequently-asked-questions.rst28
1 files changed, 16 insertions, 12 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index 7b7dd0b0..a474f905 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -43,17 +43,11 @@ Can you return an array or a ``string`` from a solidity function call?
Yes. See `array_receiver_and_returner.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/60_array_receiver_and_returner.sol>`_.
-What is problematic, though, is returning any variably-sized data (e.g. a
-variably-sized array like ``uint[]``) from a function **called from within Solidity**.
-This is a limitation of the EVM and will be solved with the next protocol update.
-
-Returning variably-sized data as part of an external transaction or call is fine.
-
Is it possible to in-line initialize an array like so: ``string[] myarray = ["a", "b"];``
=========================================================================================
Yes. However it should be noted that this currently only works with statically sized memory arrays. You can even create an inline memory
-array in the return statement. Pretty cool, huh?
+array in the return statement.
Example::
@@ -70,7 +64,7 @@ Example::
Can a contract function return a ``struct``?
============================================
-Yes, but only in ``internal`` function calls.
+Yes, but only in ``internal`` function calls or if ``pragma experimental "ABIEncoderV2";`` is used.
If I return an ``enum``, I only get integer values in web3.js. How to get the named values?
===========================================================================================
@@ -145,7 +139,17 @@ you should always convert it to a ``bytes`` first::
Can I concatenate two strings?
==============================
-You have to do it manually for now.
+Yes, you can use ``abi.encodePacked``::
+
+ pragma solidity >=0.4.0 <0.6.0;
+
+ library ConcatHelper {
+ function concat(bytes memory a, bytes memory b)
+ internal pure returns (bytes memory) {
+ return abi.encodePacked(a, b);
+ }
+ }
+
Why is the low-level function ``.call()`` less favorable than instantiating a contract with a variable (``ContractB b;``) and executing its functions (``b.doSomething();``)?
=============================================================================================================================================================================
@@ -299,8 +303,8 @@ In this example::
Can a contract function accept a two-dimensional array?
=======================================================
-This is not yet implemented for external calls and dynamic arrays -
-you can only use one level of dynamic arrays.
+If you want to pass two-dimensional arrays across non-internal functions,
+you most likely need to use ``pragma experimental "ABIEncoderV2";``.
What is the relationship between ``bytes32`` and ``string``? Why is it that ``bytes32 somevar = "stringliteral";`` works and what does the saved 32-byte hex value mean?
========================================================================================================================================================================
@@ -401,7 +405,7 @@ case in C or Java).
Is it possible to return an array of strings (``string[]``) from a Solidity function?
=====================================================================================
-Not yet, as this requires two levels of dynamic arrays (``string`` is a dynamic array itself).
+Only when ``pragma experimental "ABIEncoderV2";`` is used.
What does the following strange check do in the Custom Token contract?
======================================================================