Git Product home page Git Product logo

wasm-flipper's Introduction

Flipper: WASM dApp for Astar

This is a demo for a simple WASM contract. The contract name is Flipper. Flipper contract has two method.

  1. One transaction method flip
  2. One query method get.

Flipper contract is meant to show a hello world use case for WASM, Swanky and connect the contract via a React frontend.

The contract folder contains the contract code. The UI folder contains the UI code. UI is written in Next.js and React.

Usage

Install swanky cli https://github.com/AstarNetwork/swanky-cli

npm install -g @astar-network/[email protected]

Deploy the Flipper contract

  1. Init
cd contract
swanky init flipper

and chose ink as a contract language and flipper as template and a chosen contract name. Chose Y when asking to download the Swanky node.

  1. Start the local node
cd flipper
swanky node start

Then swanky node starts running in your local environment.

  1. Build the contract

Open new tab

swanky contract compile flipper

(Try rustup update if you face error which Swanky doesn't return error)

  1. Deploy the contract

Local

swanky contract deploy flipper --account alice -g 100000000000 -a true

Shibuya

swanky contract deploy flipper --account alice --gas 100000000000 --args true --network shibuya

Copy paste the contract address.

Run the UI

Install Dependencies

cd ../..
yarn

Start Next.js server

yarn dev

Go to http://localhost:3000 and enter the contract address. Flip button flips the boolean value.

Note when running Swanky node:

Example is set up to connect to Shibuya network. If you want to connect to local environment, you need to change the setting in app.tsx file in ui/components:

// local
// const WS_PROVIDER = 'ws://127.0.0.1:9944'

// shibuya
const WS_PROVIDER = 'wss://shibuya-rpc.dwellir.com'

Also, you need to add predefined Substrate Developer Accounts to your browser extension so you can sign the flip() call with Alice account existing on Swanky node.

You can find instructions how to do that in this article

wasm-flipper's People

Contributors

hilarious23 avatar niklabh avatar andabak avatar fiexer 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.