How do you send a message with data into a contract in Alethzero

BluefinBluefin Member Posts: 47
Fired up Alethzero. Cut and pasted Gavin's splitter contract into the "Data" box. Submitted it as a contract creation. Everything looks ok. Now, I cannot seem to perform a "split". I believe I need to enter something into the data box, i.e., the addresses of the recipients and send it to the contract address?

Somehow I cannot get it working. Sorry, this may sound trivial, but the reality is I am a novice trying to understand how to execute a contract. Need to get past this.

A cut and paste of the data to be sent will be good.

Additionally, I am trying to understand this part in the init part of the program:

[0] "Splitter"
(call 0x929b11b8eeea00966e873a241d4b67f7540d1f38 0 0 0 8 0 0)

What exactly is it doing in calling and putting the "Splitter" into this address?



  • BluefinBluefin Member Posts: 47
    I believe there is a bug in passing the Data into the contract from Alethzero. Somehow it doesn't appear to send the data across. But then I may be wrong. If anyone can enlighten me, it would be good.
  • nickETHnickETH Member Posts: 2
    Sharing the frustrations like the above. LLL docs have great code examples but lack examples of what the corresponding transaction data looks like.
  • nickETHnickETH Member Posts: 2
    (By which I mean, what you type into to the "Data" field to send transactions to the contract).
  • BluefinBluefin Member Posts: 47
    Alethzero is definitely buggy. That's ok, it is in prelim stage. But someone of authority should at least verify this. :-(
  • JasperJasper Eindhoven, the NetherlandsMember Posts: 514 ✭✭✭
    @Bluefin? the first part ofSplitter it registers the name "Splitter" to NameReg, which is essentially like namecoin, but for contracts.(currently) Namereg is on 0x929b11b8eeea00966e873a241d4b67f7540d1f38. Ethereum premines to ensure we have those adresses and they dont change between test versions.(perhaps if you have a contract and want the address to stay the samebut it may well just be the Ether byte across test versions, you could ask them to include it in the premine) Names can only be given once, if the given one already exists, the registrar will do nothing. So since others may have submitted the splitter too, the name may be taken.

    Looks like the POC-5 LLL on the wiki doesnt explain it entirely, the first zero is the amount in ethers sent, then one of the zeros is the address of the name "Splitter" and the 8 is the number of characters; the length in bytes of the message. Not clear on what the other zeros are about.
  • mids106mids106 Member Posts: 188 ✭✭✭
    Special for you Bluefin; an EtherCasts episode on how to use (and debug) the Splitter contract!
  • BluefinBluefin Member Posts: 47
    @mids106. Thanks for the video. It has been very helpful indeed. The version of Alethzero that I am using is 0.4.2 for Windows 64Bit. My interface shows that it requires only 20 bytes instead of 32 bytes as shown on your Mac version.

    Nevertheless, I have tried both versions, i.e., 20 and 32 bytes but to no avail. I realise my Namereg as shown in the contract panel is the original one, i.e., 929b11b8eeea00966e873a241d4b67f7540d1f38.

    The log says it has "split" and sent, but the wallet doesn't show the amount.

    Thanks a lot anyway. I now get the gist of how to do it. I believe it may still be a buggy wallet for the windows version as the ethers that I mined kept disappearing and resetting itself.

    The unfortunate thing is I am just a user and not a programmer and therefore don't really know how to compile one. Guess I just have to wait a little longer for an updated version of Alethzero in Windows.
  • BluefinBluefin Member Posts: 47
    @Jasper, According to Gavin's yellow paper on the POC-5 version on the message call, this is what he wrote verbatim:

    "In the case of executing a message call, several parameters are required: sender (s), transaction originator (o), recipient (r), available gas (g), value (v) and gas price (p) together with an arbitrary length byte array, d, the
    input data of the call."

    They are not necessary called in that order. It appears that "8" may not be needed in POC-5 but instead substituted by a string of bytes starting from [0] and possibly 0x00 as the "End of Line" call.

    There is also an output message coming back from the call. I can understand gas price, but I am not so sure about the need to send available gas. s and o is the same if it is a transaction sending a value. If it is a message call from a contract initiated by the originator, s is the contract address (I think) and o is the originator who called this contract to execute the message call.

    Please correct me if I am wrong. Many parts of Gavin's paper still remain cryptic for me...:(
  • BluefinBluefin Member Posts: 47
    edited May 2014
    @mids106‌, I found the answer to the problem. This is how I changed the code:

    [0] "Red132"
    (call 0x929b11b8eeea00966e873a241d4b67f7540d1f38 0 0 0 6 0 0)
    [count] (/ (calldatasize) 32)
    [pay] (/ (callvalue) @count)

    ;; Cycle through each address
    [i] 0
    (for () (< @i @count) ()
    (call (calldataload (* @i 32)) @pay 0 0 0 0 0)
    [i]:(+ @i 1)

    Basically, I believe the Alethzero is a POC-4 version and that the for loop needs some modification. [i] increment happens at the end of the loop and I have to initialize [i] : 0 before the loop starts.

    This then works!!

    The compiler is therefore not compiling properly.

    * Note that a colon was added inadvertently in the last "[i]:(+ @i 1)". I guess this is still ok, with or without the colon, which should be the case anyway.
Sign In or Register to comment.