Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update polkadot.js apps examples to use polkadot.js api #813

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiPromise, WsProvider } from '@polkadot/api';

const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network');

const main = async () => {
const polkadotApi = await ApiPromise.create({
provider: wsProvider,
});

const balances = await polkadotApi.query.balances.account('INSERT_ADDRESS');
console.log(balances.toHuman());
};

main();
14 changes: 14 additions & 0 deletions .snippets/code/builders/get-started/eth-compare/balances/locks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiPromise, WsProvider } from '@polkadot/api';

const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network');

const main = async () => {
const polkadotApi = await ApiPromise.create({
provider: wsProvider,
});

const locks = await polkadotApi.query.balances.locks('INSERT_ADDRESS');
console.log(locks.toHuman());
};

main();
20 changes: 12 additions & 8 deletions builders/get-started/eth-compare/balances.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ As with Ethereum, there are two main types of accounts: user-owned and contract

![Moonbeam balances diagram](/images/builders/get-started/eth-compare/balances/balances-2.png)

You can check on your balances, including your free (or transferrable) and reserved balances (if exists), using [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/accounts){target=_blank}.
### Retrieve Your Balance {: #retrieve-your-balance }

![View balances on Polkadot.js Apps](/images/builders/get-started/eth-compare/balances/balances-3.png)
You can check on your balances, including your free (or transferrable) and reserved balances (if exists), using the [Polkadot.js API](/builders/build/substrate-api/polkadot-js-api){target=_blank}.

You can also view your balance locks using Polkadot.js Apps. Before getting started, make sure Polkadot.js Apps is connected to the correct network. Then go ahead and select the **Developer** tab, then choose **Chain State**, and take the following steps:
!!! note
--8<-- 'text/_common/endpoint-examples.md'

1. Select **balances** from the **selected state query** dropdown
2. Choose the **locks** extrinsic
3. Enter your address
4. Click the **+** button to submit the extrinsic
```js
--8<-- 'code/builders/get-started/eth-compare/balances/balance.js'
```

![View locks on Polkadot.js Apps](/images/builders/get-started/eth-compare/balances/balances-4.png)
You can also retrieve your balance locks using the Polkadot.js API.

```js
--8<-- 'code/builders/get-started/eth-compare/balances/locks.js'
```

## Main Differences {: #main-differences }

Expand Down
Loading