Is there a way to access Ethereum Smart Contract's variables by name in JavaScript?

ThePiachuThePiachu Member Posts: 16
Say I have a simple smart contract:
    contract Simple {
	    string32 message;

	    function Simple() {
            message = "Hello world!";
	    }
    }
How can I easily access the `message` variable by name in JavaScript? It looks like there is some way to map functions into JS (https://dappsforbeginners.wordpress.com/tutorials/javascript-api-2/), but variables appear to only be accessible through a complicated way (https://dappsforbeginners.wordpress.com/tutorials/javascript-api-1/):
    var storageObject = web3.eth.storageAt(contractAddress);
    document.getElementById('fullName').innerText = web3.toAscii(storageObject['0x']) + ' ' + web3.toAscii(storageObject['0x01']);

Comments

Sign In or Register to comment.