Getting Started with SDK
How to setup the AkashicPay SDK for use in your codebase
Installing
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>[version]</version>
</dependency>
</dependencies>
# In case of Gradle
dependencies {
implementation 'com.akashicpay:AkashicPaySDK:[version]'
}$ dotnet add package AkashicPaySDKRegister
Build
import type { 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`
const privateKey = process.env.akashicKey;
// this is the address of your AkashicLink account. Of the form "AS1234..."
const l2Address = process.env.l2Address;
// in development, you will use our testnet and testnet L1 chains
const environment =
process.env.environment == "production"
? Environment.Production
: Environment.Development;
// you're strongly encouraged to pass an instance of your preferred logger
const logger: ILogger = pino({ name: "AkashicPaySDK" });
// optional, the SDK will try to find the fastest node if omitted
const targetNode =
environment == "development" ? ACNode.SingaporeDAI : ACDevNode.Singapore1;
// instantiate an SDK instance, ready to use
const akashicPay = await AkashicPay.build({
privateKey,
l2Address,
environment,
targetNode,
logger,
});Testing
Callbacks
Last updated
Was this helpful?