Hot answers tagged

5

Your understanding is quite correct. SmartPy is a Python library, not a Python-inspired language so we use Python everywhere and overload Python's constructions. This approach is called meta-programming and is extremely important for bigger templates. Control operators such as if, for, while cannot be overloaded in Python. So we have our own pure-python ones ...


5

Try https://github.com/murbard/pytezos/blob/master/pytezos/crypto.py from pytezos.crypto import Key key = Key(key='mnemonic', passphrase='******', email='foo@bar.com') key.public_key_hash() >>> edpk...


5

Your magicbyte seems to be wrong. If you take the decimal byte values from the original, convert them to hex, then pad it with a leading zero, you get >>> struct.unpack('>L', b'\x00\x57\x52\x00')[0] 5722624 This value should produce the expected result: >>> payload = '...


4

It looks like you are only actually grabbing 2 bytes of data (4 hex chars). I verified this by decoding the result you got, and it only returning two bytes of data for the given magic byte. Try making the following change: def get_chain_id(self): chainid = bytes.fromhex(self.payload[2:10]) return bitcoin.bin_to_b58check(chainid, magicbyte=5722583)


3

The immediate problem seems to be that you are not getting signatures in "lower S" form. This seems better: sk.sign_digest(digest, sigencode=ecdsa.util.sigencode_string_canonize) I cannot vouch for the correctness of the code generally.


2

There is no way of iterating over all values in a big_map in the language to which SmartPy compiles (Michelson). So it doesn't surprise me that this doesn't work in SmartPy either. Indeed, according the SmartPy documentation: e.values(): Returns the list of values of a map, sorted by keys. Here, I presume that map refers exclusively to normal, "simple" ...


2

Accounts are pre-created in Sandboxed mode, this shows how to find the secret keys: $ grep SECRET src/bin_client/tezos-init-sandboxed-client.sh export BOOTSTRAP1_SECRET="unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh" export BOOTSTRAP2_SECRET="unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo" export BOOTSTRAP3_SECRET="...


2

Accounts are pre-created in Sandboxed mode, this shows how to find the secret keys: $ grep SECRET src/bin_client/tezos-init-sandboxed-client.sh export BOOTSTRAP1_SECRET="unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh" export BOOTSTRAP2_SECRET="unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo" export BOOTSTRAP3_SECRET="...


2

Not a direct answer, but workaround python-ecdsa lib generates non-deterministic signatures by default (see more at https://tools.ietf.org/html/rfc6979#section-3.2). Each time you run your code you get a new result. I've experienced this issue and eventually switched to secp256k1 package (there were several extra reasons for that): https://github.com/baking-...


2

The preapply/operations endpoint requires an array of operations to be submitted. Just wrap your call around square brackets and it should work. This is how it's done in eztz.


2

First of all, many thanks! You've helped me with solving the block signature mystery :) You can use pytezos.encoding package: from pytezos.encoding import base58_encode def get_chain_id(self): chainid = bytes.fromhex(self.payload[2:10]) return base58_encode(chain_id, b'Net')


2

It seems like SmartPy type inference doesn't auto-cast 0 to mutez. We need to do the following: sp.amount > sp.mutez(0)


1

@arvidj is right of course and you cannot iterate on a bigmap. You need to keep your sum in the storage. You also have another error: if it was a map, you would still need to use a local variable to accumulate the sum. This is introduced by total = sp.newLocal('total', ...). What the error is telling you is that your v is escaping it`s scope. With 1, we ...


Only top voted, non community-wiki answers of a minimum length are eligible