Installation
Learn how to install and set up the Moromoro SDK in your project.
Prerequisites
Before installing the Moromoro SDK, ensure you have:
Node.js: Version 14.0 or higher
Package Manager: npm or yarn
ethers.js: Version 5.4.0 or higher (will be installed automatically)
Installation Methods
npm install @moromoro/moro-sdk ethersyarn add @moromoro/moro-sdk etherspnpm add @moromoro/moro-sdk ethersVerify Installation
After installation, verify that the package is installed correctly:
const { MoroBestRate } = require('@moromoro/moro-sdk')
console.log('Moromoro SDK loaded successfully!')Or in TypeScript/ES6:
import { MoroBestRate } from '@moromoro/moro-sdk'
console.log('Moromoro SDK loaded successfully!')Package Contents
The installed package includes:
Main Library: Pre-built JavaScript bundles
TypeScript Definitions: Full type definitions for TypeScript support
ES Modules: ES module builds for modern bundlers
Dependencies
The SDK has the following dependencies:
Required Dependencies
ethers:
^5.7.2- Ethereum library for interacting with the blockchain
Peer Dependencies
The SDK works with:
Node.js 14+
Modern browsers (Chrome, Firefox, Safari, Edge)
TypeScript Support
The SDK is written in TypeScript and includes full type definitions. No additional @types packages are needed.
TypeScript Configuration
Ensure your tsconfig.json includes:
{
"compilerOptions": {
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"lib": ["ES2020"],
"target": "ES2020"
}
}Browser Support
The SDK can be used in browser environments with bundlers like:
Webpack
Vite
Rollup
Parcel
Webpack Configuration
If using Webpack 5, add polyfills for Node.js core modules:
npm install --save-dev node-polyfill-webpack-plugin// webpack.config.js
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
module.exports = {
plugins: [
new NodePolyfillPlugin()
]
}Vite Configuration
For Vite projects:
npm install --save-dev @esbuild-plugins/node-globals-polyfill// vite.config.js
import { defineConfig } from 'vite'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
export default defineConfig({
optimizeDeps: {
esbuildOptions: {
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true
})
]
}
}
})Framework Integration
React
npm install @moromoro/moro-sdk ethers// src/hooks/useMoromoro.js
import { MoroBestRate } from '@moromoro/moro-sdk'
import { ethers } from 'ethers'
import { useMemo } from 'react'
export function useMoromoro(network = 'hyperevm') {
const moroClient = useMemo(() => {
const provider = new ethers.providers.JsonRpcProvider(
'https://rpc.hyperliquid.xyz/evm'
)
return new MoroBestRate(provider, network)
}, [network])
return moroClient
}Next.js
npm install @moromoro/moro-sdk ethers// lib/moromoro.ts
import { MoroBestRate } from '@moromoro/moro-sdk'
import { ethers } from 'ethers'
export function createMoroClient(network: string) {
const provider = new ethers.providers.JsonRpcProvider(
'https://rpc.hyperliquid.xyz/evm'
)
return new MoroBestRate(provider, network)
}Vue.js
npm install @moromoro/moro-sdk ethers// plugins/moromoro.js
import { MoroBestRate } from '@moromoro/moro-sdk'
import { ethers } from 'ethers'
export default {
install(app, options) {
const provider = new ethers.providers.JsonRpcProvider(options.rpcUrl)
const moroClient = new MoroBestRate(provider, options.network)
app.config.globalProperties.$moro = moroClient
}
}Environment Setup
Environment Variables
Create a .env file for your configuration:
# .env
RPC_URL=https://rpc.hyperliquid.xyz/evm
NETWORK=hyperevm
PRIVATE_KEY=your_private_key_hereUsing dotenv
npm install dotenvrequire('dotenv').config()
const { MoroBestRate } = require('@moromoro/moro-sdk')
const { ethers } = require('ethers')
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
const moroClient = new MoroBestRate(provider, process.env.NETWORK)Updating the SDK
Check Current Version
npm list @moromoro/moro-sdkUpdate to Latest Version
# Using npm
npm update @moromoro/moro-sdk# Using yarn
yarn upgrade @moromoro/moro-sdk# Using pnpm
pnpm update @moromoro/moro-sdkInstall Specific Version
npm install @moromoro/[email protected]Troubleshooting
Next Steps
Now that you have installed the SDK, proceed to:
Quick Start Guide - Learn basic usage
API Reference - Explore the full API
Examples - See code examples
Getting Help
If you encounter issues during installation:
Check GitHub Issues
Review the API Reference
Contact support through the official channels