Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loredanacirstea/ewasm-jsvm
ewasm virtual machine for javascript
https://github.com/loredanacirstea/ewasm-jsvm
ethereum ewasm javascript solidity virtual-machine
Last synced: 17 days ago
JSON representation
ewasm virtual machine for javascript
- Host: GitHub
- URL: https://github.com/loredanacirstea/ewasm-jsvm
- Owner: loredanacirstea
- License: gpl-3.0
- Created: 2020-05-12T16:07:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-29T07:31:56.000Z (over 1 year ago)
- Last Synced: 2024-10-22T09:13:06.527Z (23 days ago)
- Topics: ethereum, ewasm, javascript, solidity, virtual-machine
- Language: JavaScript
- Homepage:
- Size: 1.31 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ewasm-jsvm
1) ewasm virtual machine
2) evm virtual machineUPDATE: the ewasm part is outdated and is currently being developed in another (private for now) repo. The EVM virtual machine can be used as a debugger (not efficient, as it offers a snapshot state of storage, memory and logs after each opcode).
Specs: https://github.com/ewasm/design/blob/master/eth_interface.md.
**! Use it only for testing. Not production ready.**
## Use
Needs peer dependencies: `npm install ethers --save`.
```
npm install ewasm-jsvm --save
```### Node
For `i64` support, use a Node.js version which supports the `--experimental-wasm-bigint` flag. E.g. `v13.10.1`
### Browser
A limited (Ethereum interface methods with args of type `i64` are not supported by browsers), but easier to use version of the ewasm-jsvm can be found at https://observablehq.com/@loredanacirstea/ewasmjsvm.
## Development
```
cd ewasm-jsvm
yarn
```### Run Tests
```
npm run test
```To test a contract:
- add the source in `./tests/contracts` for Yul or `./tests/sol` for Solidity
- in `./tests/jsvm.test.js`:
- add the abi, like https://github.com/loredanacirstea/ewasm-jsvm/blob/54c3599cd8ab67ffad1e2172e67083977cd25e66/tests/jsvm.test.js#L86-L90
- write a new testFor contracts that only need to execute the constructor, check out the `c1` contract, abi & test:
```
const ewmodule = ewasmjsvm.runtimeSim(contracts.c1.bin, c1Abi);
const answ = await ewmodule.main(DEFAULT_TX_INFO);
```For contracts where the constructor returns a runtime wasm to be deployed (that only has a fallback/default function), check out `c2` contract, abi & test:
```
const runtime = await ewasmjsvm.deploy(contracts.c2.bin, c2Abi)(DEFAULT_TX_INFO);
const answ = await runtime.main(DEFAULT_TX_INFO);
```For contracts with functions, check out the `c10` contract, abi & test:
```
const runtime = await ewasmjsvm.deploy(contracts.c10.bin, c10Abi)(DEFAULT_TX_INFO);
let answ = await runtime.sum(8, 2, DEFAULT_TX_INFO);
```