Environment Setup
Before you start, set up nvm and install the latest Node JS version on your local machine. For more info on how to setup nvm read this post.
To start creating your own Tezos Polywrapper, clone our fork of the Polywrap integration repository.
As long as Polywrap Tezos is in alpha stage, we will be hosting the most recent version of our code on https://github.com/blockwatch-cc/polywrap-tezos. Once we reach a stable release, the official version will become available in the upstream Polywrap repository.
Prerequisites
nvm
yarn
docker
docker-compose
To implement your wrapper's logic, you use AssemblyScript which then is compiled down to WebAssembly.
Create Your Project
To begin, create a new template project by cloning our template repository (replacing <project-name> with your project's name:
Installation
Let's ensure that all dependencies are installed. From inside your project directory, run:
Now, the Polywrap CLI is installed locally to your project directory. For more information on how this CLI works, refer to the Polywrap docs - Project Setup.
Continue to learn the Polywrap project folder structure.
Polywrap Project Structure
Once your project is set up, the folder tree should look similar to this:
src/_tests_
src/_tests_
The tests folder contains testUtils.ts file which contains the ens, ipfs, tezos-plugin-js, ethereum-plugin-js, client-js that’s setup and used in the .spec.ts files. The e2e test codes are written in the query.spec.ts and mutations.spec.ts files. Tests are run using the Tezos Test Environment.
src/mutation
src/mutation
The src/mutation & src/query folders are where the API's GraphQL schema and AssemblyScript implementation files live.
src/utils
src/utils
The src/utils directory contains getString and normalizeValue functions which are helper functions used when getting data from storage.
jest.config.js
jest.config.js
This file contains the Jest configurations.
package.json
package.json
The package.json file is the heart of any Node project. It records important metadata about a project which is required before publishing to NPM, and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.
Build
To build your template project, run:
Your build folder will contain the following files:
The content is uploaded to decentralized storage and enables any Polywrap client to download, query, and execute your wrapper's functionality from within the application.
The mutation.wasm
and query.wasm
files are the WebAssembly files compiled from AssemblyScript.
The schema.graphql file contains the API schema, consisting of custom types and callable methods referred to as query and mutation. The web3api.yaml manifest file describes the layout of the package.
Last updated