AkashicPay
繁體中文
繁體中文
  • 簡介
    • 概述
    • 費用結構
    • 交易時間
    • 術語
  • 儀表板
    • 儀表板
    • 帳號
    • 轉帳
    • 設置
    • 開發者
  • SDK
    • 入門
    • 付款流程
    • SDK 與工具套件
    • 函式 (Functions)
      • getDepositAddress
      • getDepositUrl
      • 識別碼 (Identifier) & ReferenceId
      • 要求的金額和貨幣
      • 提款/提幣 (payout)
      • 提款/提幣回調 (Payout callback)
      • 存款回調 (Deposit callback)
      • getTransfers
      • getBalance
      • getTransactionDetails
      • 錯誤訊息 (Errors)
    • 支援貨幣
    • 回調安全性
  • 指南
    • 快速指南
    • 建議整合流程
Powered by GitBook
On this page
  • 安裝
  • 註冊
  • 建構
  • 測試
  • 龍頭 (Faucet)

Was this helpful?

  1. SDK

入門

如何設定 AkashicPay SDK 以便在您的程式碼庫中使用

安裝

安裝套件時使用

npm install @akashicpay/sdk
#or
yarn add @akashicpay/sdk
# Pre-Reqs
# Requires at least PHP 7.0 and either the gmp or bcmath extension

composer require akashic/akashic-pay
# In case of Maven
<dependencies>
    <dependency>
        <groupId>com.akashicpay</groupId>
        <artifactId>AkashicPaySDK</artifactId>
        <version>1.4.0</version>
    </dependency>
</dependencies>

# In case of Gradle
dependencies {
  implementation 'com.akashicpay:AkashicPaySDK:1.4.0'
}
$ dotnet add package AkashicPaySDK

註冊

測試環境

在開發過程中,請在初始化時省略密鑰對(L2Address 和 PrivateKey),在這種情況下,SDK 會建立並使用新的密鑰對。然後將它們複製到初始化中。之後,請聯絡我們的技術支援人員設定回調 URL。例如,在 typescript 中:

import { AkashicPay, Environment } from "@akashicpay/sdk";

// production is the default environment.
// And in production, an otk must be specified
const akashicPay = await AkashicPay.build({
  environment: Environment.Development,
});

// for security reasons, this would throw if the environment was production
// but you can use this in development to record and re-use your otk
const { l2Address, privateKey } = akashicPay.keyBackup;
console.log(
  `my testing L2 address: ${l2Address} and private key: ${privateKey}`
);

正式環境

建構

本範例設定使用許多可選的建立參數,僅供說明之用。

using AkashicPaySDK;
using AkashicPaySDK.Constants;

namespace ApSdkTests;

public class Example
{
    public static async Task Main(string[] args)
    {
        var environment = 
            Environment.GetEnvironmentVariable("environment") == "production" ? 
                APEnvironment.Production : 
                APEnvironment.Development;
        
        var otk = ApSdkFactory.CreateOtkFromKeyPair("your_private_key", "your_l2Address");
        var sdk = await ApSdkFactory.CreateSdk(environment, otk);
    }

}
<?php

require "vendor/autoload.php";

use Akashic\AkashicPay;
use Akashic\Constants\Environment;
use Akashic\Constants\ACNode;
use Akashic\Constants\ACDevNode;

$akashicPay = new AkashicPay([
    // in development, you will use our testnet and testnet L1 chains
    'environment' => getenv('environment') === 'production' ? Environment::PRODUCTION : Environment::DEVELOPMENT,
    // optional, the SDK will try to find the fastest node if omitted
    'targetNode' => getenv('environment') === 'production' ? ACNode::SINGAPORE_1 : ACDevNode::SINGAPORE_1,
    // use whatever secret management tool you prefer to load the private key
    // from your AkashicLink account. It should be of the form:
    // `"0x2d99270559d7702eadd1c5a483d0a795566dc76c18ad9d426c932de41bfb78b7"`
    // In development, each developer could have their own, or omit this (and
    // the l2Address), in which case the SDK will create and use a new pair.
    // you can instead use your Akashic Link account's 12-word phrase, using the
    // argument `recoveryPhrase`
    'privateKey' => getenv('akashicKey'),
    // this is the address of your AkashicLink account. Of the form "AS1234..."
    'l2Address' => getenv('l2Address'),
]);
import com.akashicpay.constants.APEnvironment;
import com.akashicpay.model.ACOtk;
import com.akashicpay.sdk.IAPSdk;

public class Main {

    public static void main(String[] args) throws Exception {
        ACOtk otk = APSdkFactory.createOtkFromKeyPair("your_private_key", "your_l2_address");

        APEnvironment environment =
                System.getenv("environment").equals("production") ?
                        APEnvironment.Production : APEnvironment.Development;
        
        IAPSdk sdk = APSdkFactory.createSDK(environment, otk);
    }
}
using AkashicPaySDK;
using AkashicPaySDK.Constants;

namespace ApSdkTests;

public class Example
{
    public static async Task Main(string[] args)
    {
        var environment = 
            Environment.GetEnvironmentVariable("environment") == "production" ? 
                APEnvironment.Production : 
                APEnvironment.Development;
        
        var otk = ApSdkFactory.CreateOtkFromKeyPair("your_private_key", "your_l2Address");
        var sdk = await ApSdkFactory.CreateSdk(environment, otk);
    }

}

現在您可以使用 AkashicPay 了!要瞭解更多關於不同功能的資訊,請前往下一頁。繼續閱讀以獲得更多關於 AkashicPay 進階設定和測試的詳細資訊。

測試

然後,若要在之後的測試中重複使用相同的 otk(建議),只要在設定時提供 otk 即可:

import { AkashicPay, Environment } from "@akashicpay/sdk";

const privateKey = process.env.akashicKey;
const l2Address = process.env.l2Address;

const akashicPay = await AkashicPay.build({
  privateKey,
  l2Address,
  environment: Environment.Development,
});

// Now, e.g. create a wallet on the Tron Shasta testnet
const { address } = await akashicPay.getDepositAddress(
  NetworkSymbol.Tron_Shasta,
  "EndUser123"
);
<?php

require "vendor/autoload.php";

use Akashic\AkashicPay;
use Akashic\Constants\Environment;
use Akashic\Constants\NetworkSymbol;

// production is the default environment.
// And in production, an otk must be specified
$akashicPay = new AkashicPay([
    'environment' => Environment::DEVELOPMENT,
    'privateKey' => getenv('akashicKey'),
    'l2Address' => getenv('l2Address'),
]);

// Now, e.g. create a wallet on the Tron Shasta testnet
$address = $akashicPay->getDepositAddress(NetworkSymbol::TRON_SHASTA, 'user123');
import com.akashicpay.constants.APEnvironment;
import com.akashicpay.model.ACOtk;
import com.akashicpay.model.APDepositAddressResult;
import com.akashicpay.model.APNetworkSymbol;
import com.akashicpay.sdk.IAPSdk;

public class Main {

    public static void main(String[] args) throws Exception {
        String l2Address = "your l2Address";
        String privateKey = "your privateKey";

        ACOtk otk = APSdkFactory.createOtkFromKeyPair(privateKey, l2Address);

        IAPSdk sdk = APSdkFactory.createSDK(APEnvironment.Development, otk);

        APDepositAddressResult trxDepositAddress =
                sdk.getDepositAddress(APNetworkSymbol.TRX_SHASTA, "EndUser123");
    }
}
using AkashicPaySDK;
using AkashicPaySDK.Constants;
using AkashicPaySDK.Model;

namespace ApSdkTests;

public class Example
{
    public static async Task Main(string[] args)
    {
        var l2Address = "your l2Address";
        var privateKey = "your privateKey";
        var otk = ApSdkFactory.CreateOtkFromKeyPair(l2Address,privateKey);

        var sdk = await ApSdkFactory.CreateSdk(APEnvironment.Development, otk);

        var trxDepositAddress = await sdk.GetDepositAddressAsync(TronShastaNetworkSymbol.Value, "test005");
    }
}

龍頭 (Faucet)

Previous開發者Next付款流程

Last updated 2 months ago

Was this helpful?

創建一個 帳號,並在 AkashicPay.com 上完成註冊程序,包括根據需要設置回調 URL,如中所述。

l2Address - 位於 的頂部欄位。

privateKey - 位於 的設定 -> 安全 -> 密鑰對備份。

recoveryPhrase (如果沒有 privateKey) - 在 建立帳號時顯示

您也可以將 AkashicPay 與 Testnet & Sepolia (Ethereum) 和 Shasta (Tron) 測試網路一起使用,這對本地開發和暫存環境非常有用。要做到這一點,不需要 ;您可以按如下方式建立一個 AkashicPay 實例,SDK 會為您創建一個 「測試」:

在測試和本地開發期間,您需要在測試網路上使用加密貨幣才能進行任何有意義的工作。Akashic 提供了一個簡單的龍頭 (Faucet),只要提供您的 ,您就可以在 Shasta 和 Sepolia 上申請一些代幣:。

如果您需要進一步的資金,官方 每天會在 Shasta 上提供使用者 5000 TRX 或 USDT。

Tron Discord
快速指南
https://faucet.testnet.akashicchain.com/
AkashicLink
AkashicLink
AkashicLink
AkashicLink
AkashicChain
AkashicLink
otk
L2 地址/身份 (identity)