Run Code Examples
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/iota.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 iota.rs
- Create your
.env
file by making a copy of the.env.example
file by running the following command:
cp .env.example .env
Run Code Examples
The iota.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 node_api_core_get_health --release
Examples List
You can replace the node_api_core_get_health
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.
Build the Examples
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
Build All the Examples
Since the examples are written in TypeScript, they first need to be compiled to JavaScript, before you can run them. To do this run the following commands in the examples folder :
npm i
npm run build
After you have run this command, you should have a newly create dist
folder within the examples
folder with all the
compiled examples.
Build a Single Example
You can also use tsc exampleName.js
from the examples
folder to compile a specific example.
Run the Examples
To run any Node.js example, you need to select any of the
Node.js examples and run it with your local
Node.js interpreter. The following snippet runs 00_get_info.js
from the project root:
node client/bindings/nodejs/examples/dist/00_get_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 iota.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/iota.rs.git
Then, move into the Java examples folder by running the following command:
cd iota.rs/client/bindings/java/examples
Run Code Examples
The IOTA Client 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=GetInfo
To run another example of your choice, replace GetInfo
with the name of any other example from the Java examples directory.