The PDX Utopia block chain stack calls the wasm smart contract using soloutflow
In this rapidly changing world, smart contracts have become a powerful service across all platforms.Solfund is a trend that PDX Utopia block chain stack USES solfund to call wasm smart contracts.
What is solfat?
As a statically typed language that supports inheritance, libraries, and complex user-defined types, solinland can be used to create various types of smart contracts for voting, crowdfunding, wallets, and more that run on the blockchain.
Sollion in the ethereum contract
Contracts are the basic building blocks of ethereum’s decentralized application.All variables and functions are part of the contract, which is the starting point for all projects.An empty contract called MyFirst looks like this:
Layout of solfat
The source file can contain any number of contract definitions, including directives and pragma directives.
Like any other language, solfat can use single-line and multi-line comments.
The type of value in solfat
The following types are also called value types because variables of these types will always be passed by value.
Solfat data structure
Solfat provides three types of data structures:
Wasm smart contracts are invoked using solfund
Define the ABI
> defines the Contract object in ‘hello-wasm-abi/ SRC /abi.rs’, including <br> in the’ hello-wasm ‘sample;
> ‘put/get/getcounter’ three methods’ ABI ‘description, note, we can not directly use’ JSON ‘to describe’ ABI ‘;
> must define the declaration using ‘pdxabi::Contract’.
The following three steps are recommended to generate the ABI:
1. Write ‘contract interface’ using ‘solglacial’;
2. Compile ‘contract interface’ with ‘remix’ to get the corresponding ‘ABI’ description;
3. Pdxabi ::Contract ‘;
After deploying the wasm contract, you can use the contract address and contract interface to instantiate the contract in the remix for easier testing.
Solidity Contract Interface
In the [Remix IDE] (http://remix.ethereum.org/#optimize=false&version=soljson-v0.5.3+commit.10d17f24.js&evmVersion=null&appVersion=0.7.7) write contract interface, and compile solidity.
Deployment and use
* deploy the contract in the same way as the ‘hello-wasm’ sample
[the README. Md] (https://github.com/PDXbaap/ewasm-rust-demo/blob/master/README.md) about ` deployment ` description:
* invoke contract:If ‘web3’ series’ SDK ‘is used,’ JSON ABI ‘+’ Contract Address ‘can be used to instantiate the Contract and make a call. If’ remix IDE ‘is used for test calls,You can use the ‘solmuddy Contract Interface’ + ‘Contract Address’ to instantiate the Contract and invoke the SDK and remix IDE provided by web3 for more information see the web3 foundation.
Solidity invokes the Wasm contract
With ` sol ` contracts to invoke ` wasm ` contracts, and ` sol ` call ` sol ` the same way, the assumption has been deployed ` hello — wasm — abi ` this contract, and get the address ` 0 xda3ce11d916ffba4a1289cef66a7f142ec5a0f74 `, through ` hello — wasm — abi ` contract interface and address can instantiate the contract, after usage and ` sol ` call ` sol ` consistent.
Hello-wasm -abi contract interface
Call the wasm contract method
After deploying the ‘foobar’ contract, use the ‘hello-wasm-abi’ contract address:
` 0 xda3ce11d916ffba4a1289cef66a7f142ec5a0f74 ` respectively as the first parameter to invoke ` fetch ` and ` set ` method, complete the ` hello — wasm — abi ` contracts ` get ` and ` put ` calls.
- the public chain of PDX -
PDX public chain aims to build a public block chain ecosystem. As a public block chain IaaS, it helps enterprise customers, developer groups and ordinary users to enjoy the convenience and fun brought by block chain with powerful underlying patented technology.
The PDX public chain asserts that data sovereignty belongs to the user.
- join the community
The official Telegram
The official medium
Official English twitter
The official Facebook
Official microblog PDXchain