Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@phala/index

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phala/index

inDEX JavaScript SDK

  • 1.1.5
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

inDEX JavaScript SDK

Getting Started

npm install @phala/index
import {Client} from '@phala/index'
const client = new Client()
await client.isReady

EVM Chain

import {lookupAsset} from '@phala/index'
import {Wallet, ethers} from 'ethers'

const privateKey = '0x…'
const wallet = new Wallet(privateKey)
const recipient = '0x…'
const solution = [
  // JSON solution
]

const moonbeam = client.createEvmChain('Moonbeam')
const asset = lookupAsset('Moonbeam', 'WGLMR')
const amount = ethers.parseEther('1')
const simulateResults = await client.simulateSolution(solution, recipient)
const approvalTx = await moonbeam.getApproval(
  asset.location,
  wallet.address,
  amount
)
if (approvalTx) {
  await wallet.signTransaction(approvalTx)
}
const deposit = await moonbeam.getDeposit(
  asset.location,
  amount,
  recipient,
  solution
)
const tx = await wallet.sendTransaction(deposit.tx)
const task = await client.getTask(deposit.id)

Substrate Chain

import {lookupAsset} from '@phala/index'
import Keyring from '@polkadot/keyring'

const mnemonic = 'mnemonic'
const recipient = '0x…'
const keyring = new Keyring({type: 'sr25519'})
const pair = keyring.addFromUri(mnemonic)
const solution = [
  // JSON solution
]

const simulateResults = await client.simulateSolution(solution, recipient)
const phala = client.createPhalaChain('Phala')
await phala.isReady // necessary for substrate chains
const deposit = await phala.getDeposit(
  lookupAsset('Phala', 'PHA').location,
  1_000_000_000_000n,
  recipient,
  solution
)
const txHash = await deposit.tx.signAndSend(pair)
const task = await client.getTask(deposit.id)

FAQs

Package last updated on 18 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc