Run Code Examples
Hornet Node
Most of the examples require a Hornet Node running the Stardust upgrade. You can connect to a node you trust, use the public API, run your own node or run a local private tangle
Public API
You can use the Shimmer Testnet as well as its Faucet to quickly run the examples.
Run Your Own Node
If you want direct access to the Tangle, you can set up a HORNET node using docker.
Run a Local Private Tangle
If you want to run the examples locally, you can set up a private tangle in a few simple steps.
Language Specific Instructions
Each language has different set up instructions you need to follow to get the code examples up and running.
- Rust
- Nodejs
- Python
- Java
Prerequisites
Before you can run the examples, please refer to the Rust Getting Started guide to install the library.
Clone the Repository
To run the rust examples, you will first need to clone the repository. You can do so by running the following command:
git clone git@github.com:iotaledger/wallet.rs.git
Set Up Your .env file
After you have cloned the project, you should:
- Move into the project directory by running the following command:
cd wallet.rs
- Create your
.env
file by making a copy of the.env.example
file by running the following command:
cp .env.example .env
You should update the NODE_URL
and FAUCET_URL
values to match the Hornet node you want to use.
Run Code Examples
The wallet.rs library has numerous examples
you can run to get acquainted with the library. After you have followed the instructions to
install the library, you can run any example with the following
command from the examples
directory:
cargo run --example 0_generate_addresses --release
Examples List
You can replace the 0_generate_addresses
by any other example from the Rust examples directory.
You can get a full list of examples by running the following command:
cargo run --example
Prerequisites
Before you can run the examples, please refer to the Node.js Getting Started guide to install the library.
Set Up Your .env
File
The examples use variables from a .env
file. Though you can create your own, for the examples you can simply copy the
existing .env.example
file. You can
do this running the following command from the bindings/nodejs
directory:
cp .env.example .env
Install Dependencies
Before you can try out the examples, you must install the necessary dependencies using npm. You can do this by running
the following command from the binding/nodejs
directory:
npm i
Build the Library
Once you have set up your .env
file and installed the necessary dependencies
, you can build the library by running the following command:
npm run build
Run the Examples
The wallet.rs library has numerous examples you can run to get acquainted with the library. After you have followed the instructions to build the library, you can run any Node.js example. You will need to select any of the Node.js examples and run it with your local Node.js interpreter.
To run examples, you will need to change to the bindings/nodejs/examples
directory, and run any example.
The following command will run the 10-node-info.js
example:
node 10-node-info.js
Prerequisites
Before you can run the examples, please refer to the Python Getting Started guide to install the library.
Run Code Examples
The wallet.rs library has numerous examples
you can run to get acquainted with the library. After you have followed the instructions to
install the library, you can run any example with the following
command from the bindings/python
directory:
python3 example/[example file name]
Where [example file name] is one of the examples.
For instance, to run
00_get_info.py
,
you should run:
python3 examples/00_get_info.py
Clone the Repository
To run the examples, you will first need to clone the repository. You can do so by running the following command:
git clone git@github.com:iotaledger/wallet.rs.git
Then, move into the Java examples folder by running the following command:
cd wallet.rs/bindings/java/examples
Run Code Examples
The IOTA Wallet Java library has numerous examples
you can run to get acquainted with the library. You can run any example with the following
command from the examples
directory:
.././gradlew run -Pexample=CreateAccount
To run another example of your choice, replace CreateAccount
with the name of any other example from the Java examples directory.