DEV Community

VivekAsCoder
VivekAsCoder

Posted on

3 1

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay