Hot answers tagged

5 votes
Accepted

Why does smartpy use sp.for/sp.while instead of the default loops provided by python?

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-...
FFF's user avatar
  • 3,260
5 votes

Creating public key hash

Try https://github.com/murbard/pytezos/blob/master/pytezos/crypto.py from pytezos.crypto import Key key = Key(key='mnemonic', passphrase='******', email='[email protected]') key.public_key_hash() >>&...
Michael Zaikin's user avatar
5 votes
Accepted

How do I base58 encode the chain ID using Python?

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\...
cayblood's user avatar
  • 298
4 votes
Accepted

Pytezos: structuring call for FA2

As @Groxan pointed out, update_operators entrypoint expects a list: add_op = token.update_operators([{ "add_operator": { "owner": 'tz1...', "operator":...
Michael Zaikin's user avatar
4 votes

How do I base58 encode the chain ID using Python?

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 ...
Stephen Andrews's user avatar
3 votes
Accepted

Unable to get consistent tz2 (secp256pk1) signature

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 ...
Tom's user avatar
  • 2,506
2 votes
Accepted

How to total smartpy.TMutez type stored as values in smartpy.bigmap?

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 ...
arvidj's user avatar
  • 2,378
2 votes
Accepted

How to connect to sandboxed server with pytezos?

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:...
jpic's user avatar
  • 207
2 votes

How to connect to sandboxed server with pytezos?

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:...
Arthur B's user avatar
  • 4,599
2 votes

Unable to get consistent tz2 (secp256pk1) signature

Not a direct answer, but workaround python-ecdsa lib generates non-deterministic signatures by default (see more at https://www.rfc-editor.org/rfc/rfc6979#section-3.2). Each time you run your code you ...
Michael Zaikin's user avatar
2 votes

Can inject operation but can't preapply operation, returns 400

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.
Stephen Andrews's user avatar
2 votes

How do I base58 encode the chain ID using Python?

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): ...
Michael Zaikin's user avatar
2 votes
Accepted

How to compare a mutez value with int in smartpy

It seems like SmartPy type inference doesn't auto-cast 0 to mutez. We need to do the following: sp.amount > sp.mutez(0)
Chiptus's user avatar
  • 141
2 votes

Pytezos for originating contracts

You can get the contract script and use it for the origination: kolibri_oven = pytezos.using('mainnet').contract('KT1KH3wH4sneEevPVW7AACiVKMjhTvmXLSK6') initial_storage = {} pytezos.origination(script ...
dmirg's user avatar
  • 442
2 votes
Accepted

Gas Exhausted error

I think this is an estimation bug on pytezos side, which only seems to happen for transactions without parameters. Try the following: <...>.transaction( destination=targetAddr, amount=...
Rodrigo Quelhas's user avatar
2 votes
Accepted

How can I connect to the kathmandunet in pytezos?

Have a look at the example bellow: from pytezos import pytezos pytezos_client = pytezos.using(shell='https://rpc.kathmandunet.teztnets.xyz')
Rodrigo Quelhas's user avatar
1 vote

Url error in smartpy

You can use sp.io.import_template("fa2_lib.py").
Jordan_tez's user avatar
  • 1,055
1 vote

Using Pytezos to Properly call a smart contract with correct parameters ( to purchase token from objkt )

Your destination contract doesn't seem to have a fulfill_ask entrypoint. https://tzkt.io/KT1KXXZ758wtyf2NBjWKPeXugDh5Mm7kyckw/entrypoints And according to betterCallDev, there is no deployed Tezos ...
iguerNL's user avatar
  • 1,141
1 vote
Accepted

How to validate a tezos address either it's valid or invalid?

Please use the pyTezos documentation search feature
Simon McLoughlin's user avatar
  • 1,047
1 vote
Accepted

how to find the balance in pytezos

You can query the node to know if an implicit account tz{1,2,3}* is revealed or not. Examples Revealed Account: https://mainnet.api.tez.ie/chains/main/blocks/head/context/contracts/...
Rodrigo Quelhas's user avatar
1 vote

How to create an address of tezos by using pytezos?

pytezos.using expects a private key as key parameter. In the example above you are providing the public key hash, which is incorrect. :param key: base58 encoded key, path to the faucet file, faucet ...
Rodrigo Quelhas's user avatar
1 vote
Accepted

How to use the pytezos.crypto.encoding.base58_encode function?

Try the following: from pytezos.crypto.key import Key pk = Key.from_encoded_key('edpkvFujbm3Xiamfxceg4GbsUBHzvqLZQmZvddg7xcFFvFQBEjeHTp')
Rodrigo Quelhas's user avatar
1 vote

Getting error in cryptobot smart contract. [What fix is required ?? ]

I hope you found an answer before the one I'm giving you. I fixed 3 things: # Line 41: data_type = sp.TRecord(powerup = sp.TString, cryptobot_contract = sp.TContract(sp.TRecord(power = sp.TString, ...
Jordan_tez's user avatar
  • 1,055
1 vote

Buying NFT's on objkt.com using Pytezos

The contract you're originating is the tezzard's FA2 contract. This contract is where NFT's data is stored, and where ownership of the NFTs is recorded (the ledger). This contract does not handle the ...
Aharon Lando's user avatar
1 vote
Accepted

my tezos oracles docker image (tqtezos/oracle-stock-ticker) is unable to find activation code via faucet file

The secret field was changed to activation_code when the faucets moved from https://faucet.tezos.com to https://teztnets.xyz. Try to open a ticket in their repository: https://github.com/tqtezos/...
Rodrigo Quelhas's user avatar
1 vote

Tezos for Python

PyTezos and SmartPy allow you to write smart contracts in Python, which is then transpiled into Michelson (the native language of Tezos). You then need to use the tezos-client to deploy this Michelson ...
utdrmac's user avatar
  • 3,422
1 vote

How to total smartpy.TMutez type stored as values in smartpy.bigmap?

@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 ...
FFF's user avatar
  • 3,260

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