DEV Community

VivekAsCoder
VivekAsCoder

Posted on

How to deploy FA2 contract for NFT on Tezos.

Let's see.

Writing the code.

import smartpy as sp
fa2 = sp.io.import_script_from_url("file:./fa2.py")

class Token(fa2.FA2):
    pass

admin = sp.address("tz1Qd55E9faDRDUWVbFTv4GXe7mA46NPctLx")
sp.add_compilation_target("Token", Token(
    config = fa2.FA2_config(
        non_fungible=True,
        assume_consecutive_token_ids = False
    ),
    admin = admin,
    metadata = sp.big_map({
        "": sp.utils.bytes_of_string("tezos-storage:content"),
        "content": sp.utils.bytes_of_string("""{name: "LOL"}"""),
    })
))
Enter fullscreen mode Exit fullscreen mode

Deploying the code

Since, we're not noob here, let's create a makefile.

SP=~/smartpy-cli/SmartPy.sh
SHELL := /bin/bash

nft:
    $(SP) compile ./nft.py ./output --html
    $(SP) originate-contract \
    --code ./output/Token/step_000_cont_1_contract.tz \
    --storage ./output/Token/step_000_cont_1_storage.tz \
    --rpc https://hangzhounet.smartpy.io
Enter fullscreen mode Exit fullscreen mode

Then write the following command to deploy the code to testnet.

make nft
Enter fullscreen mode Exit fullscreen mode

Got any question, leave in the comments.

Top comments (0)