💻
mx-sdk-as
  • MultiversX WASM AssemblyScript (Proof of concept)
  • The Crowdfunding Smart Contract
    • The Crowdfunding Smart Contract (part 1)
    • The Crowdfunding Smart Contract (part 2)
  • The Flip Smart Contract
    • The Flip Smart Contract : Introduction
    • The Flip Smart Contract part 1 : Setting up the development environment
    • The Flip Smart Contract part 2 : Think about the contract and the game mechanisms
    • The Flip Smart Contract part 3 : Setting up the project
    • The Flip Smart Contract part 4 : Writing the contract storage
    • The Flip Smart Contract part 5 : Contract administration
    • The Flip Smart Contract part 6 : Bet logic
    • The Flip Smart Contract part 7 : Make the flip
    • The Flip Smart Contract part 8 : Bounty endpoint
    • The Flip Smart Contract part 9 : Testing the contract
  • 💡How to
    • Model classes
    • Enums
    • Modules
Powered by GitBook
On this page
  • Cloning the contract template
  • Initializing the code and dependancies
  • Building the contract
  • Next up
  1. The Flip Smart Contract

The Flip Smart Contract part 3 : Setting up the project

Time to code !

Cloning the contract template

For the moment there is no CLI allowing to create new AssemblyScript smart contracts projects, so you'll need to clone the empty contract template :

git clone https://github.com/gfusee/mx-sdk-as-empty.git flip
cd flip
rm -rf .git

A CLI like mxpy is not available yet for AssemblyScript projects. This feature is planned.

Initializing the code and dependancies

Open the folder inside your favorite code editor and replace the content of the `assembly/index.ts` by the following code :

//@ts-nocheck

import {
    ContractBase
} from "@gfusee/mx-sdk-as";

@contract
abstract class FlipContract extends ContractBase {
    
}

Use //@ts-nocheck to avoid false errors due to IDEs thinking the code is in TypeScript instead of AssemblyScript and annotations not processed.

Here we have the simplest contract ever : a contract that does nothing (for now!). More information about each line can be found inside the previous tutorial.

As any node project we need to install npm packages with the following command:

npm install

Building the contract

Run the next command to build your contract :

npm run build

If everything went well you should have a new folder named build with two files inside : release.wasm and release.wat. The first one is the deployable code and the second one is a "human readable" version of the first one.

Next up

At the moment the contract is empty. We will write the flip code in next parts of this tutorial, starting by the contract storage 📚

PreviousThe Flip Smart Contract part 2 : Think about the contract and the game mechanismsNextThe Flip Smart Contract part 4 : Writing the contract storage

Last updated 1 year ago