This is in regard to the tutorial demonstrating a coin.
In order to work with current serpent, which, as it seems, doesn't support msg.data anymore, I changed the code to be:
def init():
self.storage[msg.sender] = 10000
def send(to, value):
to = to
from = msg.sender
value = value
if self.storage[from] >= value:
self.storage[from] = self.storage[from] - value
self.storage[to] = self.storage[to] + value
This compiles in AZ and creates the desired contract.
In order to interact with it, I used "serpent encode_abi":
serpent encode_abi 0 DEST_ADDRESS AMOUNT
It results, for example, in:
00000000000000000000000000d9dccddd414217ba5065152ef86385ea067fdc3f0000000000000000000000000000000000000000000000000000000000000078
And it works well - transfers the coin (which is evident in the javascript console:
web3.eth.stateAt(contractAddress, '0xd9dccddd414217ba5065152ef86385ea067fdc3f')
)
But, I wanted to do it all in AZ, but I can't get the same result. The following data:
0 0xd9dccddd414217ba5065152ef86385ea067fdc3f 120
produces a much larger result (many more bytes for 0 and 120), and doesn't work:
0000 ???????? 00 00 00 00 00 00 00 00
0008 ???????? 00 00 00 00 00 00 00 00
0010 ???????? 00 00 00 00 00 00 00 00
0018 ???????? 00 00 00 00 00 00 00 00
0020 ???????? 00 00 00 00 00 00 00 00
0028 ???????? 00 00 00 00 d9 dc cd dd
0030 AB??Pe?. 41 42 17 ba 50 65 15 2e
0038 ?c?????? f8 63 85 ea 06 7f dc 3f
0040 ???????? 00 00 00 00 00 00 00 00
0048 ???????? 00 00 00 00 00 00 00 00
0050 ???????? 00 00 00 00 00 00 00 00
0058 ???????x 00 00 00 00 00 00 00 78
Is there a way to produce the same as encode_abi in AZ? Is it the cause of it not working at all, because the data types are much larger?
0 ·
Comments
you use $0x01 instead of 0x01