JavaScript/Node.js interface to UltraNoteI cryptocurrency RPC/API services. This library provides a comprehensive set of methods to interact with UltraNoteI daemon and wallet services.
- Installation
- Quick Start
- Configuration
- API Reference
- Examples
- Error Handling
- Troubleshooting
- Contributing
- License
npm install ultranotei-apiMake sure you have UltraNoteI daemon and wallet services running:
- Start the network daemon (ultranoteid):
./ultranoteid- Start the wallet (ultranoteiwallet):
./ultranoteiwallet --rpc-bind-port 3333 --wallet-file my --password PASSWORDconst XUNI = require('ultranotei-api');
// Initialize the API client
const xuni = new XUNI({
daemonHost: 'http://localhost',
walletHost: 'http://localhost',
daemonRpcPort: 43000,
walletRpcPort: 3333,
timeout: 5000
});
// Get wallet status
xuni.status()
.then(status => console.log('Wallet status:', status))
.catch(error => console.error('Error:', error));
// Send a transaction (1.234567 XUNI)
xuni.send({
transfers: [{
address: 'xuni7Xd3NBbBiQNvv7vMLXmGMHyS8AVB6EhWoHo5EbGfR2Ki9pQnRTfEBt3YxYEVqpUCyJgvPjBYHp8N2yZwA7dqb4PjaGWuvs4',
amount: 1234567 // 1.234567 XUNI (6 decimal places)
}]
})
.then(result => console.log('Transaction successful:', result))
.catch(error => console.error('Transaction failed:', error));The XUNI constructor accepts the following configuration options:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
daemonHost |
string | Yes | - | Daemon host URL (http:// or https://) |
walletHost |
string | Yes | - | Wallet host URL (http:// or https://) |
daemonRpcPort |
number | Yes | - | Daemon RPC port (default: 43000) |
walletRpcPort |
number | Conditional | - | Wallet RPC port (required for wallet operations) |
timeout |
number | No | 5000 | Request timeout in milliseconds |
rpcUser |
string | No | - | RPC authentication username |
rpcPassword |
string | No | - | RPC authentication password |
- Daemon RPC Port: 43000
- Daemon P2P Port: 42000
- Wallet RPC Port: 3333 (configurable)
All API methods return Promises and should be used with .then()/.catch() or async/await.
Note: UltraNoteI uses 6 decimal places. This means:
1000000= 1.0 XUNI100000= 0.1 XUNI10000= 0.01 XUNI1000= 0.001 XUNI100= 0.0001 XUNI10= 0.00001 XUNI1= 0.000001 XUNI
All amount parameters in the API expect the raw amount (integer) with 6 decimal places.
height()- Get last block heightbalance()- Get wallet balancestransfers()- Get all transfersoutputs()- Get unlocked outputsreset()- Reset wallet cachestore()- Save wallet to diskoptimize()- Combine outputs
send(opts)- Send transferspayments(paymentId)- Get incoming paymentsmessages([opts])- Get transaction messages
createIntegrated(address, paymentId)- Create integrated addresssplitIntegrated(address)- Split integrated addresscreateDeposit(opts)- Create depositwithdrawDeposit(depositId)- Withdraw depositestimateFusion(opts)- Estimate fusionsendFusionTransaction(opts)- Send fusion transaction
info()- Get blockchain informationindex()- Get next block heightcount()- Get block countcurrencyId()- Get currency ID
blockHashByHeight(height)- Get block hash by heightblockHeaderByHeight(height)- Get block header by heightblockHeaderByHash(hash)- Get block header by hashlastBlockHeader()- Get last block headerblock(hash)- Get block by hashblocks(height)- Get blocks from height
transaction(hash)- Get transaction by hashtransactions(txs)- Get multiple transactionstransactionPool()- Get transaction poolsendRawTransaction(rawTx)- Send raw transaction
// Get wallet status and balance
const status = await xuni.status();
const balance = await xuni.balance();
console.log('Status:', status, 'Balance:', balance);
// Create new address
const newAddress = await xuni.createAddress();
console.log('New address:', newAddress);
// Get transaction history
const transfers = await xuni.transfers();
console.log('Transaction history:', transfers);// Send basic transaction (1.0 XUNI)
const result = await xuni.send({
transfers: [{
address: 'xuni7Xd3NBbBiQNvv7vMLXmGMHyS8AVB6EhWoHo5EbGfR2Ki9pQnRTfEBt3YxYEVqpUCyJgvPjBYHp8N2yZwA7dqb4PjaGWuvs4',
amount: 1000000, // 1.0 XUNI (6 decimal places)
message: 'Payment for services'
}],
mixIn: 6,
fee: 10000 // 0.00001 XUNI fee
});
console.log('Transaction result:', result);try {
const result = await xuni.send({
transfers: [{
address: 'invalid-address',
amount: 1000000 // 1.0 XUNI (6 decimal places)
}]
});
} catch (error) {
console.error('Transaction failed:', error);
// Error: address must be 99-character string beginning with Xuni
}The API returns Promise rejections with descriptive error messages:
'address must be 99-character string beginning with Xuni''paymentId must be 64-digit hexadecimal string''amount must be a raw amount of XUNI (X)'
'RPC server error'- Connection or server issues'RPC timeout'- Request timeout (5 seconds default)
- Connection refused
- Host not found
- Connection timeout
-
Connection refused
- Ensure daemon/wallet services are running
- Check firewall settings
- Verify host and port configuration
-
Authentication errors
- Check RPC username/password if required
- Verify daemon/wallet RPC authentication settings
-
Timeout errors
- Increase timeout setting for slow connections
- Check network connectivity
-
Method not found
- Ensure correct method name (check API reference)
- Verify required parameters are provided
For debugging, you can enable detailed logging:
const xuni = new XUNI({
daemonHost: 'http://localhost',
walletHost: 'http://localhost',
daemonRpcPort: 43000,
walletRpcPort: 3333,
timeout: 10000 // 10 second timeout
});
// Add request logging
const originalRequest = xuni.request;
xuni.request = function(...args) {
console.log('RPC Request:', args);
return originalRequest.apply(this, args);
};Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
git clone https://github.com/xun-project/ultranotei-api.git
cd ultranotei-api
npm install
npm testThis project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Check existing issues for solutions
- Review the API documentation
| API Version | UltraNoteI Daemon | UltraNoteI Wallet |
|---|---|---|
| 4.1.0 | v2.0.0+ | v2.0.0+ |
| 4.0.0 | v1.5.0+ | v1.5.0+ |
Always ensure your UltraNoteI services are compatible with the API version you're using.