transferBalance
Call this function to execute an fungible token transfer 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
must the id of the user currently logged in.
Example Usage
import {Halliday} from "halliday-sdk";
// Transfer an ERC20 to a different user, with gas sponsored by the paymaster.
const balanceTransferTxInfo = await hallidayClient.transferBalance({
from_in_game_player_id: userInGameId, // your user's id in your application
to_in_game_player_id: "other_player_id", // other user's id in your application
token_address: "0x0799ea468f812e40dbabe77b381cac105da500cd",
value: "100000000000000000", //value in wei
sponsor_gas: true,
});
// Transfer a native token to a different user, with gas sponsored by the paymaster.
const balanceTransferTxInfo = await hallidayClient.transferBalance({
from_in_game_player_id: userInGameId, // your user's id in your applicatio
to_in_game_player_id: "other_player_id", // other user's id in your application
value: "0.75", //value in ether
sponsor_gas: true,
});
Inputs
TransferBalanceRequest Object
Name | Type | Description |
---|---|---|
from_in_game_player_id | string | The user id of the sending user |
to_in_game_player_id | string | The user id of the receiving user |
token_address (optional) | string | Contract address of ERC20 asset to transfer. Leave empty to transfer the native token |
value | string | Amount of this token to transfer (enter value in wei for ERC20 token and ether for native token) |
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 14 hours ago
What’s Next