0

I trying to write a smart contract on the tezos network and using import FA2 library for this. But when I try to run the code I face the url error. this is my code :

import smartpy as sp

FA2 = sp.io.import_script_from_url("https://smartpy.io/templates/fa2_lib.py") 

class CyrusNft(FA2.Fa2Nft):
    pass
    
@sp.add_test(name="Test cyrusNft")
def test():
    sc = sp.test_scenario()
    cyrusNft = CyrusNft(metadata=sp.utils.metadata_of_url("ipfs://Qme5jKLzvtLfgQowJqPExWw9sJHrbwYqRgKTtxgJEjfHDG"))
    sc += cyrusNft

and this is error :

In /lib/python3.10/urllib/request.py, line 1419:

raise URLError('unknown url type: %s' % type)
urllib.error.URLError:

thank you for helping me

2 Answers 2

1

You can use sp.io.import_template("fa2_lib.py").

0

The updated URL for importing the FA2 library is https://legacy.smartpy.io/templates/fa2_lib.py

You can get the latest info from the official docs

Here is the final code:

import smartpy as sp

FA2 = sp.io.import_script_from_url("https://legacy.smartpy.io/templates/fa2_lib.py")

class CyrusNft(FA2.Fa2Nft):
    pass

@sp.add_test(name="Test cyrusNft")
def test():
    sc = sp.test_scenario()
    cyrusNft = CyrusNft(
        metadata=sp.utils.metadata_of_url(
            "ipfs://Qme5jKLzvtLfgQowJqPExWw9sJHrbwYqRgKTtxgJEjfHDG"
        )
    )
    sc += cyrusNft
2

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.