# How to connect to MAAL Chain

For RPC URLs for our testnet and mainnet [visit](https://docs.maalscan.io/maal-network-details)

When interacting with our own blockchain built on the Polygon (formerly Matic) network, you can use various JSON-RPC endpoints to send transactions, broadcast them, and receive transaction-related information. Here are some common JSON-RPC endpoints you can use with Web3.js to interact with our blockchain:

1. **Send Transaction:** To send a transaction to our blockchain, you typically use the `eth_sendTransaction` method. You'll need to construct a transaction object and sign it with the sender's private key.
2. **Broadcast Transaction:** After constructing and signing a transaction, you can broadcast it using the `eth_sendRawTransaction` method. This sends the signed transaction data to the network for processing.
3. **Get Transaction Receipt:** To retrieve information about a specific transaction, including its status and other details, you can use the `eth_getTransactionReceipt` method. This returns a receipt object containing information about the transaction's execution.
4. **Get Transaction by Hash:** If you want to get detailed information about a transaction using its transaction hash, you can use the `eth_getTransactionByHash` method.
5. **Get Transaction Count:** To retrieve the number of transactions sent from a specific address, you can use the `eth_getTransactionCount` method.

Here's how you might use these endpoints with Web3.js (javascript):

```javascript
const Web3 = require('web3');

const rpcUrl = 'https://node1-mainnet.maalscan.io';
const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl));

// Construct and send a transaction
const senderAddress = '0x...'; // Your sender's address
const privateKey = '0x...'; // Your sender's private key
const receiverAddress = '0x...'; // Receiver's address
const valueToSend = web3.utils.toWei('0.1', 'ether');

const nonce = await web3.eth.getTransactionCount(senderAddress);
const gasPrice = await web3.eth.getGasPrice();

const txObject = {
  nonce: nonce,
  to: receiverAddress,
  value: valueToSend,
  gasPrice: gasPrice,
  gas: 21000, // Gas limit for standard transactions
};

const signedTx = await web3.eth.accounts.signTransaction(txObject, privateKey);
const txHash = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log('Transaction Hash:', txHash);

// Get transaction receipt
const receipt = await web3.eth.getTransactionReceipt(txHash);
console.log('Transaction Receipt:', receipt);

// Get transaction details by hash
const txDetails = await web3.eth.getTransactionByHash(txHash);
console.log('Transaction Details:', txDetails);

// Get transaction count of an address
const transactionCount = await web3.eth.getTransactionCount(senderAddress);
console.log('Transaction Count:', transactionCount);
```

Please replace the placeholders (`'0x...'`) with actual addresses and keys. Also, remember that interacting with real blockchains involves real value transactions and security considerations, so exercise caution and test thoroughly before using this code in a production environment.
