5.3 Data Persistence

The public_data, private_data, read_list, and write_list in the previous chapter use the same context for a contract data store. Public_data can be viewed on the blockchain explorer. Specific examples of use are as follows:

function init()
    assert(chainhelper:is_owner(),'no auth')
    
    -- read data    
    read_list = {public_data={rate=true,max_bet=true}}
    chainhelper:read_chain()
    
    public_data.rate  = 98
    public_data.max_bet = 1000000 
    
    -- write data
    write_list = {public_data={rate=true,max_bet=true}}
    chainhelper:write_chain()
end

The data field should be defined via read_list each time you use it and then read the data via chainhelper:read_chain(). After the data changes, you should define the write_list and then write the data back to the chain via chainhelper:write_chain().

5.3 Data Persistence


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.