Submitting Transactions

Submitting a transaction to the Celestium network involves creating a signed transaction and broadcasting it to the network through an RPC node. This section provides a step-by-step guide on how to submit transactions to Celestium Testnet.


1. Prepare a Transaction

A transaction can transfer CLT tokens, interact with a smart contract, or deploy a new contract. Transactions must include:

  • From: Sender’s address.

  • To: Recipient’s address (optional for contract creation).

  • Value: Amount of CLT to send (in wei).

  • Gas Limit: Maximum gas units to consume.

  • Gas Price: Fee per unit of gas (in wei).

  • Data: Optional data payload (e.g., smart contract call).


2. Sign the Transaction

Transactions must be signed using the sender’s private key. Popular libraries like ethers.js or web3.js can help with signing:

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("http://rpc-private-testnet.celestium.network");
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);

const tx = {
  to: "0xRecipientAddress",
  value: ethers.parseEther("0.1"),
  gasLimit: 21000,
  gasPrice: ethers.parseUnits("1", "gwei")
};

const transactionResponse = await wallet.sendTransaction(tx);
console.log(`Transaction hash: ${transactionResponse.hash}`);

Replace PRIVATE_KEY and 0xRecipientAddress with your actual data.


3. Broadcast the Transaction

If you sign the transaction offline, broadcast it using eth_sendRawTransaction:

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_sendRawTransaction",
  "params":["0xSignedTransactionData"],
  "id":1
}'

Replace 0xSignedTransactionData with the signed transaction hex string.


4. Check Transaction Status

Use eth_getTransactionReceipt to check the status:

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_getTransactionReceipt",
  "params":["0xTransactionHash"],
  "id":1
}'

If the receipt is null, the transaction is still pending.


5. View on Explorer

Track your transaction on http://testnet.celestium.network using your transaction hash.


Best Practices

  • Use eth_estimateGas to calculate gas before sending.

  • Ensure your balance covers the transaction value and gas fees.

  • Double-check your private key security; never expose it publicly.

This approach ensures that transactions are processed smoothly on the Celestium network.

Last updated