Skip to content

Latest commit

 

History

History
64 lines (42 loc) · 1.79 KB

README_RUN_TEST.md

File metadata and controls

64 lines (42 loc) · 1.79 KB

Get the wordlist from the test smart contract

cd test

npm install

node call.js

[
  { word: 'hello', level: '1', mean: '你好' },
  { word: 'hello', level: '1', mean: '你好' },
  { word: 'hello', level: '1', mean: '你好' }
]

Build contract

build contract need to install ink: https://paritytech.github.io/ink/

cd diwl-contract/

cargo contract build

The contract generated by the compilation is in the following location:

diwl-contract/target/ink/diwl_contract.contract

Local node

I'm use AstarNetwork's swanky-node for test,download a binary release from: https://github.com/AstarNetwork/swanky-node/releases

Start local node:

./swanky_node

I use a old version macos(<12), Swanky Node binary release don't work, so I build from the source, there were some problems compiling rockdb during the compilation process.

If you have the same problem please refer to the link below: rust-rocksdb/rust-rocksdb#528 https://substrate.stackexchange.com/questions/4620/build-rocksdb-failed-at-snappy-snappy-cc103336-error-invalid-output-constrai

Deploy and call contract use polkadotjs js api

copy .contract file and metadata.json to test/test_contract

also you can edit base.js change file path use generated file Directly.

let wasmPath = __dirname + "test_contract/diwl_contract.contract";
let abiMetadataPath = __dirname + "test_contract/metadata.json";
let wasmPath = __dirname + "../diwl-contract/target/ink/diwl_contract.contract";
let abiMetadataPath = __dirname + "../diwl-contract/target/ink/metadata.json";

use local node, you need to change the rpc address in base.js.

const api = await ApiPromise.create({ rpc: "ws://localhost:9944" });
//const api = await ApiPromise.create({ rpc: "wss://rpc.shibuya.astar.network" });