GithubHelp home page GithubHelp logo

ivanmolto / zoe-sketchbook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from agoric/zoe-sketchbook

0.0 1.0 0.0 2.67 MB

An easy way to get started with building JavaScript smart contracts on Zoe. Draft and lightly test your smart contact code here

JavaScript 100.00%

zoe-sketchbook's Introduction

Zoe Sketchbook

An easy way to get started building JavaScript smart contracts on Zoe. Draft and lightly test your smart contact code here.

Getting started

The following instructions are written for MacOS. If they don't work for you, or you can contribute instructions for a different platform, please create a new Github issue describing the problem.

Prerequisites and Recommendations

Required

  1. XCode Command Line Tools - you likely will prompted to install this in the terminal as you install the following items.
  2. Node.js 12.16.2 LTS - this is the JavaScript engine that will run the code
  3. Homebrew - we will use this in the next step to install yarn
  4. Yarn 1 - install using Homebrew in the terminal by typing brew install yarn and hitting Enter.

Recommendations

We recommend using nvm to switch between Node versions as necessary.

We also recommend using Visual Studio Code as your code editor.

Grab a local copy of Zoe Sketchbook

In the terminal, navigate to the folder in which you would like to download Zoe Sketchbook (we recommend a code directory, created by entering mkdir code):

cd code
git clone https://github.com/Agoric/zoe-sketchbook.git
cd zoe-sketchbook
yarn install

Editing and inspecting the code

Open up Visual Studio Code (VS Code), and open the zoe-sketchbook folder (you can find it under Users/[your username]/code/).

Open Zoe Sketchbook

You should now see a number of files in the file explorer on the left hand side.

File Structure

Looking at Examples

In the examples/ folder (you can look at this on Github.com, but we recommend viewing the files locally using VS Code), there are examples of minting fungible tokens (baytownBucks.js), and securely trading with another person using the atomicSwap contract running on Zoe (tradeWithAtomicSwap.js). Additionally, all of the contracts written by Agoric for Zoe are copied into zoe-contracts-copied for your perusal.

Running Tests

Some of the these examples have tests that you can run and look at to see how they work, and use them as templates to create your own tests. You can find these tests in the test directory.

To run all of the tests, do: yarn test from the command line/terminal.

We use the tape testing framework. It was installed for you when you ran yarn install.

Running one test at a time

You can add .only to a test to run only that test:

test.only('timing test', t => {
});

Adding your own contracts

Feel free to make a new file in your local copy (what you just cloned) and write out your own contract. You will probably want to create a test file for your contract as well to make sure it works as intended.

Happy contracting!

Further Instructions

Installing NVM

  1. Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  1. It may ask you to have a bash profile so that it can add an export for NVM. You can create a profile file by entering:
touch ~/.bash_profile

If you needed to add a bash profile, rerun step 1.

  1. Close and reopen terminal
  2. Enter:
nvm install 12.16.2
nvm use 12.16.2

Now you can switch back and forth between installed version of Node by using the nvm use command.

zoe-sketchbook's People

Contributors

katelynsills avatar chris-hibbert avatar dependabot[bot] avatar

Watchers

James Cloos 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.