0

I am hitting a wall trying to figure out a working proof of concept to get pytezos to "purchase" a token from objkt. I am using the following script with pytezos under the assumption that:

  1. I do this using an operation group
  2. I should use the .transaction method
  3. I need to pass the entrypoint ( in tzKT this appears to be a fulfill_ask entrypoint? ) and the additional token_id?
from pytezos import pytezos
from decimal import Decimal


# COLECT THIS TOKEN: https://objkt.com/asset/KT1KXXZ758wtyf2NBjWKPeXugDh5Mm7kyckw/2
# COLLECTIO CONTRACT: KT1KXXZ758wtyf2NBjWKPeXugDh5Mm7kyckw
# Market PLace Contract: KT1WvzYHCNBvDSdwafTHv7nJ1dWmZ8GCYuuC
# PRICE: Decimal('.01')
# CREATOR: tz2SRxyGc1SFnbAyGuWTNcRbWgZB6pyeGYqB


PRVKEY = "edsk...."
contract_address='KT1WvzYHCNBvDSdwafTHv7nJ1dWmZ8GCYuuC'
token_id=2
ask_id = 1253832

opgrp = pytezos.using( shell='mainnet', key=PRVKEY )

# best guess how to format parameters based on doc: https://pytezos.org/high_level.html#pytezos.client.PyTezosClient.transaction


opg2 = opg.transaction( destination=contract_address, 
                        amount=Decimal('.009'), 
                        fee=Decimal('.00150'), 
                        parameters  = { "entrypoint": 'fulfill_ask', 
                                        "value": '(Pair ask_id {})'.format(ask_id) })  


opgrp2 = opgrp2.fill()
opgrpSigned = opgrp2.sign() # error out here: fails to parse the Micheline expression for "value"

UPDATED: User iguerNL pointed out the flaw that i am not connecting with the correct contract, i am updating to fix that.

2 Answers 2

1

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 contract with a fulfill_ask entrypoint (?):

https://better-call.dev/search?text=fulfill_ask

1
0

Instead of doing the low-level stuff yourself, you may consider trying to use factori, see the Python section of the recent article https://functori.com/blog/blog-csharp-python-now-supported-in-factori.html . You can adapt the given scenario to call your contract.

If the following scenario isn't clear, please ask and I will explain it more in detail:

Can you try this (with the right identity, that is, instead of Alice, input your secret key and your public key)?

First get factori using e.g. docker as in https://gitlab.com/functori/dev/factori/-/blob/next/README.md . Then:

mkdir test && cd test
factori import kt1 . KT1WvzYHCNBvDSdwafTHv7nJ1dWmZ8GCYuuC --name test --python --force

Create a file src/python_sdk/main.py:

from importlib.metadata import metadata
import time
import test_python_interface
import factori_types
import blockchain

def main():
    debug = False
    kt1 = "KT1WvzYHCNBvDSdwafTHv7nJ1dWmZ8GCYuuC"
    #modify your script with the right identity
    alice : blockchain.identity = { 'sk' : "edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq", 'pk' : 'edpkvGfYw3LyB1UcCahKQk4rF2tvbMUk8GFiTuMjL75uGXrpvKXhjn', 'pkh' : 'tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb' }
    ask_id = 1253832
    param : Fulfill_ask = {"ask_id" : ask_id, "proxy" : None}
    ophash = test_python_interface.callFulfill_ask (
        kt1,
        _from=alice,
        param=param,
        networkName="mainnet",
        debug=debug,
    )
    print("An operation is sent to a node. Its hash is: " + ophash)
    print("Waiting for its inclusion in a block ...")
    time.sleep(15)  # we need to wait for one block before calling the contract
    print("Check the status of your operation: https://tzkt.io/" + ophash)

main()

Finally, run

python3 src/python_sdk/main.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.