hide You are viewing an archived web page, collected at the request of Ethereum Foundation using Archive-It. This page was captured on 12:23:06 Jun 20, 2021 , and is part of the Community collection. The information on this web page may be out of date. See All versions of this archived page. Loading media information

Syntax error

randomrandom Member Posts: 4
I am following this tutorial:

I am working with go-ethereum 0.6. This is my first contract:

init {
this.store[this.origin()] = 10**20

I get the error:

Your contract could not be sent over the network: line 1: syntax error: store

What did I do wrong?


  • mids106mids106 Member Posts: 188 ✭✭✭
    I believe that in Mutan 0.4 you should be using contract.storage[tx.origin()] = 10**20
  • StephanTualStephanTual London, EnglandMember, Moderator Posts: 1,282 mod
    That's right, init is deprecated since Mutan 0.2.

    See: https://github.com/ethereum/go-ethereum/wiki/Mutan-0.4

    (in particular the note regarding changes since PoC5 RC17)
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    This adaptation of the example contract of the tutorial works for me. That is to say, it's accepted by the compiler and I can send it in a transaction:
    contract.storage[tx.origin()] = 10**20

    exit compile {
    var to = this.data[0]
    var from = tx.origin()
    var value = this.data[1]

    if contract.storage[from] > value {
    contract.storage[from] = contract.storage[from] - value
    contract.storage[to] = contract.storage[to] + value
    I get stuck at the next point in the tutorial however; retrieving the storage values from the contract with eth.getStorageAt() returns an empty string. Any suggestions welcome.
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    Just found a - presumably correct - version of the currency contract on the Mutan 0.4 examples page. The only difference there is return compile instead of exit compile. Not sure yet if that's the culprit. Testing with it now.
  • mids106mids106 Member Posts: 188 ✭✭✭
    @AronVanAmmers‌ this is the version that I can successfully compile with mutan 0.4 and can even run on pyethereum 0.2.4:
    contract.storage[tx.origin()] = 1000000

    return compile {
    var to = this.data[0]
    var from = tx.origin()
    var value = this.data[1]

    if contract.storage[from] > value {
    contract.storage[from] = contract.storage[from] - value
    contract.storage[to] = contract.storage[to] + value
    exit 1
    exit 0
    I have added the exit codes so I can do some additional testing, not really required.
  • rapidosrapidos SydneyMember Posts: 8
    Trying to run that same tutorial.
    It seems I can send the contract (at least it returns an address for it: "aeefdefa73ae6a207ca1ae52840ddf168b9b438d").

    Now when trying to query the amount initially stored (i.e. at contract.storage[tx.origin()]), it does not seem to work.

    The returned value from the callback to eth.getStorageAt seems to be empty.

    Yet, based on the following console output, I believe the call to getStorageAt went through, no?

    2014/08/13 23:07:28 wallet.qml:380: html
    2014/08/13 23:07:28 webapp.qml:43: [onMessageReceived]: {"call":"getCoinBase","_seed":692754,"args":[]}
    2014/08/13 23:07:28 webapp.qml:43: [onMessageReceived]: {"call":"getStorage","args":["aeefdefa73ae6a207ca1ae52840ddf168b9b438d","3036401729e171b4c1469871ec5303218a060938"],"_seed":422182}
    2014/08/13 23:07:28 webapp.qml:43: [onMessageReceived]: {"call":"getStorage","args":["aeefdefa73ae6a207ca1ae52840ddf168b9b438d","3036401729e171b4c1469871ec5303218a060938"],"_seed":683014}

    Any idea what did I miss?

    Actually is there some tool with a friendly GUI to query the blockchain?
    Check if the contract is there, etc...
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    Thanks @mids106‌, using that contract now. However got stuck further on the way, see post below.

    @rapidos‌ we seem to have run into the same error. In addition to that, the Go-Ethereum / Ethereal client currently fails to update the testnet blockchain.

    There is a way to explore the blockchain more elaborately, including contract storage: cpp-ethereum/AlethZero. There are releases for Mac and Win. AlethZero doesn't allow contracts in Mutan syntax however, only LLL and Serpent. The JavaScript API is also slightly different. But it should be possible to get the "currency" tutorial working with some adaptations. See the currency example contract in LLL syntax.
  • rapidosrapidos SydneyMember Posts: 8
    edited August 2014
    Thanks Aron for these pointers.

    I am indeed still stuck on the same problem (where the callback from getStorageAt returns an empty string).
    Ironically other calls seem to work fine, such as:
    which does return indeed the right amount.

    I have been trying the following, all failed (i.e. I observe the same issue):

    1. Make a build from the git/develop branch (as opposed to the master branch).
    2. To avoid the '25531 block error' on testnet, I did run my own blockchain from scratch, using also a connection to the seedless node on

    Now I'm trying to gather more clues through AlethZero (I've simply downloaded the dmg build from git releases section).

    I can have both Ethereal & AlethZero nicely talking to each other from the same machine (on OSX):
    I simply run Ethereal on a different port:
    ethereal -port 30301
    Then launch AlethZero, nuke its blockchain, connect it to peer my_own_ip:30301

    AlethZero does pick my Ethereal blockchain (the blockchain panel does list the correct blocks: same hashes).

    But I do not know how to explore the blocks, states and contracts with AlethZero. Ok, will post my AlethZero related questions on the "Cpp Implementation" category of this forum.
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    Thanks, a local setup with Ethereal/AlethZero interoperating is very useful! I'll be interested to hear about your progress.
  • heliumcraftheliumcraft Member Posts: 28
    I'm stuck with the same issue, can't query the initial amount of storage. Anyone had any luck with the issue? Should I just use Serpent & AlethZero and forget the go-ethereum client?
  • heliumcraftheliumcraft Member Posts: 28
    @AronVanAmmers‌ @rapidos‌ did you have any luck with this issue?
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    @heliumcraft‌ up to now, no. I'm in the process of building a version of Ethereal from the latest source code, but I don't have a usable version yet. I'll update when I have.

    From the current release versions, AlethZero the most usable / working in my experience. But things move fast.

    A tip about the JavaScript API: use the following code in the JavaScript console (or in your HTML file) to find the methods of the magic object eth:
    This will return a (long) JSON string with all properties and methods of eth in your current version of AlethZero (should work in Ethereal too), which you can turn into something readable by using for example JSBeautifier.
  • kharvtrankharvtran Member Posts: 12
    @AronVanAmmers: thanks for the tip, quite useful!
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    That tip works in Ethereal as well, although there it just list the function names and not the parameters.

    Example output on the current development version (0.6.5) of Ethereal:
    Example output on a recent development version (0.6.4) of AlethZero:
  • heliumcraftheliumcraft Member Posts: 28
    I found this issues:

    - document.querySelector("#currentAmount") doesn't work for me, instead do document.getElementById("currentAmount")
    - sometimes the ethereal client seems to cache the js code and doesn't reflect the code changes, changing the js filename works.

    This , plus using my own Testnet, I can get the balance.
  • AronVanAmmersAronVanAmmers Amsterdam, NetherlandsMember Posts: 40 ✭✭
    Great, thanks.

    I've found the same w.r.t. caching the JS code (from a .js file loaded with a <script> tag). What I do is add something unique as a query string after the file name, e.g.:
    <script type="text/javascript" src="myApp.js?123">
    Changing the part "123" after every change makes sure Ethereal picks up the new version.
Sign In or Register to comment.