Skip to main content
This guide demonstrates how to create, sign, and broadcast a transaction using the Adamik API along with the Stellar SDK for JavaScript. This tutorial is perfect for developers who want to integrate Adamik’s features into their Stellar workflows, ensuring secure and efficient transaction management.

Prerequisites

  • Node.js and npm installed
  • Basic understanding of Stellar and transaction workflows
  • Familiarity with the Stellar SDK

Step-by-Step Guide

1. Setting Up the Environment

Ensure you have the Stellar SDK installed in your project:

2. Writing the Script

Below is the script that handles the full transaction flow, from creating a wallet to broadcasting the signed transaction. You can find the complete code example in the Adamik GitHub repository.

3. Explanation

  • Wallet Creation: The script begins by creating a wallet using a Stellar secret key, which is crucial for managing private keys. Please note Adamik API doesn’t have the custody of the assets.
  • Transaction Encoding: The transaction details are passed to the Adamik API, which returns an encoded transaction with its hash. Note that amounts are in stroops (1 XLM = 10,000,000 stroops).
  • Signing: The transaction hash is signed directly using the Stellar Keypair’s sign method, producing a hex signature.
  • Broadcasting: The signed transaction is broadcast to the Stellar network using the Adamik API with the signature attached.

4. Troubleshooting

  • Invalid API Key: Ensure your Adamik API key is correct.
  • Network Issues: Verify network availability and Adamik API status.
  • Insufficient Balance: Ensure your account has enough XLM to cover the transaction amount plus fees.
  • Security Note: Never hardcode sensitive information like secret keys in your production environment.

5. Get in Touch

Connect with us through our Discord Server or directly through GitHub.