Skip to content

Commit

Permalink
docs: getBalances, transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobinstein committed Dec 2, 2024
1 parent 53bab41 commit 9dfba26
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/build/ar-io-sdk/io/general/get-balance/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { CodeGroup } from '@/components/Code'
main()
```
```typescript {{ title: 'Web' }}
import { IO } from '@ar.io/sdk/web';
import { IO, mIOToken } from '@ar.io/sdk/web';

async function main() {
const io = IO.init();
Expand Down
117 changes: 117 additions & 0 deletions src/app/build/ar-io-sdk/io/general/get-balances/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { CodeGroup } from '@/components/Code'

# getBalances

`getBalances` is a method on the `IO` class that retrieves the balances of the IO process in `mIO`, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous request.

`getBalances` does not require authentication.

## Parameters

{

<div style={{ textAlign: 'center' }}>
<table className="inline-table">
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
<th>Optional</th>
</tr>
</thead>
<tbody>
<tr>
<th>cursor</th>
<td>string - WalletAddress</td>
<td>The last wallet address from previous page of results.</td>
<td>true</td>
</tr>
<tr>
<th>limit</th>
<td>number</td>
<td>The number of results to return per page.</td>
<td>true</td>
</tr>
<tr>
<th>sortBy</th>
<td>string</td>
<td>Attribute to sort results by, i.e. `balance`</td>
<td>true</td>
</tr>
<tr>
<th>sortOrder</th>
<td>string</td>
<td>Order to return sorted results, `asc` or `desc`</td>
<td>true</td>
</tr>
</tbody>
</table>
</div>
}

## Examples

<CodeGroup title="getBalance">

```typescript {{title: 'NodeJS'}}
const {IO, mIOToken} = require('@ar.io/sdk');

async function main(){
const io = IO.init();
const balances = await io.getBalances({
cursor: '-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA',
limit: 100,
sortBy: 'balance',
sortOrder: 'desc',
});

console.log(balances)
}

main()
```

```typescript {{ title: 'Web' }}
import { IO } from '@ar.io/sdk/web';

async function main() {
const io = IO.init();
const balances = await io.getBalances({
cursor: '-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA',
limit: 100,
sortBy: 'balance',
sortOrder: 'desc',
});

console.log(balances)
}

main();
```

</CodeGroup>

## Output

```typescript
{
"items": [
{
"address": "-4xgjroXENKYhTWqrBo57HQwvDL51mMvSxJy6Y2Z_sA",
"balance": 1000000
},
{
"address": "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
"balance": 1000000
}
// ...98 other balances
],
"hasMore": true,
"nextCursor": "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
"totalItems": 1789,
"sortBy": "balance",
"sortOrder": "desc"
}
```

112 changes: 112 additions & 0 deletions src/app/build/ar-io-sdk/io/general/transfer/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { CodeGroup } from '@/components/Code'

# transfer

`transfer` is a method on the `IO` class that transfers `mIO` to the designated `target` recipient address.

`getBalance` requires authentication.

## Parameters

{

<div style={{ textAlign: 'center' }}>
<table className="inline-table">
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
<th>Optional</th>
</tr>
</thead>
<tbody>
<tr>
<th>target</th>
<td>String - WalletAddress</td>
<td>Recipient wallet address to send `mIO` to.</td>
<td>false</td>
</tr>
<tr>
<th>qty</th>
<td>number</td>
<td>The number of `mIO` tokens to transfer.</td>
<td>false</td>
</tr>
<tr>
<th>tags</th>
<td>array</td>
<td>
An array of GQL tag objects to attach to the transfer AO message.
</td>
<td>true</td>
</tr>
</tbody>
</table>
</div>
}

## Examples

<CodeGroup title="getBalance">

```typescript {{title: "NodeJS"}}
const fs = require("fs");
const { IO, ArweaveSigner, IOToken } = require("@ar.io/sdk");

async function main() {
const jwk = JSON.parse(fs.readFileSync("KeyFile.json"));
const io = IO.init({
signer: new ArweaveSigner(jwk),
});

const result = await io.transfer(
{
target: "nszYSUJvtlFXssccPaQWZaVpkXgJHcVM7XhcP5NEt7w",
qty: new IOToken(1000).toMIO(), //converts IO to mIO
},
// Optional tags
{
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
}
);
console.log(result);
}

main();

```

```typescript {{ title: 'Web' }}
import { IO, IOToken, ArConnectSigner } from '@ar.io/sdk/web';

async function main() {
const io = IO.init({
signer: new ArConnectSigner(window.arweaveWallet)
})
const result = await io.transfer(
{
target: "nszYSUJvtlFXssccPaQWZaVpkXgJHcVM7XhcP5NEt7w",
qty: new IOToken(1000).toMIO(), //converts IO to mIO
},
// Optional tags
{
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
}
);
console.log(result);
}

main();
```

</CodeGroup>

## Output

```typescript
{
id: 'Q44fpJLfq8wt-3RXA5a7ReiN7wmwkgxQA2jPYW51R-Q',
result: 'You transferred 1000000000 to nszYSUJvtlFXssccPaQWZaVpkXgJHcVM7XhcP5NEt7w'
}
```

0 comments on commit 9dfba26

Please sign in to comment.