nebulasio / wiki

This repository is out of date, please check the new wiki:
http://wiki.nebulas.io/en/latest/
GNU General Public License v3.0
421 stars 153 forks source link

Cannot use LocalContractStorage.set in smart contract. #194

Closed harryge00 closed 6 years ago

harryge00 commented 6 years ago

I have followed the tutorial https://github.com/nebulasio/wiki/blob/master/tutorials/%5B%E4%B8%AD%E6%96%87%5D%20Nebulas%20101%20-%2004%20%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6%E5%AD%98%E5%82%A8%E5%8C%BA.md#localcontractstorage and deployed the following code:

'use strict';

var SampleContract = function () {
};

SampleContract.prototype = {
    init: function () {
    },
    set: function (name, value) {
        // 存储字符串
        LocalContractStorage.set("name",name);
        // 存储数字
        LocalContractStorage.set("value", value);
        // 存储对象
        LocalContractStorage.set("obj", {name:name,value:value});
    },
    get: function () {
        var name = LocalContractStorage.get("name");
        console.log("name:"+name)
        var value = LocalContractStorage.get("value");
        console.log("value:"+value)
        var obj = LocalContractStorage.get("obj");
        console.log("obj:"+JSON.stringify(obj))
    },
    del: function () {
        var result = LocalContractStorage.del("name");
        console.log("del result:"+result)
    }
};

module.exports = SampleContract;

The contract address is n1ziQ1AnhMjm5qXxXVM7gRujW8qGRAf9PbE. And I have call set("ddd", "eee") in transaction 7d2637a48672227ab7c48d73705110aeb72f52f5f6186ba15e03f6e9d4154a48. However, when I call get, no results are returned.

harryge00 commented 6 years ago

BTW, I used web-wallet/contract.html to deploy contracts and call functions

yupnano commented 6 years ago

Apparently, there is no return statement in your get function.