Transfer a Token

The following sample will show you how to transfer a token on Hedera Hashgraph. We will first generate a request for the end user. Once validated, you will get notified about transaction's status.

Prerequisites:

pageGetting started

Step 1: Get Xact Fees

In order to get the fees from our service, you need to proceed as below

/* Get the service fees */
$fees = $client->getXactFeesTransfer();

Step 2: Initializing Token Transfer

When initializing a token transfer, a request will be sent to the end user. A Webhook must be defined as a second parameter and will be called every time a Token has been transferred successfully.

/* From which account to transfer the token */
$fromAccountId = '';
/* Account that receive the token */
$toAccountId = '';
/* Token to Transfer */
$tokenId = '';
/* Supply */
$supply = 1;
/* Custom uniq ID */
$uniqId = '';
/* Define a Webhook */
$webhook = '';

/* Transfer a token */
$client->transfer([
    $fromAccountId,
    $toAccountId,
    $tokenId,
    $supply,
    $uniqId
], $webhook);

On each user's validation, you will receive a JSON like this :

Fields

Type

Description

fromAccountId

string

Account Id of the emitter

toAccountId

string

Account Id of the receiver

tokenId

string

Token ID being transferred

status

'Accepted' or 'Refused'

Status of the request

uniqId

string

Custom Uniq Id

Find more details on the webhook implementation here

Last updated