Coder Social home page Coder Social logo

tezos-utils's Introduction

Tezos node scripts helpers

This repo contains some scripts to help in the develop of smart contract in tezos chain.

Currently it has the following features:

  • Compile one or multiple contracts
  • Test one or multiple contracts

Setup

This repo is meant to be a submodule for other repos, so to setup the project follow the next commands:

Add to the submodule to your repo by running:

git submodule add https://github.com/tlacloc/tezos-utils

You can run the setup.sh file with

sh tezos-utils/setup.sh

Or you can do it manually by:

  • Install docker or smartpy - CLI

  • Install node and npm

  • Then copy scripts and src folder to main project folder.

  • Copy package.json and .env.example in main project folder.

  • Save .env.example as .env and fill the vairables as needed.

run npm install to install the modules needed for the repo (also if you want, copy .gitignore from this submodule to don't store all the crap and byte-compiled smarpy files).

Configure the following files:

Create test account (if needed) and store the information in scripts/accounts.js. Add the name of the smart contract file in scripts/config.js (in contractsConfig).

Other configurations

I highly recommend to create build/ and test_retults/ folders on your main project before running any command of the Commands section, in some cases the ouput files/directories has root permissions, you can fix it by running the following command:

sudo chmod -R a=wr build/

Do the same for the test_results

Make sure the scripts/tezos-utils.js has executable permissions.

Commands

Before runing any of these commands, make sure the compilation target name of your smart contract is "compilation", or make a small fix at scripts/compile.js to match your compilation target name

Compile contract

To compile all contracts in contractsConfig stored in src/ just run:

node scripts/tezos-utils.js compile all

To compile a specific contract in contractsConfig stored in src/ just run:

node scripts/tezos-utils.js compile <contract> <other contracts>

You can specify as many as you want.

The output of both commands would be stored at build/$CONTRACT_NAME/

Test contract

To test all contracts in contractsConfig stored in src/ just run:

node scripts/tezos-utils.js test all

To test a specific contract in contractsConfig stored in src/ just run:

node scripts/tezos-utils.js test <contract> <other contracts>

You can specify as many as you want.

The output of both commands would be stored at tests_results/$CONTRACT_NAME/

Estimate contract deployment cost

To estimate the deployment cost a specific contract in contractsConfig stored in src/ just run:

node scripts/tezos-utils.js estimate <contract>

note: this action would be sign with the account and chain of the environment variables stored at .env, also would return the actual account balance and the deployment cost.

Deploy contract

To deploy a specific contract in contractsConfig stored in src/ just run:

node scripts/tezos-utils.js deploy <contract>

note: this action would be sign with the account and chain of the environment variables stored at .env

Other features

The project can be used with github workflow, to make it possible, you would need to create an action in github based on the one stored at .github/workflows

What it does it, when there is a push or merge in the dev branch (it can be also configured to mainnet in master branch) the actions installs the app and compiles, tests, estimates and deploy the smart contract into hangzhounet tezos testnet.

If you want to do the same, you need to create the secrets in your repo, there you would need to store your public and private keys (that's why I just use it on testnet) similar as we store them in the .env file.

Then decide what contract you want to run and change the name (currently is the calculator we have for for illustrative purposes only) to the one you stored in the config file. Make sure you have configure the contract to be built in the testnet chain.

tezos-utils's People

Contributors

tlacloc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tezos-utils's Issues

root permissions

Description

When the command test or compile is ran, the folder output can not be deleted without root permissions (dunno way)

Work to be done

Check if is related to how the data is exported by docker, or by the smartpy-CLI

fix it XD

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.