Skip to main content
This guide demonstrates how to create, sign, and broadcast a transaction using the Adamik API with StarkNet. This tutorial is perfect for developers who want to leverage Adamik to power their StarkNet workflow, ensuring secure and efficient transaction management.

Prerequisites

  • Node.js and npm installed
  • Basic understanding of StarkNet blockchain and transaction workflows
  • Familiarity with StarkNet libraries

Step-by-Step Guide

1. Setting Up the Environment

Install the required dependencies:

2. Writing the Script

Below is the script that handles StarkNet transactions, including wallet deployment and transfers: You can find the complete code example in the Adamik GitHub repository.

3. Explanation

  • Key Generation: The script uses the StarkNet curve to generate a public key from your private key.
  • Address Encoding: Before making a transfer, we need to get our wallet address using the Adamik API’s address encode endpoint.
  • Transaction Encoding: The transaction details are passed to the Adamik API, which encodes the transaction specifically for StarkNet.
  • Signing: The encoded transaction is signed using StarkNet’s signature scheme.
  • Broadcasting: The signed transaction is broadcast to the StarkNet network via the Adamik API.
  • Account Deployment: The script also handles the case where the account hasn’t been deployed yet, automatically creating a deployment transaction if needed.

4. Troubleshooting

  • Invalid Signature: Ensure you’re using the correct private key and StarkNet curve for signing.
  • Gas Fees: Make sure your wallet has enough funds to cover gas fees.

5. Get in Touch

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