Skip to content
This repository was archived by the owner on Feb 14, 2021. It is now read-only.

Add real life example in tutorial #29

@Pzixel

Description

@Pzixel

I'm currently trying to port some Solidity code into wasm using pwasm. But I have a problem that I don't see enough examples or documentation to perform such a transform. For example, here is a simple Solidity contract:

contract Example {    
    string[] values;

    function addValue(string value) public onlyOwner {
        values.push(value);
    }

    function getValue(uint i) public returns(string) {
        return values[i];
    }
	
    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }
}

it's very simple but it shows all properties that real contracts have: it has onlyOwner modifier, it works with dynamically-sized data and it push values into internal storage (which is not prealocated). Token examples are too simple and don't show how to perform such operations that are crucial for most contracts.

I'm playing with these storage_keys!/pwasm_ethereum::write and so on, but it doesn't look I'm even approaching the solution. Currently It's actually a blocker to me, without stretching storage I cannot migrate my code to wasm.


I'd appreciate any help because I'm currently stuck with that - I only see how I can write into preallocated fixed size storage, but I don't see how to dynamically increase it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions