# How to connect to MAAL Chain

For RPC URLs for our testnet and mainnet [visit](/maal-network-details.md)

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maalscan.io/how-to-connect-to-maal-chain.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
