Send Ethereum or ERC20 Tokens with PHP

Let's send ERC20 Tokens to another address

  1. You need basic knowledge of how to code with PHP (or know someone who can), you can also learn it at Codecademy.
  2. Create a Tokengateway.io account (if you don't have one already).
  3. Install the PHP 7 modules JSON and CURL. If you are on a Linux Debian/Ubuntu machine, you can use the following commands:
    apt-get install php7-curl
    apt-get install php7-json
    Now restart Apache with:
    service apache2 restart
  4. Now create a file named sendtoken.php with the following content (or download it here):
    $apikey = "YOURAPIKEY"; // API Key in your account panel
    $contractaddress = "CONTRACTADDRESS"; // Smart contract address of the Token
    $from = "SENDERADDRESS"; // Tokengateway address you want to send from
    $to = "RECEIVERADDRESS"; // Receiving address $password = "PASSWORD"; // Password of the Tokengateway address
    $amount = 55.89; // Amount of Tokens to send
    # -------------------------------------------------------

    # Define function endpoint
    $ch = curl_init("https://eu.api.

    # Setup request to send json via POST. This is where all parameters should be entered.
    $payload = json_encode( array("apikey" => $apikey, "contractaddress" => $contractaddress, "from" => $from, "to" => $to, "password" => $password, "amount" => $amount) );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

    # Return response instead of printing.
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

    # Send request.
    $result = curl_exec($ch);

    # Decode the received JSON string
    $resultdecoded = json_decode($result, true);

    # Print the transaction id of the transaction
    echo $resultdecoded['txid'];
  5. Replace YOURAPIKEY in the above code with the API Key in your Account panel.
  6. Replace the other variables in the upper section of the code above with your data
  7. Upload the created PHP script to your web server
  8. Call the script in your browser. For example, if you upload it to the root directory of your website, you can call it by typing yourwebsite.com/sendtoken.php
  9. After a few seconds, the script will return a transaction id (which means the transaction has been sent successfully). You can lookup this transaction id on Etherscan
  10. Congratulations! You just sent ERC20 Tokens using Tokengateway. Wasn't that hard, right?
  11. Want to know how to check the Token balance of an ethereum address? Check out this Tutorial