Skip to main content

Post a Data Block

You can post a data block by adding hex encoded data as options when you create a block.

The following code example will:

  1. Create a Client which will connect to the Shimmer Testnet.
  2. Create the options with the hex encoded data.
  3. Create a SecretManager from a mnemonic.
  4. Create and post the block with the data from step 2.
  5. Generate a public address.
Iota.js

You can also find this guide in the native iota.js library

Post a Block

Code Example

Dotenv

This example uses dotenv, which is not safe to use in production environments.

client/examples/node_api_core/04_post_block.rs
loading...

Run the Example

Run the example by running the following command:

cargo run --example node_api_core_post_block --release -- https://api.testnet.shimmer.network
  • You can replace https://api.testnet.shimmer.network with any node url.

Expected Output

Posted: BlockId(0x2f1de84a2977afeb413d44d8069c67e2df3f8da9ee6ba9dd62190e5256469169)

Post a Raw Block

Code Example

Dotenv

This example uses dotenv, which is not safe to use in production environments.

client/examples/node_api_core/05_post_block_raw.rs
loading...

Run the Example

Run the example by running the following command:

cargo run --example node_api_core_post_block_raw --release -- https://api.testnet.shimmer.network
  • You can replace https://api.testnet.shimmer.network with any node url.

Expected Output

Posted: BlockId(0x9982248af2d1b41f5f9f5b439d113ebe9611b6ace17ae487f2b3104b00b9950e)