> For the complete documentation index, see [llms.txt](https://docs.emc.network/emc-testnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emc.network/emc-testnet/emc-testnet/functions-of-nodeinterface/using-nodeinterface.md).

# Using NodeInterface

#### Installation and configuration

First, you need to install the libraries for interacting with EMC chain nodes. For example, you can useweb3.jsLibrary:

npm install web3

Then, configure your project to connect the EMC chain nodes:

const Web3 = require('web3'); const web3 = new Web3('<https://rpc.emcchain.io>'); // Replace with the RPC URL of the EMC chain

#### Query node information

The following is a sample code for querying basic information about a node:

async function getNodeInfo() {

&#x20;   const nodeInfo = await web3.eth.getNodeInfo();

&#x20;   console.log('Node Info:', nodeInfo);

}

getNodeInfo();

#### Query block information

The following is sample code to query specific block information:

async function getBlockInfo(blockNumber) {

&#x20;   const blockInfo = await web3.eth.getBlock(blockNumber);

&#x20;   console.log('Block Info:', blockInfo);

}

getBlockInfo(123456); //Replace with actual block number

#### Query transaction information

The following is sample code to query specific transaction information:

async function getTransactionInfo(txHash) {

&#x20;   const transactionInfo = await web3.eth.getTransaction(txHash);

&#x20;   console.log('Transaction Info:', transactionInfo);

}

getTransactionInfo('0x123...'); // Replace with actual transaction hash

#### Query account information

The following is sample code to query the balance of a specific account:

async function getAccountBalance(address) {

&#x20;   const balance = await web3.eth.getBalance(address);

&#x20;   console.log('Account Balance:', web3.utils.fromWei(balance, 'ether'), 'EMC');

}

getAccountBalance('0xabc...'); //Replace with actual account address

#### Interact with contracts

The following is sample code for calling smart contract methods on the chain:

const contractABI = \[ /\* Contract ABI \*/ ]; const contractAddress = '0xdef...'; // Replace with the actual contract address const contract = new web3.eth.Contract(contractABI, contractAddress);

async function callContractMethod() {

&#x20;   const result = await contract.methods.yourMethod().call();

&#x20;   console.log('Contract Method Result:', result);

}

callContractMethod();
