Using the HallidayClient for Smart Account Functionality

Interact with and send transactions from your Halliday Smart Account

Once logged in, the HallidayClient provides many functions for you to use your Halliday Smart Account to interact with the blockchain.

Create a Smart Account, or Get your Smart Account Details

Create a Halliday smart account on a supported blockchain, or get the smart account details if you already have one:

// Create or retrieve your Halliday Smart Account details
const smartAccount = await hallidayClient.getOrCreateSmartAccount();

// Get your smart account address, on a blockchain
const smartAccountAddres = smartAccount.smartAccountAddress;
const blockchain = smartAccount.blockchainType;

For more details on the return type, please refer to our SDK Reference.


View Assets in the Smart Account

You can view assets and balances in the smart account with simple calls:

// Get NFTs in the Halliday Smart Account.
const assets = await hallidayClient.getAssets();

// Get ERC20 balances and native token balances in the Halliday Smart Account.
const balances = await hallidayClient.getBalances();

Submit a Transaction with the Smart Account

You can call any contract function with the Smart Account, which will be automatically signed by the signer associated with the smart account. The function will return when the transaction has succeeded or failed on chain. Below is a code snippet on how to set up, submit, and get the transaction result with your smart account:

import { ethers } from "ethers;
import { CallContractRequest } from "@halliday-sdk/accounts";

const contractAddress = '0x1f6557356bfb310a556300a36fb18f54fb4791b1';
const contractAbi = [...]; // Replace with your contract's ABI

// Create an instance of the contract
const contract = new ethers.Contract(contractAddress, contractAbi, signer);

// Get the calldata for a contract call
const calldata = contract.interface.encodeFunctionData('someFunction', ['arg1', 'arg2']);

// Construct the call contract request
const transactionRequest: CallContractRequest = {
  targetAddress: contractAddress,
  valueInWei: "0",
  calldata: calldata,
  sponsorGas: true,  // Please go to the dashboard to enable/disable gas sponsorship on chains!
}

// Use your Halliday Smart Account to submit the transaction
const transactionInfo = await hallidayClient.callContract(transactionRequest);

// See the information on the transaction after it has been successfully submitted on chain
const transactionHash = transactionInfo.onChainId;
const trasnactionReceipt = transactionInfo.userOpReceipt;
const transactionStatus = transactionInfo.status;
const transactionSender = transactionInfo.sender;