@aryze/reforge
v1.0.4
Published
TypeScript SDK for Aryze Reforge cross-chain bridge protocol
Readme
@aryze/reforge
TypeScript SDK for Aryze Reforge cross-chain bridge protocol.
Installation
npm install @aryze/reforgeQuick Start
1. Configuration
import reforge from '@aryze/reforge';
// AWS-compatible configuration (recommended)
const config = reforge.createAWSConfig({
apiKey: 'your-api-key',
apiUrl: 'https://api.aryze.io/history/v1',
});
reforge.configure(config);2. Initiate Reforge
import reforge, { IReforgeInitiate } from '@aryze/reforge';
const data: IReforgeInitiate = {
chainIdHex0: '0x1', // Source chain (Ethereum)
chainIdHex1: '0x89', // Destination chain (Polygon)
token0: '0x...', // Source token address
token1: '0x...', // Destination token address
amount0: '1000000000000000000', // Amount in wei
priceToken0InUSD: 1.0, // USD price
tx0: '0x...', // Source transaction hash
account0: '0x...', // Source account
tx0Timestamp: Math.floor(Date.now() / 1000),
tokenType: 'erc20',
};
const result = await reforge.initiateReforge(data);
console.log(result); // { data: { success: true } } or { error: "..." }3. Finish Reforge
import reforge, { IReforgeFinish, HistoryId } from '@aryze/reforge';
const data: IReforgeFinish = {
historyId: '0x1_0x...' as HistoryId, // From initiate response
amount1: '990000000', // Amount received
priceToken1InUSD: 1.0, // USD price
tx1: '0x...', // Destination transaction hash
tx1Timestamp: Math.floor(Date.now() / 1000),
};
const result = await reforge.finishReforge(data);
console.log(result); // { data: { success: true } } or { error: "..." }Environment Variables
Create a .env file for your API credentials:
API_KEY=your-api-key
API_URL=https://api.aryze.io/history/v1Then in your code:
const config = reforge.createAWSConfig({
apiKey: process.env.API_KEY,
apiUrl: process.env.API_URL,
});AWS API Gateway Compatibility
The SDK includes AWS-compatible configuration that resolves common CORS and header issues:
// AWS-compatible configuration (automatically enables minimal mode)
const awsConfig = reforge.createAWSConfig({
apiKey: 'your-api-key',
apiUrl: 'https://your-api-gateway.amazonaws.com/prod',
});
// Manual configuration with minimal mode
reforge.configure({
apiKey: 'your-api-key',
apiUrl: 'https://your-api-gateway.amazonaws.com/prod',
includeUserAgent: false, // Disable User-Agent header
minimalMode: true, // Use minimal fetch options
debug: false, // Disable debug logging
});TypeScript Support
The SDK is written in TypeScript and provides full type definitions:
import reforge, {
IReforgeInitiate,
IReforgeFinish,
ActionResponse,
HistoryId,
TokenType,
} from '@aryze/reforge';Error Handling
All methods return a consistent response format:
const result = await reforge.initiateReforge(data);
if (result.error) {
console.error('Operation failed:', result.error);
} else {
console.log('Operation succeeded:', result.data);
}Token Types
Supported token types:
'erc20'- ERC20 tokens'erc721'- ERC721 NFTs'erc1155'- ERC1155 multi-tokens
Chain IDs
Use hex format for chain IDs:
- Ethereum:
'0x1' - Polygon:
'0x89' - Arbitrum:
'0xa4b1' - Optimism:
'0xa'
License
MIT
