Prerequisites
Before you begin, make sure you have:- Completed the REST API setup guide
- Your MoonKey API key (test or live)
- A test user ID (or follow step 0 to create one)
All examples in this guide use test API keys. Replace
sk_test_your_api_key_here with your actual API key.Create a User (Optional)
If you want your wallet to be owned by a specific user, first create a user account:1. Create a Wallet
Let’s create an Ethereum wallet for your user:If a wallet of the same type already exists for the user, MoonKey will return the existing wallet instead of creating a new one.
2. Sign a Message
Now let’s sign a message with your newly created wallet:3. Send a Transaction
Finally, let’s send a transaction on Ethereum’s testnet, Sepolia:Broadcasting the Transaction
Thesigned_transaction is ready to be broadcast to the Ethereum network. You can use it with the eth_sendRawTransaction RPC method:
Understanding Transaction Parameters
When sending a transaction, you need to provide several parameters:Use tools like eth-converter.com to convert between decimal and hex values for ETH amounts and gas prices.
Creating Solana Wallets
MoonKey also supports Solana wallets. To create a Solana wallet, simply change thewallet_type:
Best Practices
Security
- Never expose API keys - Keep your secret API keys secure on your backend
- Use test keys for development - Test thoroughly before switching to live keys
- Validate user actions - Always verify that requests come from authenticated users
Transaction Safety
- Verify addresses - Always double-check recipient addresses before sending transactions
- Test on testnet first - Use Sepolia for Ethereum or Devnet for Solana before going to mainnet
- Monitor transaction status - Track transactions and handle failures gracefully
- Use appropriate gas limits - Ensure transactions have enough gas to complete
Error Handling
Always implement proper error handling for API requests:Troubleshooting
Common Issues
401 Unauthorized- Verify your API key is correct
- Ensure you’re using the
Bearertoken format - Check that your API key hasn’t been revoked
- Verify the wallet ID is correct
- Ensure the wallet belongs to your app
- Check that the user ID exists
- Verify the wallet has sufficient balance
- Check that gas limits and fees are appropriate
- Ensure the recipient address is valid
- Verify you’re on the correct network (testnet vs mainnet)
- Implement exponential backoff for retries
- Cache wallet data when possible
- Batch operations where appropriate
Support
Need help?- Check the API Reference for detailed endpoint documentation
- Review authentication setup for configuration help
- Contact support for technical assistance