callContract
Call this function to execute an custom transaction. The user must be logged in for this call to succeed. You can confirm a user has been logged in by calling hallidayClient.getUserInfo()
. Note that the from_in_game_player_id
input must match the id of the user currently logged in.
Example Usage
import {Halliday} from "halliday-sdk";
// 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']);
// Call the contract, with gas sponsored by the paymaster.
const contractCallTxInfo = await hallidayClient.callContract({
from_in_game_player_id: userInGameId, // your user's id in your application
target_address: contractAddress,
value: "0",
calldata,
sponsor_gas: true,
});
Inputs
CallContractRequest Object
Name | Type | Description |
---|---|---|
from_in_game_player_id | string | The user id of the sending user |
target_address | string | Address of the target contract |
value | string | Value being transferred to target_address ("0" if not transferring any tokens to target_address) |
calldata | string | Encoded data representing the contract call to execute for user |
sponsor_gas | boolean | Whether to pay for user's gas on their behalf |
on_rate_limit (optional) | Function | Callback to run if user is rate-limited (i.e small message on screen for a few seconds) |
Outputs
Promise to a GetTransactionReponse Object
Name | Type | Description |
---|---|---|
blockchain_type | string | The blockchain on which this transaction occurred (e.g. ETHEREUM, IMMUTABLE_PROD) |
tx_id | string | The ID of the transaction |
status | string | The status of the transaction (e.g. PENDING, COMPLETE, FAILED) |
retry_count | number | The number of times we've retried sending this transaction |
on_chain_id (optional) | string | The blockchain transaction id if the transaction succeeded |
error_message (optional) | string | The error message if the transaction failed |
user_op_receipt (optional) | string | JSON Object of the user operation receipt (if the operation went through on chain) |
Updated about 15 hours ago
What’s Next