[Astar]Develop smart contracts with ask!

Realtakahashi Work
4 min readJun 21, 2022

Summary

  • briefly explain what ask! is.
  • Follow the official documentation to implement the simplest sample of ask! And run it on the Astar Network.

What is ask!?

According to the official website,”ask! is an Embedded Domain Specific Language (EDSL) to write WebAssembly based smart contracts using typescript.”

Why ask!?

There are currently three options for developing smart contracts on the blockchain implemented in Substrate. One is to develop on EVM using Solidity, the other is to develop using ink !, which is a rust-based EDSL, and the method to use ask!
Solidity is a very attractive development language for many who are involved in developing existing web applications. The reason is that the language specification of solidity is close to javascript and solidity has many good tools. However, as blockchain officials say, solidity has various challenges and is said to be “WASM is future”.
It’s a bit old, but see Dr. Gavin Wood talking about the future of WASM.

When developing smart controls with WASM, you have the option of using ink !. As I mentioned earlier, ink! Is implemented using rust. I have experience developing with C and C ++, so I didn’t have much trouble learning rust. However, I think that there is a disadvantage that the learning cost is high for the developer who started his career from application development on the web as a developer.Since ask! uses typescript, I realize that it has the advantage of being familiar to many developers.

Develop using ask!

check your environment

ask! uses node.js, so if it’s not installed in your environment, install it.Node.js of My environment is as following

% node --version
v16.4.0

Trying flipper sample

Create a project with the following command according to “Quick Start” on the official website.

% mkdir flipper
% cd flipper
% npx pl-ask-cli init

note:When I ran it in my environment, I got the error “Error: Cannot find module’cross-spawn’”. If the same event occurs, please take the following command.

% npm list cross-spawn
% npm install cross-spawn

Then create an empty “index.ts” file under the “contracts” directory.

Copy the “flipper” sample code from the official documentation and paste it into the index.ts file you just created.

Compile with the following command.

npx pl-ask-cli compile contracts/index.ts

If the compilation is successful, “index.wasm” and “metadata.json” will be created under the “build” directory.

Deploy the smart contract on Astar Node

Download and run Astar Node locally. Then use Polkadot / Substrate Portal to deploy the compiled controller.

% wget https://github.com/AstarNetwork/Astar/releases/download/v4.2.0/astar-collator-4.2.0-macOS-x86_64.tar.gz
% tar xvf astar-collator-4.2.0-macOS-x86_64.tar.gz
% ./astar-collator --dev

Select “Contract” from the “Developer” menu to deploy the Contract.
The detailed method is introduced in another article, so I will omit it here. Note that in the case of ink !, a “.contract” file containing metadata and wasm is created, but in the case of ask !, they are separate. You need to upload both “metadata.json” and “index.wasm”.

Next Step

I would like to continue to pay attention to ink! With Open Brush, which is an implementation standard like Open Zeppelin, but I will also pay attention to ask! In parallel. While waiting for these two technological advances, I will implement the dApp I want to implement with EVM.

About Astar

Astar Network is the Smart Contract Hub for WASM + EVM built on Polkadot and is one of the top Parachains in the Polkadot ecosystem in Total Value Locked and most Ethereum assets transferred over. Astar Network is the leading smart contract hub that connects the Polkadot ecosystem to Ethereum, Cosmos, and all major Layer 1 Blockchains. Astar Network supports dApps using multiple virtual machines — namely WASM and EVM — and offers the best technology solutions and financial incentives via its Build2Earn and Astar Incubation Program for Web3 developers to build on top of a secure, scalable, and interoperable blockchain.

Website | Twitter | Discord | Telegram | GitHub | Reddit

--

--