Skip to main content

HolographWallet

The HolographWallet class manages a HolographAccount, allowing users to interact with their account via the configured networks.

1. Constructor Parameters

account

  • Type:
    HolographAccountrequired

The account object the wallet will use to sign transactions.

import { HolographAccountFactory, HolographWallet } from "@holographxyz/sdk";

const defaultAccount = HolographAccountFactory.createAccountUsingPrivateKey(
process.env.PRIVATE_KEY
);

const holographWallet = new HolographWallet({
account: defaultAccount,
});

chainsRpc

  • Type:
    { [key in NetworkKey]?: string }

It follows the same shape as the networks property in the HolographConfig object. It is an object with the chain name as the key and the RPC URL as the value.

Check out the full list of supported chains in the HolographConfig networks documentation.

src/holograph/wallet.ts
import { HolographAccountFactory, HolographWallet } from "@holographxyz/sdk";

const defaultAccount = HolographAccountFactory.createAccountUsingPrivateKey(
process.env.PRIVATE_KEY
);

const holographWallet = new HolographWallet({
account: defaultAccount,
chainsRpc: {
polygon: "https://polygon-rpc-url.com",
avalanche: "https://avalanche-rpc-url.com",
},
});

The chainsRpc property can be skipped as long as the .env file contains the network RPC URLs.

.env
POLYGON_RPC_URL = "https://polygon-rpc-url.com";
AVALANCHE_RPC_URL = "https://avalanche-rpc-url.com";

2. Properties

account

  • Type:
    HolographAccount

The same account object that was passed to the constructor.


3. Methods

isBalanceSufficientForTx()

Checks whether the account balance is sufficient to pay for the transaction fees.

Params:

  • chainId:
    numberrequired
  • gasPrice:
    bigintrequired
  • gasLimit:
    bigintrequired
  • value:
    bigintdefault: BigInt(0)

Returns:

Promise<boolean>

import { HolographAccountFactory, HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holograph/networks";

const defaultAccount = HolographAccountFactory.createAccountUsingPrivateKey(
process.env.PRIVATE_KEY
);

const holographWallet = new HolographWallet({
account: defaultAccount,
});

const isBalanceSufficient = await holographWallet.isBalanceSufficientForTx(
networks.polygon.chain,
BigInt(1000000000),
BigInt(21000)
);

onChain()

Returns a new instance of the WalletClient and PublicActions interfaces to interact with for the specified chain.

There are many of useful methods available in those interfaces, including the ability to sign messages, send transactions, check balances, and more.

Params:

  • chainId:
    numberrequired

Returns:

import { HolographAccountFactory, HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holograph/networks";

const defaultAccount = HolographAccountFactory.createAccountUsingPrivateKey(
process.env.PRIVATE_KEY
);

const holographWallet = new HolographWallet({
account: defaultAccount,
});

// Signing a message
await holographWallet.onChain(networks.polygon.chain).signMessage({
account: holographWallet.account,
message: "Hello World!",
});

// Check the holographWallet.onChain available methods below

Here is the full list of methods available in the Public Actions interface:

  • balance
  • blobBaseFee
  • block
  • blockNumber
  • blockTransactionCount
  • call
  • chainId
  • createBlockFilter
  • createEventFilter
  • createPendingTransactionFilter
  • estimateFeesPerGas
  • estimateGas
  • estimateMaxPriorityFeePerGas
  • event
  • feedHistory
  • filtersAndLogs
  • filterChanges
  • filterLogs
  • gasPrice
  • getLogs
  • getProof
  • getTransaction
  • getTransactionConfirmations
  • getTransactionCount
  • getTransactionReceipt
  • pendingTransactions
  • prepareTransactionRequest
  • rawTransaction
  • transaction
  • transactionReceipt
  • typedData
  • verifyMessage
  • verifyTypedData
  • waitForTransactionReceipt
  • watchBlocks
  • watchBlockNumber
  • watchEvent
  • watchPendingTransactions
  • uninstallFilter

Check out the Viem docs for a more complete reference on each method.


Here is the full list of methods available in the Wallet Client/Wallet Actions interface:

  • addChain
  • getAddresses
  • getPermissions
  • prepareTransactionRequest
  • requestAddresses
  • requestPermissions
  • sendRawTransaction
  • sendTransaction
  • signMessage
  • signTransaction
  • signTypedData
  • switchChain
  • watchAsset

Check out the Viem docs for a more complete reference on each method.