Crates.io | rusnap-api |
lib.rs | rusnap-api |
version | 0.1.1 |
source | src |
created_at | 2023-10-13 14:44:46.352453 |
updated_at | 2023-10-18 07:02:17.888916 |
description | JSONRPC API for Metamask Snap |
homepage | |
repository | https://github.com/tiannian/rusnap |
max_upload_size | |
id | 1002360 |
size | 14,394 |
Build Metamask Snap use Rust.
https://github.com/tiannian/rusnap-example
Install cargo-rusnap
.
cargo install rusnap
Please install these dependencies.
cargo rusnap new <pkg-name>
# Build dev mode in default
cargo rusnap build
# Build release mode
cargo rusnap build --release
cargo rusnap start
Then you can load snap in metamask.
Execute these js statement in broswer devtool:
window.ethereum.request({
method: "wallet_requestSnaps",
params: { "local:http://localhost:8080": {} },
});
Or use Metamask Snap Debug Tool.
Execute these js statement in broswer devtool:
window.ethereum.request({
method: "wallet_invokeSnap",
params: {
snapId: "local:http://localhost:8080",
request: {
method: "hello",
},
},
});
TODO
Basic function of Snap:
Use OsRng
in rand_core
or other random crate based on getrandom
.
Please add getrandom
with js
feature.
getrandom = { version = "0.2.10", features = ["js"] }
Use rusnap-ethers
and ethers
.
Note:
rusnap-ethers
don't re-export inrusnap
crate, please add this crate independently.