callContract

Call this function to execute an custom transaction.

Example Usage

// Call an arbitrary contract.
const contractAddress = '0x1f6557356bfb310a556300a36fb18f54fb4791b1';
// The contract's ABI
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']);

const transactionRequest: CallContractRequest = {
  targetAddress: contractAddress,
  valueInWei: "0",
  calldata: calldata,
  sponsorGas: true
}

// Call the contract, with gas sponsored by the paymaster.
const transactionInfo = await hallidayClient.callContract(transactionRequest);

Inputs

A CallContractRequest Object, with properties shown below:

NameTypeDescription
targetAddressstringAddress of the target contract
valueInWeistringValue being transferred to target_address ("0" if not transferring any value to target_address)
calldatastringEncoded data representing the contract call to execute for user
sponsorGasbooleanWhether to pay for user's gas with gas sponsorship
onRateLimit (optional)FunctionCallback to run if user is rate-limited (i.e small message on screen for a few seconds)
gasFeeOverrides (optional)maxFeePerGas: string;
maxPriorityFeePerGas:
string;
Hardcoded gas fee values in Wei to use for transaction instead of dynamic query values
useRetry (optional, defaults to False)booleanWhether to use the SDK's mechanism of auto-retrying with different gas fees in the event of a gas-related error.
shouldFallbackToUserFunds (optional)booleanWhether to retry a sponsored operation without sponsorship (i.e with user's funds) if operation will exceed user's sponsorship limit.

Outputs

This function returns after the transaction has completed or failed on chain, as there is built-in polling and optional retry logic. The function returns a TransactionDetails object, with properties shown below:

NameTypeDescription
senderstringThe Halliday Smart Account address that sent the transaction
blockchainTypestringThe blockchain on which this transaction occurred (e.g. AVALANCHE_CCHAIN, OPTIMISM, etc.)
txIdstringThe ID of the transaction
statusstringThe status of the transaction (e.g. PENDING, COMPLETE, FAILED)
retryCountnumberThe number of times we've retried sending this transaction
onChainId (optional)stringThe transaction hash, if the transaction succeeded or failed on chain
errorMessage (optional)stringThe error message if the transaction failed
userOpReceipt (optional)stringJSON Object of the user operation receipt (if the operation went through on chain)