This article is an excerpt. For detailed development, deployment, and invocation code examples, followMp.weixin.qq.com/s/jNRlVo6fu…Look at it.

In recent years, several blockchain projects have supported the use of WebAssembly (Wasm) to execute user-written smart contracts. Today, I will briefly introduce Polkadot, NEAR and Dfinity, how to use the contract language framework provided by each of them to implement a simple Counter contract, and compile it into Wasm contract and deploy it on the chain. Note: The default precondition is that the Rust development environment has been installed and configured.

# installation Rustup curl, proto '= HTTPS' - tlsv1.2 - sSf # https://sh.rustup.rs | sh configuration source $HOME /. Cargo/env # add wasm Rustup  target add wasm32-unknown-unknownCopy the code

Polkadot

Polkadot is a heterogeneous multi-chain network with shared security and interoperability, with relay chains and parallel chains/parallel threads. The Polkadot relay chain itself does not support smart contracts. But because of Substrate’s built-in Palm-contracts, parallel chains on Polkadot will support WebAssembly smart Contracts.

ink! Is an embedded Domain Specific Language (eDSL)[1] that you can use to write smart contracts in Rust. ink! Is the standard Rust, defined as a “contract format,” using the specialized #[ink(…)] Property macros, which eventually allow the use of INK! Create Wasm bytecode compatible with Substrate, and then use Wasm virtual machines to run Contracts via Palm-contracts.

Pallets currently support pallets running on Pallets except for ink in Rust language! In addition, there are the following projects:

  • Ask! [2] AssemblyScript is a contract language framework based on AssemblyScript, developed by Patract.
  • Solang, developed by Hyperledger-Labs, supports Wasm tools for compiling Solidity into Pallets.

Before developing the contract, we need to download and install the following tools:

Paritytech. Making. IO/ink – docs/ge…

  • Cargo – contract, ink! The CLI tool is used to help set up and manage contracts
  • Canvas-node, a simple Substrate blockchain, is used to run contracts
  • Jupiter[3], Patract maintains modules containing Patract contract design specifications and compatible with the latest Palm-contracts, which can be used for running Contracts.

For detailed development, deployment, and invocation code examples, goMp.weixin.qq.com/s/jNRlVo6fu…Look at it.

For more details refer to INK! Documents:

Paritytech. Making. IO/ink – docs/ge…

NEAR

NEAR is an open network infrastructure that provides a decentralized application platform. Through the malleability of the bottom layer, optimization of the middle layer, and mature tools of the application layer, it provides a simple and friendly user experience for developers and users.

Currently, NEAR supports smart contract development in two languages, AssemblyScript and Rust, through the NEAR SDK. No matter which language is used to build smart contracts, once compiled into Wasm, they end up being deployed and executed in exactly the same way on the NEAR platform.

For detailed development, deployment, and invocation code examples, goMp.weixin.qq.com/s/jNRlVo6fu…Look at it.

See the developer documentation for more details:

Docs.near.org/docs/develo…

DFINITY

DFINITY’s Internet Computer is a distributed and decentralized platform for running software. The source code for an application written on an Internet Computer is compiled into a WebAssembly module. When an Internet Computer deploys a WebAssembly module containing an application, the program is executed in a cell called software Canister. End users can interact with the canister software by accessing the entry functions defined by the application through a front-end client, such as a browser.

The contract language supported by DFINITY is Rust and Motoko, a modern programming language created by DFINITY that is optimized for developing and running programs on the Internet Computer blockchain. It is used in conjunction with the development kit DFINITY Canister SDK.

Download and install the DFINITY Canister SDK before developing the contract.

Sdk.dfinity.org/docs/quicks…

For detailed development, deployment, and invocation code examples, goMp.weixin.qq.com/s/jNRlVo6fu…Look at it.

Refer to the DFINITY documentation for more details:

Sdk.dfinity.org/docs/rust-g…

summary

Through practice, we found that the basic steps for smart contract development are as follows:

1. Initialize the project, write contract code and compile the contract through tools;

2. Deploy contract to local blockchain or test network; 3. Invoke the method in the contract.

Note: Patract’s contract language framework (Docs. Patract. IO/contracts/l…

We can see that there are many ways to deploy smart contracts, both on the command line and in the browser, but this is often not very consistent with our programmer style, because we are used to writing code in the IDE and then packaging it up and seeing what happens. Although there are already contract plug-ins in ides that allow you to write smart contracts, deploying smart contracts is a different way to do a quick deployment and testing.

Patract (Patract.io /), a technology provider for deep Polkadot Ecological Wasm contract technology, has provided the Ink! And Ask! Redspot (Redspot.patract.io /en/), which simplifies the development of… It covers the entire contract development process (develop-debug-test-deploy) and allows developers to build rich plug-ins to extend Redspot’s capabilities, minimizing the contract developer’s burden and automating the repetitive process. Redspot is designed to be similar to Truffle in the Ethereum ecosystem, but with more extensive capabilities than Truffle.

Meanwhile, Patract designed Europa (github.com/patractlabs… Ganache is part of the Ethereum ecosystem, but Europa is more about logging detailed execution information during the process of deploying the call contract, which is the best way to reflect the “black box” of contract modules, which is very helpful to contract developers.

About Patract

Patract provides solutions for parallel chain and DApp development in boca’s Wasm contract ecosystem. We help the community design and develop on-chain contract module and Runtime support, and provide DApp developers with a full stack of tools and services covering the development, testing, debugging, deployment, monitoring, data provisioning, and front-end development phases.

How to join Patract

1. For contract developers, visit the official website (Patract.io) to familiarize yourself with the test chain and tool suite. Element (app.element. IO /#/room/#Pat… Discord (Discord. Gg /wJ8TnTfjcq) 2. For parallel chain projects that will integrate the functionality of the Wasm contract, or for DApp projects developed using the Wasm contract, welcome to the Patract Open Platform: open.patract.io 3. For users, welcome to join: Telegram (t.me/ Patract) Twitter (twitter.com/PatractLabs… 4. For job seekers, we are recruiting blockchain development engineers, front-end/full stack development engineers, product managers and other positions, you can contact [email protected]