-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from xchainjs/feature/hip/updateDocs
Update docs
- Loading branch information
Showing
52 changed files
with
1,258 additions
and
831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,7 @@ Chain identifier for BNB. | |
## AssetBNB | ||
|
||
Base "chain" asset of Binance chain. | ||
|
||
## BNB_DECIMAL | ||
|
||
Asset Decimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
sort: 3 | ||
--- | ||
|
||
# XCHAIN BSC | ||
|
||
Custom Binance smart chain client and utilities used by XChainJS clients | ||
|
||
{% include list.liquid all=true %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
sort: 1 | ||
--- | ||
|
||
# How it works | ||
|
||
This package uses etherjs library, by default it uses several providers. (https://docs.ethers.io/v5/api-keys/) | ||
|
||
### Explorer URL | ||
* Mainnet:[`https://bscscan.com`](https://bscscan.com) | ||
* Testnet:[`https://testnet.bscscan.com`](https://testnet.bscscan.com) | ||
|
||
## RPC Ethers Providers | ||
* Mainnet:[`https://rpc.ankr.com/bsc`](https://rpc.ankr.com/bsc) | ||
* Testnet:[`https://bsc-testnet.public.blastapi.io`](https://bsc-testnet.public.blastapi.io) | ||
|
||
## Dependencies | ||
|
||
* [`@xchainjs/xchain-client`](http://docs.xchainjs.org/xchain-client/interface.html) | ||
* [`@xchainjs/xchain-crypto`](http://docs.xchainjs.org/xchain-crypto/how-to-use.html) | ||
* [`@xchainjs/xchain-util`](http://docs.xchainjs.org/xchain-util/how-to-use.html) | ||
* [`@xchainjs/xchain-evm-providers`](http://docs.xchainjs.org/@xchainjs/xchain-evm-providers/how-to-use.html) | ||
* [`@xchainjs/xchain-evm-providers`](http://docs.xchainjs.org/@xchainjs/xchain-evm-providers/how-to-use.html) | ||
* @xchainjs/xchain-evm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
sort: 2 | ||
--- | ||
|
||
# How to use | ||
|
||
## Installation | ||
|
||
``` | ||
yarn add @xchainjs/xchain-bsc | ||
``` | ||
|
||
Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-bsc`. | ||
|
||
``` | ||
yarn add @xchainjs/xchain-evm @xchainjs/xchain-evm-providers @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers | ||
``` | ||
|
||
## Client Testing | ||
|
||
``` | ||
yarn install | ||
yarn test | ||
``` | ||
|
||
## Basic Usage Example | ||
###Imports | ||
```ts | ||
import { Client, defaultBscParams, AssetBSC } from "@xchainjs/xchain-bsc" | ||
import { FeeOption } from "@xchainjs/xchain-client" | ||
import { assetToBase, baseToAsset, assetAmount, Asset, Chain } from "@xchainjs/xchain-util" | ||
``` | ||
|
||
### Connect wallet to new Bsc Chain Client | ||
Network default is Mainnet | ||
```ts | ||
// Create new Bsc Asset | ||
const assetRIP: Asset = { | ||
chain: AssetBSC.chain, | ||
symbol: `RIP-0x224695ba2a98e4a096a519b503336e06d9116e48`, | ||
ticker: `RIP`, | ||
synth: false, | ||
} | ||
// Create new Bsc Client Instance | ||
const connectWallet =async () => { | ||
defaultBscParams.phrase = "phrase" | ||
const bscClient = new Client(defaultBscParams) | ||
let address = bscClient.getAddress() | ||
console.log(`Address: ${address}`) | ||
let isValid = bscClient.validateAddress(address) | ||
if( isValid === true ){ | ||
try { | ||
const balance = await bscClient.getBalance(address) | ||
let assetAmount = (baseToAsset(balance[1].amount)).amount() | ||
console.log(`With balance: ${assetAmount}`) | ||
|
||
} catch (error) { | ||
console.log(`Caught: ${error}`) | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.