41 lines
1.1 KiB
JavaScript
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();
|