Skip to content

lab10-coop/pwasm-erc777

Repository files navigation

pwasm-erc777

Build Status

Description

An experimental implementation of the ERC777 Ethereum Token Standard implemented in Rust/WebAssembly using the "pwasm" libraries and tools.

The purpose of this implementation is to explore the feasibility of writing complex contracts for the Ethereum platform using Rust/WebAssembly.

It uses the Rust 2018 Edition and current nightly builds of Rust to benefit of newest language features and simplifications.

pwasm Environment Modifications and Extensions

To allow faithful representation of the ERC777 ABI the pwasm-abi repository was forked here and extended with support for Rust/ABI "String" type.

Furthermore a Rust module containing a procedural macro for compile-time calculation of keccack hashes was implemented to reduce the Gas cost of running the contract by eliminating needless re-calculation of constant hash values for smart contract storage.

Functions emulating the Solidity "require" function were implemented to ease the transition from the Solidity implementation and produce more readable/recognizable precondition checks.

wruffle

In addition to Rust Unit Tests further Integration Tests using the node.js and "web3" module were developed, following the example of the Solidity ERC777 implementation.

The truffle toolchain is widely used for development/testing/deploying of smart contracts in Solidity. This repository contains the beginnings of a similar toolset for smart contracts written in Rust, starting with support for convenient testing of smart contracts deployed in Rust.

We empathically called this toolset wruffle.

It allows quick and convenient compile/deploy/test cycles on pwasm smart contracts with the web3 tests largely identical to the ones written using truffle.

This suite is in early development, to be extended with further commands, e.g. for deploying on production chains.

Known Problems

Some mathematical operations on the U256 type imported from pwasm-std causes duplicate symbols link errors, specifically when using multiplications and modulo.

This is most likely an issue with the "uint" Rust module not being fully adapted to work in the Rust "no-std" environment at this point. Subject to further investigation.

As a consequence the granularity checks and corresponding web3 Unit Tests are currently deactivated.

Build Prerequisites

Install rust with wasm32-unknown-unknown target:

rustup target add wasm32-unknown-unknown

Install Wasm build util:

cargo install pwasm-utils --bin wasm-build

Build Rust WebAssembly

Run:

cd contracts/pwasm-erc777/
./build.sh

Testing

cd contracts/pwasm-erc777/
./test.sh

Build web3 Unit Tests

Requires node.js 10.x

Run:

npm i
npm test

About

ERC777 Ethereum Token Standard implemented in Rust using pwasm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published