- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control. - Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities. - Created .gitmodules to include OpenZeppelin contracts as a submodule. - Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment. - Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks. - Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring. - Created scripts for resource import and usage validation across non-US regions. - Added tests for CCIP error handling and integration to ensure robust functionality. - Included various new files and directories for the orchestration portal and deployment scripts.
6.0 KiB
6.0 KiB
MetaMask Integration Guide
Complete guide for integrating ChainID 138 (DeFi Oracle Meta Mainnet) with MetaMask.
Overview
This guide covers how to add ChainID 138 to MetaMask, add tokens, and integrate wallet functionality into your dapp.
Network Information
- ChainID: 138 (0x8a in hex)
- Chain Name: DeFi Oracle Meta Mainnet
- Native Currency: ETH (18 decimals)
- RPC URLs:
- Primary:
https://rpc.d-bis.org - Secondary:
https://rpc2.d-bis.org - WebSocket:
wss://rpc.d-bis.org
- Primary:
- Block Explorer:
https://explorer.d-bis.org - Domain:
d-bis.org(Cloudflare DNS/SSL)
Adding the Network
Option 1: Using the MetaMask SDK
import { addOrSwitchNetwork } from '@defi-oracle/metamask-sdk';
// Add or switch to ChainID 138
await addOrSwitchNetwork();
Option 2: Using wallet_addEthereumChain
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x8a',
chainName: 'DeFi Oracle Meta Mainnet',
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18
},
rpcUrls: ['https://rpc.d-bis.org', 'https://rpc2.d-bis.org'],
blockExplorerUrls: ['https://explorer.d-bis.org'],
iconUrls: ['https://explorer.d-bis.org/images/logo.png']
}]
});
Option 3: Using Chainlist
- Visit chainlist.org
- Search for "ChainID 138" or "DeFi Oracle Meta"
- Click "Add to MetaMask"
- Approve the network addition in MetaMask
Option 4: Manual Addition
- Open MetaMask
- Click the network dropdown
- Click "Add Network"
- Click "Add a network manually"
- Enter the network details:
- Network Name: DeFi Oracle Meta Mainnet
- RPC URL:
https://rpc.d-bis.org - Chain ID: 138
- Currency Symbol: ETH
- Block Explorer URL:
https://explorer.d-bis.org
Switching Networks
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0x8a' }]
});
Adding Tokens
Using the SDK
import { addToken } from '@defi-oracle/metamask-sdk';
await addToken(
'0xYourTokenAddress',
'WETH',
18,
'https://explorer.d-bis.org/images/tokens/weth.png'
);
Using wallet_watchAsset (EIP-747)
await window.ethereum.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: '0xYourTokenAddress',
symbol: 'WETH',
decimals: 18,
image: 'https://explorer.d-bis.org/images/tokens/weth.png'
}
}
});
Checking Current Network
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
if (chainId === '0x8a') {
console.log('Connected to ChainID 138');
}
Listening to Network Changes
window.ethereum.on('chainChanged', (chainId) => {
if (chainId === '0x8a') {
console.log('Switched to ChainID 138');
} else {
console.log('Switched to another network');
}
});
Complete Integration Example
async function connectToChain138() {
// Check if MetaMask is installed
if (typeof window.ethereum === 'undefined') {
alert('Please install MetaMask');
return;
}
try {
// Get current chain ID
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
// If not on ChainID 138, switch or add
if (chainId !== '0x8a') {
try {
// Try to switch first
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0x8a' }]
});
} catch (error) {
// If switch fails, network might not be added
if (error.code === 4902) {
// Add the network
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x8a',
chainName: 'DeFi Oracle Meta Mainnet',
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18
},
rpcUrls: ['https://rpc.d-bis.org'],
blockExplorerUrls: ['https://explorer.d-bis.org']
}]
});
} else {
throw error;
}
}
}
console.log('Connected to ChainID 138');
} catch (error) {
console.error('Error connecting to ChainID 138:', error);
}
}
Token List
See the official token list at: metamask/token-list.json
Tokens are automatically detected by MetaMask when they appear on 2+ reputable token lists. To enable auto-detection:
- Add your token to the official token list
- Submit the token list to reputable aggregators (CoinGecko, etc.)
- Ensure token metadata is available on Blockscout
Troubleshooting
MetaMask not detected
if (typeof window.ethereum === 'undefined') {
alert('Please install MetaMask');
window.open('https://metamask.io/download/', '_blank');
}
Network already added
If you get an error that the network is already added, use wallet_switchEthereumChain instead.
RPC endpoint errors
- Verify RPC URL is correct:
https://rpc.d-bis.org - Check network connectivity
- Verify RPC node is running and accessible
- Check firewall/security settings
Token not showing
- Verify token address is correct
- Check token contract is deployed on ChainID 138
- Verify token metadata (symbol, decimals) is correct
- Ensure token logo URL is accessible
Security Best Practices
- Verify RPC URLs: Always use the official RPC URLs from this documentation
- Verify Explorer URLs: Use the official Blockscout explorer
- Verify Token Addresses: Double-check token contract addresses before adding
- Avoid Phishing: Only add networks from trusted sources
- Check Domain: Verify you're on the official domain (d-bis.org)