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

Parameter
Type
Required
Description

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)

Transfers from spot to staking are instant. Once confirmed, the balance immediately appears in your staking account.

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

Parameter
Type
Required
Description

amount

string

Yes

Amount in HYPE (e.g., '50')

Response

Example

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

Parameter
Type
Required
Description

validatorAddress

string

Yes

Validator's address in 42-character hexadecimal format (0x...)

amount

string

Yes

Amount in HYPE (e.g., '100')

Response

Example

Delegation Considerations:

  • Each delegation has a 1-day lockup per validator

  • You can delegate to multiple validators simultaneously

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

Parameter
Type
Required
Description

validatorAddress

string

Yes

Validator's address in 42-character hexadecimal format (0x...)

amount

string

Yes

Amount in HYPE (e.g., '25')

Response

Example

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

Parameter
Type
Required
Description

delegatorAddress

string

Yes

Address to query (0x...)

Response

Example

This method provides a high-level overview of your staking position. To see individual delegations by validator, use getDelegations(). Note that this doesn't include your spot account balance - use getSpotBalances() for that.

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

Parameter
Type
Required
Description

delegatorAddress

string

Yes

Address to query (0x...)

Response

Example

Lockup Status: Each delegation has a lockedUntilTimestamp. If the current time is before this timestamp, you must wait before undelegating. After the lockup expires, you can undelegate any amount at any time.

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

Parameter
Type
Required
Description

delegatorAddress

string

Yes

Address to query (0x...)

Response

Example

The hold field represents tokens locked in open trading orders. To calculate available balance for transfers, subtract hold from total.

Further Reading


getDelegatorRewards

Retrieves staking rewards history for a delegator. This is a read-only operation with no gas costs.

Parameters

Parameter
Type
Required
Description

delegatorAddress

string

Yes

Address to query (0x...)

Response

Example

Reward Distribution:

  • Rewards accrue every minute based on validator performance

  • Distributed daily to all delegators

  • Auto-compounded to your delegated stake (no manual claiming required)

  • Based on minimum balance held during each staking epoch (100k rounds ~90 minutes)

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

Parameter
Type
Required
Description

delegatorAddress

string

Yes

Address to query (0x...)

Response

Example

Verifying Transaction Success:

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

Parameter
Type
Required
Description

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:

Hyperliquid uses EIP-712 typed data signing, not standard Ethereum transactions. The sign() method handles the EIP-712 formatting automatically.

Further Reading


broadcast

Broadcasts a signed transaction to the Hyperliquid network. Returns a transaction hash.

Parameters

Parameter
Type
Required
Description

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?