美文网首页
2019-06-17 rust开发erc20

2019-06-17 rust开发erc20

作者: oracle3 | 来源:发表于2019-06-17 11:35 被阅读0次

    工程是老外现成的,wrc20-rust
    难点是如何编译和运行,这里记录一下

    1、下载代码

    git clone https://github.com/hugo-dc/wrc20-rust
    

    2、编译

    make
    cargo build-ewasm
    error: no such subcommand: `build-ewasm`
    Makefile:4: recipe for target 'all' failed
    make: *** [all] Error 101
    

    可以看到直接错误,咨询作者得到方法

    3、安装build-ewasm

    参考build-ewasm

    cargo install chisel
    cargo install wasm-snip
    cargo install --git https://github.com/hugo-dc/cargo-build-ewasm.git
    

    然后再次make,得到下面的结果:

    make
    cargo build-ewasm
    
    Building ewasm module...
    
    Executing chisel...
    Ruleset ewasm:
        remapimports: Translated
        trimexports: Translated
        verifyimports: OK
        verifyexports: OK
        repack: OK
    Writing to file: target/wasm32-unknown-unknown/release/ewasm_token.wasm
    
    
    Minifying bytecode (wasm-snip)... OK
    
    Finished
    wasm-opt -Oz -o target/wasm32-unknown-unknown/release/ewasm_token.wasm target/wasm32-unknown-unknown/release/ewasm_token.wasm
    make: wasm-opt: Command not found
    Makefile:4: recipe for target 'all' failed
    make: *** [all] Error 127
    

    又缺个wasm-opt

    4、安装wasm-opt

    编译安装

    git clone https://github.com/WebAssembly/binaryen.git
    cd binaryen
    mkdir build
    cd build
    cmake ..
    make
    sudo make install
    

    安装成功后,回到wrc20-rust的目录,继续make

    make
    cargo build-ewasm
    
    Building ewasm module...
    
    Executing chisel...
    Ruleset ewasm:
        remapimports: Already OK; not translated
        trimexports: Already OK; not translated
        verifyimports: OK
        verifyexports: OK
        repack: OK
    Writing to file: target/wasm32-unknown-unknown/release/ewasm_token.wasm
    
    
    Minifying bytecode (wasm-snip)... OK
    
    Finished
    wasm-opt -Oz -o target/wasm32-unknown-unknown/release/ewasm_token.wasm target/wasm32-unknown-unknown/release/ewasm_token.wasm
    

    5、安装wasm32-unknown-unknown

    可能出现错误:ERROR: error building wasm module, confirm target wasm32-unknown-unknown is installed
    继续安装

    rustup target add wasm32-unknown-unknown
    

    相关文章

      网友评论

          本文标题:2019-06-17 rust开发erc20

          本文链接:https://www.haomeiwen.com/subject/dxzofctx.html