🕹 w3kit: a web3 toolkit in rust


tl;dr







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.


creating a .env


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


retrieve an account's balance


through an http connection:

```

w3kit http -b ethereum -a 0xbA4C081942E6a25cAF87c5489B91b449c67f3078

✅ connecting to "ethereum" ✅ retrieving balances... 💰 account 0xba4c081942e6a25caf87c5489b91b449c67f3078 👉 0.0672775267238201 ETH ```

through a websocket connection:

```

w3kit ws -b ethereum -a 0xbA4C081942E6a25cAF87c5489B91b449c67f3078

✅ connecting to "ethereum" ✅ retrieving balances... 💰 account 0xba4c081942e6a25caf87c5489b91b449c67f3078 👉 0.0672775267238201 ETH ```



arbitrum


retrieve an account's balance


through an http connection:

```

w3kit http -b arbitrum -a ```


through a websocket connection:

```

w3kit ws -b arbitrum -a ```



avalanche


retrieve an account's balance


through an http connection:

```

w3kit http -b avalanche -a ```


through a websocket connection:

```

w3kit ws -b avalanche -a ```



near


retrieve an account's balance


through an http connection:

```

w3kit http -b near -a ```


through a websocket connection:

```

w3kit ws -b near -a ```



optimism


retrieve an account's balance


through an http connection:

```

w3kit http -b optimism -a ```


through a websocket connection:

```

w3kit ws -b optimism -a ```



polygon


retrieve an account's balance


through an http connection:

```

w3kit http -b polygon -a ```


through a websocket connection:

```

w3kit ws -b polygon -a ```



solana


retrieve an account's balance


through an http connection:

```

w3kit http -b solana -a ```


through a websocket connection:

```

w3kit ws -b solana -a ```