Skip to content

Commit

Permalink
upload docs
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfri-web3 committed Sep 6, 2024
1 parent d528bbc commit 7ef641e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Blockchain clients with whom you can prepare, make and broadcast transactions, e
| [@xchainjs/xchain-kujira](https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-kujira) | ✅ || [![npm](https://img.shields.io/npm/v/@xchainjs/xchain-kujira)](https://www.npmjs.com/package/@xchainjs/xchain-kujira) |
| [@xchainjs/xchain-cosmos](https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-cosmos) | ✅ || [![npm](https://img.shields.io/npm/v/@xchainjs/xchain-cosmos)](https://www.npmjs.com/package/@xchainjs/xchain-cosmos) |
| [@xchainjs/xchain-binance](https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-binance) | ✅ || [![npm](https://img.shields.io/npm/v/@xchainjs/xchain-binance)](https://www.npmjs.com/package/@xchainjs/xchain-binance) |

| [@xchainjs/xchain-base](https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-base) | ✅ || [![npm](https://img.shields.io/npm/v/@xchainjs/xchain-base)](https://www.npmjs.com/package/@xchainjs/xchain-base) |

### Utility packages

Expand Down
79 changes: 54 additions & 25 deletions packages/xchain-base/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,75 @@
# `@xchainjs/xchain-base`
<div align="center">
<h1 align="center">Base client</h1>

## Modules
<p align="center">
<a href='https://www.npmjs.com/package/@xchainjs/xchain-base' target='_blank'>
<img alt="NPM Version" src="https://img.shields.io/npm/v/%40xchainjs%2Fxchain-base" />
</a>
<a href='https://www.npmjs.com/package/@xchainjs/xchain-base' target='_blank'>
<img alt="NPM Downloads" src="https://img.shields.io/npm/d18m/%40xchainjs%2Fxchain-base" />
</a>
</p>
</div>

<br />

Client that allows to perform operations on the Base blockchain abstracting developers from its particularities, thus allowing developers to focus on their projects. Base is a secure, low-cost, builder-friendly Ethereum L2.

If you want to read more about Base blockchain, go to its official [web site](https://www.base.org/)

- `client` - Custom client for communicating with Base by using [`ethers`](https://github.com/ethers-io/ethers.js)

## Installation

```sh
yarn add @xchainjs/xchain-base
```

Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-base`.
or

```sh
yarn add @xchainjs/xchain-evm @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers
npm install @xchainjs/xchain-base
```

## Documentation
## Initialization

Using the Base client you can initialize the main class of the module in consultation mode if you do not provide any parameters, this means you could retrieve information from the blockchain and prepare transactions to sign, but you will not be able to sign transactions, or generate addresses.

```ts
import { Client } from '@xchainjs/xchain-base'

const client = new Client()

### [`xchain base`](http://docs.xchainjs.org/xchain-client/xchain-base/)
// Make read operations with your client
```

Otherwise, if you want to sign transactions and get the addresses you own, you will need to initialize the main class of the protocol as follows

```ts
import { Client, defaultBaseParams } from '@xchainjs/xchain-base'

const client = new Client({
phrase: 'your secret phrase',
...defaultBaseParams
})

[`How xchain-base works`](http://docs.xchainjs.org/xchain-client/xchain-base/how-it-works.html)\
[`How to use xchain-base`](http://docs.xchainjs.org/xchain-client/xchain-base/how-to-use.html)
// Make read or write operations with your client
```

## Features

## Service Providers
Thanks to the Base client you will be able to:
- Get the Base and tokens balances that an address owns
- Generate addresses given a secret phrase
- Transfer Base and tokens to another address
- Get details of a transaction
- Get address transaction history

This package uses the following service providers:

| Function | Service | Notes |
| ------------------------- | --------- | ---------------------------------------------------------------------------------- |
| ETH balances | Basescan | https://api.basescan.org/apis#accounts (module=`account`, action=`balance`) |
| Token balances | Basescan | https://api.basescan.org/apis#tokens (module=`account`, action=`tokenbalance`) |
| ETH transaction history | Basescan | https://api.basescan.org/apis#accounts (module=`account`, action=`txlistinternal`) |
| Token transaction history | Basescan | https://api.basescan.org/apis#accounts (module=`account`, action=`tokentx`) |
| Explorer | Basescan | https://basescan.org/ |

Etherscan API rate limits: https://docs.basescan.org/support/rate-limits
## Examples

- This package uses `etherjs` library, by default it uses several providers. (`https://docs.ethers.io/v5/api-keys/`)
You can find examples using the Base package in the [base](https://github.com/xchainjs/xchainjs-lib/tree/master/examples/base) examples folder.

// set in env variables so default config can access.
`BASESCAN_API_KEY={YOUR_BASESCAN_API_KEY}`

//Default config can access.
`process.env.BASESCAN_API_KEY`
## Documentation

More information about how to use the Base client can be found on [documentation](https://xchainjs.gitbook.io/xchainjs/clients/xchain-base)

0 comments on commit 7ef641e

Please sign in to comment.