Skip to content

Commit

Permalink
chore(docs): additional README updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Mar 8, 2024
1 parent 087b390 commit 89db7fd
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @ar-io/sdk

This is the home of ar.io SDK. This SDK provides functionality for interacting with the ar.io ecosystem of services (e.g. gateways and observers) and protocols (e.g. ArNS). It is available for both NodeJS and Web environments.
This is the home of [ar.io] SDK. This SDK provides functionality for interacting with the ar.io ecosystem of services (e.g. gateways and observers) and protocols (e.g. ArNS). It is available for both NodeJS and Web environments.

## Table of Contents

Expand All @@ -21,7 +21,7 @@ This is the home of ar.io SDK. This SDK provides functionality for interacting w
- [Architecture](#architecture)
- [Contributing](./CONTRIBUTING.md)

# Prerequisites
## Prerequisites

- `node>=v.18.0`
- `npm` or `yarn`
Expand Down Expand Up @@ -88,41 +88,38 @@ const gateways = arIO.getGateways();
// }
```

# Usage
## Usage

The SDK is provided in both CommonJS and ESM formats and is compatible with bundlers such as Webpack, Rollup, and ESbuild. Utilize the appropriately named exports provided by this SDK's [package.json] based on your project's configuration. Refer to the [examples] directory to see how to use the SDK in various environments.

## Web
### Web

### Bundlers (Webpack, Rollup, ESbuild, etc.)
#### Bundlers (Webpack, Rollup, ESbuild, etc.)

```javascript
import { ArIO } from '@ar-io/sdk';

// set up client
const arIO = new ArIO();
// fetch gateways
const gateways = arIO.getGateways();
```

### Browser
#### Browser

```html
<script type="module">
import { ArIO } from 'https://unpkg.com/@ar-io/sdk';
// set up client
const arIO = new ArIO();
// fetch gateways
const gateways = await arIO.getGateways();
</script>
```

### Node
#### Node

```javascript
const { ArIO } = require('@ar-io/sdk');

// set up client
const arIO = new ArIO();
// fetch gateways
Expand All @@ -135,11 +132,9 @@ The SDK provides TypeScript types. When you import the SDK in a TypeScript proje

## Configuration

<!-- TODO: add instantiation examples here for warp and remote cache for comparisons once write API's are available. -->

### Custom Contracts

By default - the `ArIO` client uses the `mainnet` contract and exposes APIs relevant to the `ArIO` contract. You can provide custom `contract` or `contractTxId` to the `ArIO` constructor and expose those APIs, assuming the contract is compatible with the `ArIO` contract.
The ArIO contract client class exposes APIs relevant to the ar.io contract. It can be configured to use any contract ID that adheres to the spec of the ar.io contract. In the default case, it will automatically build and utilize a contract data provider interface that is configured to point the the known mainnet contract ID at construction time. You can provide custom contract data provider or, alternatively, a `contractTxId` to the ArIO constructor to use a different, ar.io-spec-compatible contract.

```typescript
// provide a custom contractTxId to the client and default to remote evaluation
Expand All @@ -164,7 +159,7 @@ const remoteCacheCustomArIO = new ArIO({

## APIs

#### `getBalance({ address })`
### `getBalance({ address })`

Retrieves the balance of the specified wallet address.

Expand All @@ -177,7 +172,7 @@ const balance = arIO.getBalance({
// outputs: 0
```

#### `getBalances()`
### `getBalances()`

Retrieves the balances of the ArIO contract.

Expand All @@ -201,7 +196,7 @@ const balances = arIO.getBalances();
// }
```

#### `getGateway({ address })`
### `getGateway({ address, evaluationOptions })`

Retrieves a gateway's info by its staking wallet address.

Expand Down Expand Up @@ -246,7 +241,7 @@ const gateway = arIO.getGateway({
// }
```

#### `getGateways()`
### `getGateways({ evaluationOptions })`

Retrieves the registered gateways of the ArIO contract.

Expand Down Expand Up @@ -296,7 +291,7 @@ const gateways = arIO.getGateways();
// }
```

#### `getArNSRecord({ domain })`
### `getArNSRecord({ domain, evaluationOptions })`

Retrieves the record info of the specified ArNS name.

Expand All @@ -315,7 +310,7 @@ const record = arIO.getArNSRecord({ arnsName: 'ardrive' });
// }
```

#### `getArNSRecords()`
### `getArNSRecords({ evaluationOptions })`

Retrieves all registered ArNS records of the ArIO contract.

Expand Down Expand Up @@ -375,7 +370,7 @@ const records = arIO.getArNSRecords();
For more information on how to contribute, please see [CONTRIBUTING.md].

<!-- ADD ALL LINK REFERENCES BELOW -->

[ar.io]: https://ar.io
[package.json]: ./package.json
[examples]: ./examples
[arns-service]: https://github.com/ar-io/arns-service
Expand Down

0 comments on commit 89db7fd

Please sign in to comment.