#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use JSON qw( encode_json ) use Digest::SHA qw(hmac_sha512_hex); use MIME::Base64; use POSIX qw( strftime ); my $apiKey = 'demo'; my $host = "https://api.gateio.ws"; my $prefix = "/api/v4"; my $url = '/withdrawals'; my $query_param = ''; my %mas = ( "amount" => "222.61", "currency" => "USDT", "address" => "1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs", "chain" => "TRX" ); my $body = encode_json \%mas; my $time = time; my $timestamp = strftime("%Y%m%d %S", localtime($time)); my $sign_headers = hmac_sha512_hex('POST', $prefix . $url, $query_param, $body, $timestamp); my %payload = ( "KEY" => $apiKey, "Timestamp" => $timestamp, "SIGN" => $sign_headers, "Content-Type" => 'application/json' ); my $ua = LWP::UserAgent->new; my $response = $ua->post( $host . $prefix . $url, %payload, Content => $body ); if ($response->is_success) { print $response->decoded_content; } else { print $response->decoded_content; print "HTTP POST error code: ", $response->code, "\n"; print "HTTP POST error message: ", $response->message, "\n"; }