1.1.5 • Published 1 year ago
@phala/index v1.1.5
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)
1.1.5
1 year ago
1.1.4
1 year ago
1.1.1
1 year ago
1.1.0
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.0.58
1 year ago
1.0.57
1 year ago
1.0.56
1 year ago
1.0.55
1 year ago
1.0.54
1 year ago
1.0.53
1 year ago
1.0.52
1 year ago
1.0.51
1 year ago
1.0.49
1 year ago
1.0.50
1 year ago
1.0.48
1 year ago
1.0.47
1 year ago
1.0.45
2 years ago
1.0.44
2 years ago
1.0.43
2 years ago
1.0.42
2 years ago
1.0.41
2 years ago
1.0.40
2 years ago
1.0.39
2 years ago
1.0.38
2 years ago
1.0.37
2 years ago
1.0.36
2 years ago
1.0.35
2 years ago
1.0.34
2 years ago
1.0.33
2 years ago
1.0.32
2 years ago
1.0.31
2 years ago
1.0.30
2 years ago
1.0.29
2 years ago
1.0.28
2 years ago
1.0.27
2 years ago
1.0.25
2 years ago
1.0.23
2 years ago
1.0.22
2 years ago
1.0.21
2 years ago
1.0.20
2 years ago
1.0.19
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago