Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/epicchainlabs/epicchain-js

EpicChain JS Develop is a powerful toolkit designed for developers to run a full EpicChain blockchain node using Node.js and MongoDB.
https://github.com/epicchainlabs/epicchain-js

blockchain-development blockchain-node decentralized-network epicchain epicchain-js epicchain-toolkit full-node-setup mongo-db node-js-development nodejs

Last synced: 9 days ago
JSON representation

EpicChain JS Develop is a powerful toolkit designed for developers to run a full EpicChain blockchain node using Node.js and MongoDB.

Awesome Lists containing this project

README

        


epicchain-js


Running EpicChain Blockchain Full Node with Node.js and MongoDB



npm version

---

## ๐ŸŒ **Overview**

**`epicchain-js`** is a comprehensive Node.js package designed specifically for developers and blockchain enthusiasts to interact with the **EpicChain blockchain** effortlessly. This package acts as a bridge between your application and the EpicChain network, allowing you to synchronize and query blockchain data, manage nodes, and easily perform various blockchain operations using JavaScript.

EpicChain is built for scalability, speed, and security, and `epicchain-js` fully utilizes these features. By integrating MongoDB as a storage backend, you can synchronize the blockchain state across nodes, making the entire process faster and more reliable.

This tool can be used in various scenarios such as:

- Running **full nodes** for the EpicChain blockchain.
- Interacting with the blockchainโ€™s **RPC methods**.
- Synchronizing blockchain data with MongoDB for permanent storage.
- **Querying** blockchain information, such as block height, transaction details, and more.

---

## ๐Ÿš€ **Getting Started**

To begin working with `epicchain-js`, it's essential to ensure that your development environment meets the necessary requirements and dependencies. Follow the instructions below to set everything up properly.

### ๐Ÿ“ **Preparations**

Before diving into the code, ensure that you have **MongoDB** installed and properly configured. MongoDB 3.2 or newer is required to handle the blockchain synchronization and storage features provided by this package. MongoDB will store blockchain data locally, ensuring efficient and quick access to blockchain state across your applications.

- **MongoDB Installation**: You can install MongoDB via [MongoDBโ€™s official website](https://www.mongodb.com/try/download/community).
- **MongoDB Connection**: Ensure that MongoDB is running on your local machine or a remote server, and you have the appropriate connection string to use it in your project.

### โš™๏ธ **System Requirements**

Before starting, ensure you have the following installed on your system:

- **Node.js** v8 or above (LTS versions are recommended for stability).
- **MongoDB** v3.2+ (This is a critical requirement for synchronizing data with the blockchain).

If you're unfamiliar with how to install **Node.js** or **MongoDB**, here are some quick resources:
- [Node.js Download](https://nodejs.org/)
- [MongoDB Installation Guide](https://docs.mongodb.com/manual/installation/)

---

## ๐Ÿ“ฆ **Installation**

To get started with `epicchain-js`, install it using **npm**, the Node.js package manager. This package can be installed directly from the npm registry, ensuring that you always get the latest stable version.

1. **Basic Installation**:

Use the following command to install the package in your project:

```bash
$ npm install --save @epicchain/epicchain-js
```

2. **Installing the Development Version**:

If you want to experiment with the latest code or contribute to the project, you can install the development version directly from the GitHub repository:

```bash
$ npm install --save git://github.com/epicchainlabs/epicchain-js.git#develop
```

This will install the latest development changes, but please note that this version may be less stable than the official release.

---

## ๐Ÿƒโ€โ™‚๏ธ **Quick Start**

Once installed, you can start using `epicchain-js` in your project. Hereโ€™s a simple walkthrough to get you started with **EpicChain** interactions.

### **Step 1: Import the Package**

In your projectโ€™s entry file, import the `epicchain-js` module like this:

```js
const EpicChain = require('@epicchain/epicchain-js').EpicChain;
```

This will give you access to all the functionality you need to interact with the EpicChain blockchain.

### **Step 2: Connecting to a Network**

You can choose between connecting to the **testnet** or the **mainnet**. Both networks offer real-time blockchain data, but the testnet is safer for experimentation and testing purposes.

#### Example for **Testnet**:

```js
// Create an instance for the testnet
const testnetEpicChain = new EpicChain({ network: 'testnet' });

// Wait for the node to be ready before making API calls
testnetEpicChain.mesh.on('ready', () => {
// Fetch block count from the testnet
testnetEpicChain.api.getBlockCount().then((res) => {
console.log('Testnet Block Count:', res);
});
});
```

#### Example for **Mainnet**:

```js
// Create an instance for the mainnet
const mainnetEpicChain = new EpicChain({ network: 'mainnet' });

// Wait for the node to be ready before making API calls
mainnetEpicChain.mesh.on('ready', () => {
// Fetch block data for block number 1000 from the mainnet
mainnetEpicChain.api.getBlock(1000).then((res) => {
console.log('Mainnet Block 1000 Hash:', res.hash);
});
});
```

---

## โšก **Node Setup with MongoDB Synchronization**

Once your instance is set up, you can start interacting with the **EpicChain** node and synchronize it with **MongoDB**. This allows your node to track the state of the blockchain and store data in a local database for fast retrieval.

### Example Configuration:

```js
const options = {
network: 'testnet', // Specify the network (testnet or mainnet)
storageType: 'mongodb', // Use MongoDB for data synchronization
storageOptions: {
connectionString: 'mongodb://localhost/epicchain_testnet', // Connection string for MongoDB
},
};

// Create the EpicChain instance with the options
const epicchain = new EpicChain(options);

// Wait for the storage to be ready and fetch the highest block height
epicchain.storage.on('ready', () => {
epicchain.storage.getHighestBlockHeight().then((res) => {
console.log('Highest Block Height:', res);
});
});
```

This setup will connect your node to **MongoDB** and synchronize the blockchain data for efficient querying and storage.

---

## ๐Ÿ“š **Documentation**

The documentation provides more detailed information and covers advanced features of the `epicchain-js` package. Be sure to check out the following links to expand your knowledge:

- [Official Documentation](http://epicchainlabs.io/epicchain-js/)
- [Code Examples Repository](https://github.com/rockacola/epicchain-js-examples)

---

## ๐Ÿ—‚๏ธ **Blockchain Bootstrap Files**

To bootstrap your own EpicChain instance or to run a node without downloading the entire blockchain, refer to the **[Bootstrap Files Documentation](https://github.com/epicchainlabs/epicchain-js/blob/main/BOOTSTRAP_FILES.md)**.

---

## โš™๏ธ **Options and Customization**

The configuration options are highly customizable to meet your needs. You can specify different networks, storage configurations, and more. For a full list of customizable options, refer to the **[Optional Parameters Documentation](https://github.com/epicchainlabs/epicchain-js/blob/main/OPTIONAL_PARAMETERS.md)**.

---

## ๐Ÿ› ๏ธ **Events**

`epicchain-js` is event-driven. Many of the methods emit events that you can listen to in order to perform specific actions when certain events occur. Learn more about the available events in the **[Event Emitters Documentation](https://github.com/epicchainlabs/epicchain-js/blob/main/EVENT_EMITTERS.md)**.

---

## ๐Ÿค **Contribution**

We actively encourage contributions from the community to improve and extend `epicchain-js`. Whether you are fixing bugs, adding new features, or enhancing the documentation, your contributions are welcome.

Before you contribute, please read our [Contributing Guidelines](https://github.com/epicchainlabs/epicchain-js/blob/main/.github/CONTRIBUTING.md) to ensure a smooth process. You can contribute by forking the repository, making your changes, and submitting a pull request.

By contributing, you agree to license your contributions under the **MIT License**.

---

## ๐Ÿ“œ **License**

`epicchain-js` is an open-source package licensed under the **MIT License**.

For full licensing information, please visit the [LICENSE](https://github.com/epicchainlabs/epicchain-js/blob/main/LICENSE.md) file in the repository.

### Authors:

- [@xmoohad](https://github.com/xmoohad)

---

### ๐Ÿ **Join us in revolutionizing blockchain technology with EpicChain!**

---

This version includes in-depth explanations of each section, offering more detailed insights for developers and users while ensuring a clean and modern design style. It focuses on guiding users through setup, configuration, and contributing to the project.