0.2.38 • Published 2 years ago
@thorswap-lib/xchain-solana v0.2.38
@thorswap-lib/xchain-solana
Modules
client
- Custom client for communicating with Solana by using@solana/web3.js
Installation
yarn add @thorswap-lib/xchain-solana
Following peer dependencies have to be installed into your project. These are not included in @thorswap-lib/xchain-solana
.
yarn add @thorswap-lib/xchain-client @thorswap-lib/xchain-crypto @thorswap-lib/xchain-util @solana/web3.js @solana/spl-token ed25519-hd-key
Solana Client Testing
yarn install
yarn test
Service Providers
This package uses the following service providers:
Function | Service | Notes |
---|---|---|
Balances | Solana RPC | https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getBalance |
Transaction history | Solana RPC | https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getParsedTransactions |
Transaction details by hash | Solana RPC | https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getParsedTransaction |
Transaction fees | Solana RPC | https://solana-labs.github.io/solana-web3.js/classes/Transaction.html#getEstimatedFee |
Transaction broadcast | Solana RPC | https://solana-labs.github.io/solana-web3.js/modules.html#sendAndConfirmTransaction |
Explorer | Solana Explorer | https://explorer.solana.com/ |
Examples
// import `xchain-solana`
import { Client } from '@thorswap-lib/xchain-solana'
// Create a `Client`
const client = new Client({ network: Network.Testnet, phrase: 'my secret phrase' })
// get address
const address = client.getAddress()
console.log('address:', address) // address: DsgX3wpzzaZwuEUAZVMtg52sgywkXf7mUCHodzX2YJef
// get balances
const balances = await client.getBalance(address)
console.log('balances:', balances[0].amount.amount().toString()) // balance: 6
// get transactions
const txs = await client.getTransactions({ address })
console.log('txs total:', txs.total) // txs total: 20
// get transaction details
const tx = await client.getTransactionData('any-tx-hash')
console.log('tx asset:', tx.asset) // tx asset: { chain: 'SOL', symbol: 'SOL', ticker: 'SOL' }
For more examples check out tests in ./__tests__/client.test.ts
0.2.27
2 years ago
0.2.26
2 years ago
0.2.25
2 years ago
0.2.24
2 years ago
0.2.23
2 years ago
0.2.22
2 years ago
0.2.21
2 years ago
0.2.20
2 years ago
0.2.19
2 years ago
0.2.18
2 years ago
0.2.30
2 years ago
0.2.35-development.2
2 years ago
0.2.38
2 years ago
0.2.37
2 years ago
0.2.36
2 years ago
0.2.35-development.0
2 years ago
0.2.35-development.1
2 years ago
0.2.35
2 years ago
0.2.34
2 years ago
0.2.33
2 years ago
0.2.32
2 years ago
0.2.31
2 years ago
0.2.29
2 years ago
0.2.28
2 years ago
0.2.16
2 years ago
0.2.15
2 years ago
0.2.14
2 years ago
0.2.13
2 years ago
0.2.12
2 years ago
0.2.11
2 years ago
0.2.10
2 years ago
0.2.17
2 years ago
0.2.7
2 years ago
0.2.6
2 years ago
0.2.9
2 years ago
0.2.8
2 years ago
0.2.5
2 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.2.3
3 years ago
0.2.2
3 years ago
0.1.3
3 years ago
0.2.4
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago