1
私は頑強ではなく、簡単なコードで経験しています。 基本的には、契約内にデータを永続的に格納する構造体を作成したいだけです。ドキュメントによると、私はstorage
が必要です。 しかし、代わりにmemory
を使用する場合を除いて、次のコードはコンパイルされません。どうして?高密度ストレージ構造体はコンパイルされていません
pragma solidity ^0.4.11;
contract test {
struct Selling {
address addr;
string name;
uint price;
}
mapping(string => Selling) selling;
function sellName() constant returns (bool ok)
{
address a = 0x4c3032756d5884D4cAeb2F1eba52cDb79235C2CA;
Selling storage myStruct = Selling(a,"hey",12);
}
}
私が手にエラーがこれです:あなたが最初myStruct
インスタンスを作成するとき
ERROR:
browser/test.sol:16:9: TypeError: Type struct test.Selling memory is not implicitly convertible to expected type struct test.Selling storage pointer.
Selling storage myStruct = Selling(a,"hey",12);
^--------------------------------------------^