3 releases
0.1.5 | Feb 7, 2023 |
---|---|
0.1.4 | Feb 6, 2023 |
#26 in #coin
22 downloads per month
32KB
317 lines
🕹 w3kit: a web3 toolkit in rust
tl;dr
🛠 this package contains an ongoing crate with a set of scripts for several blockchains (check it at crates.io).
📚 for a fun in-depth reading about rust, check my mirror post w3kit: a web3 toolkit in rust.
💡 for a rusty boilerplate for running stat searchers, check coingator.
installation
as a package
cargo install w3kit
for development
to build the library from this GitHub repository you can run:
make build
note that all cargo commands relevant to this work are encoded in the Makefile
.
setup
create an .env
file:
cp .env.example .env
vim .env
then add the config for the desired chain:
PROVIDER_URL_WS=
PROVIDER_URL_HTTP=
ethereum
connection to the chain
through an http connection:
> w3kit http -b ethereum
✅ connecting to "ethereum"
✅ current block: 16572583
through a websocket connection:
> w3kit ws -b ethereum
✅ connecting to "ethereum"
✅ current block: 16572598
retrieving an account data
> w3kit account -b ethereum -a 0xbA4C081942E6a25cAF87c5489B91b449c67f3078
✅ connecting to "ethereum"
✅ fetching account info: "0xbA4C081942E6a25cAF87c5489B91b449c67f3078"
✅ retrieving balances...
💰 account 0xba4c081942e6a25caf87c5489b91b449c67f3078 👉 0.0672775267238201 ETH
retrieving a coin price
> w3kit coin ethereum
✅ fetching coin info: "ethereum"
✅ fetching price for ethereum in usd
✅ GET https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd
💰 ethereum price 👉 {"ethereum":{"usd":1623.04}}
arbitrum
connection to the chain
through an http connection:
> w3kit http -b arbitrum
through a websocket connection:
> w3kit ws -b arbitrum
retrieving an account data
> w3kit account -b arbitrum -a <account>
avalanche
connection to the chain
through an http connection:
> w3kit http -b avalanche
through a websocket connection:
> w3kit ws -b avalanche
retrieving an account data
> w3kit account -b avalanche -a <account>
near
connection to the chain
through an http connection:
> w3kit http -b near
through a websocket connection:
> w3kit ws -b near
retrieving an account data
> w3kit account -b near -a <account>
optimism
connection to the chain
through an http connection:
> w3kit http -b optimism
through a websocket connection:
> w3kit ws -b optimism
retrieving an account data
> w3kit account -b optimism -a <account>
polygon
connection to the chain
through an http connection:
> w3kit http -b polygon
through a websocket connection:
> w3kit ws -b polygon
retrieving an account data
> w3kit account -b polygon -a <account>
solana
connection to the chain
through an http connection:
> w3kit http -b solana -a
through a websocket connection:
> w3kit ws -b solana -a
retrieving an account data
> w3kit account -b solana -a <account>
Dependencies
~28–45MB
~742K SLoC