-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53bab41
commit 9dfba26
Showing
3 changed files
with
230 additions
and
1 deletion.
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
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" | ||
} | ||
``` | ||
|
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,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' | ||
} | ||
``` |