RuSnap
Build Metamask Snap use Rust.
Features
- Snap basic function.
- Manage keys
- Dialog and Notification
- Random
- Store Data
- Network Access (WIP)
- Ethereum Provider (WIP)
- RPC Handle
- Keyring API (TODO)
Example
https://github.com/tiannian/rusnap-example
Install and Usage
Install cargo-rusnap
.
Dependencies
Please install these dependencies.
- wasm-pack
- npm (yarn or pnpm)
Create Snap
Build Snap
# Build dev mode in default
# Build release mode
Start Snap
Snap
Install Snap in Metamask
Then you can load snap in metamask.
Execute these js statement in broswer devtool:
window..;
Or use Metamask Snap Debug Tool.
Call Snap
Execute these js statement in broswer devtool:
window.ethereum.request({
method: "wallet_invokeSnap",
params: {
snapId: "local:http://localhost:8080",
request: {
method: "hello",
},
},
});
Publish Snap
TODO
Reference
Basic Function
Basic function of Snap:
Random
Use OsRng
in rand_core
or other random crate based on getrandom
.
Please add getrandom
with js
feature.
= { = "0.2.10", = ["js"] }
Web3 SDK
Use rusnap-ethers
and ethers
.
Note:
rusnap-ethers
don't re-export intorusnap
crate, please add this crate independently.