@glitter-finance/sdk-core
v2.0.1
Published
Glitter Finance SDK: Core Functions
Downloads
179
Keywords
Readme
Glitter Finance Core SDK
Examples
- Create a new Project
If you already have a project, you can skip this step.
mkdir glitter-sdk-example
cd glitter-sdk-example
npm init -y
- Install dependencies
#Install & Initialize Typescript
npm install typescript --save-dev
npx tsc --init
npm add @glitter-finance/sdk-core
- Code Imports & Setup
import { BridgeNetworks, BridgeTokens, GlitterBridgeSDK, GlitterEnvironment } from "@glitter-finance/sdk-core";
...
const sdk = new GlitterBridgeSDK();
sdk.setEnvironment(GlitterEnvironment.mainnet)
sdk.connect([
BridgeNetworks.algorand,
BridgeNetworks.Avalanche,
BridgeNetworks.Ethereum,
BridgeNetworks.Polygon,
BridgeNetworks.solana,
BridgeNetworks.TRON,
])
- Add Solana and Algorand Accounts
...
const algorand = sdk.algorand!
const solana = sdk.solana!
const algoAccount = await algorand.accountsStore.add("<mnemonic>")
const solAccount = await solana.accountStore.add("<mnemonic>")
- Get Supported Tokens List
import { BridgeNetworks, BridgeTokens } from "@glitter-finance/sdk-core";
...
const supportedTokensAlgorand = BridgeTokens.getTokens(BridgeNetworks.algorand)
const supportedTokensSolana = BridgeTokens.getTokens(BridgeNetworks.solana)
const supportedTokensTron = BridgeTokens.getTokens(BridgeNetworks.TRON)
- Bridge Tokens
...
// Briding xALGO from Solana
const bridgexAlgoTxId = await sdk.solana?.bridge(
solAccount.addr,
algoAccount.addr,
BridgeNetworks.algorand,
"xALGO",
BigInt(10000000)
)
console.log(bridgexAlgoTxId)