Code Monkey home page Code Monkey logo

tezos-nft-sample's Introduction

Bucket, shovel, rake, and molds

This is an attempt to bring together four tools for local development and debugging of smart contracts for Tezos:

  • Granary — all-in-one toolkit for smart contract development;
  • LIGO — high-level smart-contract language that compiles down to Michelson;
  • PyTezos — Python SDK for Tezos;
  • Better Call Dev — Michelson contract explorer.

Me and the boys

Requirements

Granary contains Tezos node (with client), and LIGO compiler, and also a set of scripts that control the containers and ease the interaction. It's shipped as npm package, and you need to have docker and node.js v11.4+ previously installed. See granary documentation for additional information.

PyTezos requires python 3.6+ installed and several system libraries: libsodium libsecp256k1 and libgmp . Check pytezos documentation for OS-specific instructions.

Setting up sandbox

Clone the repository and install dependencies:

git clone https://github.com/baking-bad/tezos-nft-sample
cd tezos-nft-sample
npm i
pip install -r requirements.txt

We need to initialize Granary settings before the first launch:

npm run init

Now can start the Tezos node:

npm run start

Awesome! Next step is adding several accounts and activating protocol:

npm run activate-alpha

That's it! There are few more commands you can use to control the node:

# Stop the node
npm run stop

# Remove all granary settings brought by init
npm run clean

# stop + clean + init + start + activate-alpha
npm run reset

Compiling sources and testing

In this sample project we have LIGO sources in src directory and unit tests in tests

LIGO compiler is executed in a docker container, and it compiles all .ligo files in src folder down to Michelson.

npm run compile

Atm compilation errors are not visible in the terminal, so you have to open the file to read them, but this will be resolved soon.

After we received Michelson sources we can use PyTezos high-level interface to write unit tests. If you are familiar with the unittest module in Python that will be super easy, if not - also easy :)

npm run test

Deploying and calling a contract

The following commands are project specific and utilize pytezos-based client module. You can use standard tezos-client instead.

PyTezos client has several useful features, first automatic generation of the initial storage, and secondly implied interface annotations. This means that even if your code is not annotated, if it implements a well-known interface, the necessary annotations will be added to it (optional of course).

python -m client originate
npm run bake

There will be link in the terminal output containing originated contract id. It will be used in the following calls. The link leads to a page in the Michelson contract explorer (BCD), where you can inspect all the operations, script, and state.

python -m client mint --contract-id={contract_id} --token-id=42
npm run bake
python -m client burn --contract-id={contract_id} --token-id=42
npm run bake

This is how it's displayed at https://better-call.dev/sandbox/{contract_id}

Better Call Dev

Further reading

Ask any question about PyTezos, Better Call Dev in Baking Bad telegram chat: https://t.me/baking_bad_chat

Granary

Documentation

LIGO

Language basics

Tutorial

Examples

PyTezos

Introduction

Quick start guide

Tutorial

Better Call Dev

Overview

Pick random contract

tezos-nft-sample's People

Contributors

m-kus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.