36673-vm/api/sign.js
Flatlogic Bot c255bd35c4 1
2025-12-05 05:27:33 +00:00

41 lines
1.1 KiB
JavaScript

const { Wallet } = require('ethers');
// This is the verifying contract address for Arbitrum from the documentation
const HYPERLIQUID_EXCHANGE_ADDRESS = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
const HYPERLIQUID_CHAIN_ID = 1337;
async function sign() {
const [,, privateKey, typedDataJson] = process.argv;
if (!privateKey || !typedDataJson) {
console.error('Usage: node sign.js <privateKey> <typedDataJson>');
process.exit(1);
}
try {
const wallet = new Wallet(privateKey);
const typedData = JSON.parse(typedDataJson);
const domain = {
name: 'Hyperliquid Exchange',
version: '1',
chainId: HYPERLIQUID_CHAIN_ID,
verifyingContract: HYPERLIQUID_EXCHANGE_ADDRESS,
};
const signature = await wallet.signTypedData(
domain,
typedData.types,
typedData.message
);
console.log(signature);
} catch (error) {
console.error('Error signing payload:', error);
process.exit(1);
}
}
sign();