Examples
Using Adamik API with TON
This guide demonstrates how to create, sign, and broadcast a transaction using the Adamik API along with a TON signer. This tutorial is perfect for developers who want to leverage Adamikto power their TON workflow, ensuring secure and efficient transaction management.
Prerequisites
- Node.js and npm installed
- Basic understanding of TON blockchain and transaction workflows
- Familiarity with the TON libraries (
@ton/crypto
,@ton/ton
)
Step-by-Step Guide
1. Setting Up the Environment
Ensure you have the required TON libraries 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.
3. Explanation
- Key Pair Generation: The script generates a key pair from a mnemonic phrase using the
@ton/crypto
library, which is helpful for managing private keys and signing transactions on TON. Please note Adamik API doesn’t have the custody of the assets. - Transaction Encoding: The transaction details, such as sender, recipient, and amount, are passed to the Adamik API, which encodes the transaction for signing.
- Signing and Broadcasting: The encoded transaction is signed using the private key, and the signed transaction is then broadcast to the TON blockchain via the Adamik API.
4. Troubleshooting
- Invalid API Key: Ensure your Adamik API key is correct and up to date.
- Network Issues: Verify network availability and Adamik API status.
- Security Note: Never hardcode sensitive information such as mnemonic phrases or private keys in your production environment.
5. Get in Touch
Connect with us through our Discord Server or directly through GitHub.