# Pre-Reqs# Requires at least PHP 7.0 and either the gmp or bcmath extensioncomposerrequireakashic/akashic-pay
# In case of Maven<dependencies><dependency><groupId>com.akashicpay</groupId><artifactId>akashicpay-sdk</artifactId><version>1.1.1</version></dependency></dependencies># In case of Gradledependencies{implementation'com.akashicpay:akashicpay-sdk:1.1.1'}
$dotnetaddpackageAkashicPaySDK
Register
Testing
In development, omit key pair (L2Address and PrivateKey) in initialisation, in which case the SDK will create and use a new pair. Then copy them to the initialisation. After that contact our Tech Support to configure the callback URL. For example, in typescript:
import { AkashicPay, Environment } from"@akashicpay/sdk";// production is the default environment.// And in production, an otk must be specifiedconstakashicPay=awaitAkashicPay.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 otkconst { l2Address,privateKey } =akashicPay.keyBackup;console.log(`my testing L2 address: ${l2Address} and private key: ${privateKey}`);
Production
Create an AkashicLink account and go through the registration process on AkashicPay.com including setting up callback URLs as desired, as described in the Quick Guide.
privateKey - Located in Settings -> Security -> Key Pair Backup of AkashicLink
recoveryPhrase (if privateKey is not present) - Shown during account creation of AkashicLink
Build
This example configuration uses many optional build arguments, for illustration purposes.
importtype { IHttpClient, ILogger } from"@akashicpay/sdk";import { ACDevNode, ACNode, AkashicPay, Environment } from"@akashicpay/sdk";import axios from"axios";import pino from"pino";import { Environment } from"@akashicpay/sdk/src";// 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// `build()` argument `recoveryPhrase`constprivateKey=process.env.akashicKey;// this is the address of your AkashicLink account. Of the form "AS1234..."constl2Address=process.env.l2Address;// in development, you will use our testnet and testnet L1 chainsconstenvironment=process.env.environment =="production"?Environment.Production:Environment.Development;// you're strongly encouraged to pass an instance of your preferred loggerconstlogger:ILogger=pino({ name:"AkashicPaySDK" });// optional, the SDK will try to find the fastest node if omittedconsttargetNode= environment =="development"?ACNode.SingaporeDAI :ACDevNode.Singapore1;// instantiate an SDK instance, ready to useconstakashicPay=awaitAkashicPay.build({ privateKey, l2Address, environment, targetNode, logger,});
<?phprequire"vendor/autoload.php";useAkashic\AkashicPay;useAkashic\Constants\Environment;useAkashic\Constants\ACNode;useAkashic\Constants\ACDevNode;$akashicPay =newAkashicPay([// 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'),]);
You are now ready to use AkashicPay! To learn more about the different functions, go to the next page. Continue reading for more details about advanced setup of AkashicPay and testing.
Dependency Injection
The SDK uses dependency injection to allow for easy testing. You can pass in your own implementations of a logger when initializing AkashicPay.
Configuring a logger
We strongly advise you to inject a logger. If one is not supplied, we will default to console logging, which is almost certainly not what you want in production or testing.
You can use any logger that implements the ILogger interface. The interface is modelled on Pino's, and injecting a Pino logger instance will work out of the box.
If you use an alternative logger in your app, you can write a class that does implement the ILogger interface, and wraps your logger.
Logging Compatibility
This project utilizes log4j for logging within a Java environment,
ensuring full backward compatibility with existing log4j configurations and code.
You can continue to use the stable and flexible logging features of log4j without any need to modify your current setup.
Logging Compatibility
This project utilizes Serilog for logging within a C# environment,
ensuring full backward compatibility with existing Serilog configurations and code.
You can continue to use the stable and flexible logging features of Serilog without any need to modify your current setup.
Testing
You can also use AkashicPay with the AkashicChain Testnet & Sepolia (Ethereum) and Shasta (Tron) testnets, useful for local development and staging environments. To do this, no AkashicLink is necessary; you can build an AkashicPay instance as follows, and the SDK will create a "test otk" for you:
Then, to reuse the same otk in later testing (recommended), simply supply the otk during setup:
import { AkashicPay, Environment } from"@akashicpay/sdk";constprivateKey=process.env.akashicKey;constl2Address=process.env.l2Address;constakashicPay=awaitAkashicPay.build({ privateKey, l2Address, environment:Environment.Development,});// Now, e.g. create a wallet on the Tron Shasta testnetconst { address } =awaitakashicPay.getDepositAddress(NetworkSymbol.Tron_Shasta,"EndUser123");
<?phprequire"vendor/autoload.php";useAkashic\AkashicPay;useAkashic\Constants\Environment;useAkashic\Constants\NetworkSymbol;// production is the default environment.// And in production, an otk must be specified$akashicPay =newAkashicPay(['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');
During testing and local development, you need cryptocurrency on the testnets to do anything meaningful. Akashic provides a simple faucet where you can request some coins and tokens on Shasta and Sepolia by supplying your L2-address/identity: https://faucet.testnet.akashicchain.com/
If you require further funds, the official Tron Discord provides users with either 5000 TRX or USDT on Shasta every day.