Storage Operation

Introduction of storage

Each smart contract can store query status data in the blockchain,this function is called storage

In a contract API function,you can use to retrieve storage objects for the current contract,the loaded contract of import_contract,forbid read and write to storage directly

Storage objects can be similar to table operations,read the properties,write attributes,but only one layer of table can be nested,and if storage [a property name] is a certain type,Changing the value of this property can only be changed to the same type of value, if the value of storage [some attribute name] is table,This table has the same type of value for different attributes, such as integers or strings。

Modifications to storage will not be submitted immediately,only when the current lua stack is closed.If there are no errors, the changes to storage are submitted automatically (only the changes are submitted instead of the storage itself)

The basic data type of storage

The types of each attribute in storage can use types,such as int, number, bool, string, Stream, Map<int>, Map<number>, Map<bool>, Map<string>, Map<Stream>, Array<int>, Array<number>, Array<bool>, Array<string>, Array<Stream>

storage operation,such as: = "hi" = 123 = 456 -- error,Types can't change
let abc = -- right,Read the storage property value = {name: "hi", age: 2} -- error,The type of attribute value for the nested table need keep consistent = {name: {name: "hi"}} -- error,Multi-tier table is not allowed in storage = {name: "hi", age: "2"} -- right