Methods
This section provides detailed documentation for all methods available in the HyperliquidStaker class. Each method includes parameters, return values, and practical examples.
buildSpotToStakingTx
Builds a transaction to transfer HYPE tokens from your spot account to your staking account. This transfer is instant and is the first step before you can delegate tokens to validators.
Parameters
amount
string
Yes
Amount in HYPE (e.g., '100')
Response
{
tx: UnsignedTx // Transaction object for signing
}Example
const { tx } = await staker.buildSpotToStakingTx({
amount: '100' // Transfer 100 HYPE to staking account
})
const { signedTx } = await staker.sign({
signer,
signerAddress: '0xYourAddress',
tx
})
const { txHash } = await staker.broadcast({
signedTx,
delegatorAddress: '0xYourAddress'
})
console.log('Transfer transaction hash:', txHash)Further Reading
buildWithdrawFromStakingTx
Builds a transaction to transfer HYPE tokens from your staking account back to your spot account. Withdrawals enter a 7-day unstaking queue, and each address can have a maximum of 5 pending withdrawals.
Parameters
amount
string
Yes
Amount in HYPE (e.g., '50')
Response
Example
Withdrawal Limits:
Each withdrawal takes exactly 7 days from submission time
Maximum of 5 pending withdrawals per address
You must have sufficient unstaked balance in your staking account (undelegate from validators first if needed)
Further Reading
buildStakeTx
Builds a transaction to delegate (stake) HYPE tokens from your staking account to a validator. Each delegation has a 1-day lockup period before it can be undelegated.
Parameters
validatorAddress
string
Yes
Validator's address in 42-character hexadecimal format (0x...)
amount
string
Yes
Amount in HYPE (e.g., '100')
Response
Example
Further Reading
buildUnstakeTx
Builds a transaction to undelegate (unstake) HYPE tokens from a validator. Undelegation is instant - tokens immediately return to your staking account (not your spot account).
Parameters
validatorAddress
string
Yes
Validator's address in 42-character hexadecimal format (0x...)
amount
string
Yes
Amount in HYPE (e.g., '25')
Response
Example
Important: Undelegation only moves HYPE back to your staking account, not your spot account. To move tokens to your spot account, you must also call buildWithdrawFromStakingTx() which has a 7-day waiting period.
Complete Unstaking Flow:
Further Reading
getStakingSummary
Retrieves a summary of staking information for an address, including total delegated amount, undelegated balance in staking account, and pending withdrawals. This is a read-only operation with no gas costs.
Parameters
delegatorAddress
string
Yes
Address to query (0x...)
Response
Example
Further Reading
getDelegations
Retrieves all active delegations for an address, showing individual validator delegations with amounts and lockup status. This is a read-only operation with no gas costs.
Parameters
delegatorAddress
string
Yes
Address to query (0x...)
Response
Example
Further Reading
getSpotBalances
Retrieves spot account balances for all tokens, including HYPE and USDC. This is a read-only operation with no gas costs.
Parameters
delegatorAddress
string
Yes
Address to query (0x...)
Response
Example
Further Reading
getDelegatorRewards
Retrieves staking rewards history for a delegator. This is a read-only operation with no gas costs.
Parameters
delegatorAddress
string
Yes
Address to query (0x...)
Response
Example
Further Reading
getDelegatorHistory
Retrieves the complete delegation event history for an address. This method is essential for verifying transaction success since Hyperliquid doesn't provide transaction status queries.
Parameters
delegatorAddress
string
Yes
Address to query (0x...)
Response
Example
Verifying Transaction Success:
Transaction Confirmation: Hyperliquid's API doesn't provide transaction status queries by hash. Always use getDelegatorHistory() to verify that your transaction was successfully processed. Wait 2-3 seconds after broadcasting before checking history.
Further Reading
sign
Signs an unsigned transaction using EIP-712 typed data signing. This method works with any Chorus One signer (Fireblocks, Local, etc.).
Parameters
signer
Signer
Yes
Signer instance (FireblocksSigner, LocalSigner, etc.)
signerAddress
string
Yes
Address performing the signature (0x...)
tx
UnsignedTx
Yes
Transaction object from buildXxxTx methods
Response
Example
Using Fireblocks Signer:
Using Local Signer:
Further Reading
broadcast
Broadcasts a signed transaction to the Hyperliquid network. Returns a transaction hash.
Parameters
signedTx
string
Yes
Signed transaction from sign() method
delegatorAddress
string
Yes
Address that signed the transaction (0x...)
Response
Example
Further Reading
Complete Transaction Flow:
Error Handling:
Further Reading
Last updated
Was this helpful?