Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 8ef57a5

Browse files
committed
Update exchange guide with store deletion events
1 parent f431121 commit 8ef57a5

File tree

2 files changed

+84
-26
lines changed

2 files changed

+84
-26
lines changed

apps/nextra/pages/en/build/guides/exchanges.mdx

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ const [balanceStr] = await aptos.view<[string]>({
205205
const balance = parseInt(balanceStr, 10);
206206
```
207207

208+
Besides SDK, you can also directly use aptos node's [balance API endpoint](/build/apis/fullnode-rest-api-reference#tag/accounts/GET/accounts/{address}/balance/{asset_type}) to get the balance of a migrated coin or fungible asset.
209+
208210
## Tracking Balance Changes
209211

210212
Balance changes can be queried in one of two ways:
@@ -325,48 +327,80 @@ In this case, we only care about coin store changes.
325327
</details>
326328

327329
3. Events are the events that were emitted by the transaction. In this case, we
328-
only care about the `0x1::coin::deposit` and `0x1::coin::withdraw` events.
330+
only care about the `0x1::coin::Withdraw` and `0x1::coin::Deposit` events.
329331

330-
The Coin deposit event is emitted when coins are deposited into an account. The
331-
account's balance will increase by that amount in the field `data.amoount`. To
332-
determine the matching asset, you must match the `guid` in the `deposit_events`
333-
to the `guid` in the `changes` section for a `CoinStore`.
332+
The Coin withdraw event is emitted when coins are withdrawn from an account. The
333+
account's balance will decrease by that amount in the field `data.amount`. To
334+
determine the matching asset, you must match the `guid` in the `withdraw_events`
335+
to the `guid` in the `changes` section for a `CoinStore`. But if the `CoinStore`
336+
is not found in the `changes`, it means it got deleted, and a `CoinStoreDeleteEvent`
337+
must be present instead. Then you can match the `guid` with
338+
`deleted_withdraw_event_handle_creation_number` and `event_handle_creation_address`.
334339

335340
<details>
336-
<summary>Coin Deposit Event</summary>
341+
<summary>Coin Withdraw Event</summary>
337342
```json
338343
{
339-
"events": [{
340-
"guid": {
341-
"creation_number": "2",
342-
"account_address": "0x5d6233bb8d7f8bd714af196339e9fb3104c9d66f38867b2a0585c4f7b9d04d28"
344+
"events": [
345+
{
346+
"guid": {
347+
"creation_number": "3",
348+
"account_address": "0xf8e25f6c8ce40a15107fb4b4d288ca03dd434d057392f2ccb5fde505a300a0bf"
349+
},
350+
"sequence_number": "0",
351+
"type": "0x1::coin::WithdrawEvent",
352+
"data": {
353+
"amount": "100000"
354+
}
343355
},
344-
"sequence_number": "0",
345-
"type": "0x1::coin::DepositEvent",
346-
"data": {
347-
"amount": "10"
356+
]
357+
}
358+
```
359+
</details>
360+
361+
<details>
362+
<summary>Coin Store Deletion Event</summary>
363+
```json
364+
{
365+
"events": [
366+
{
367+
"guid": {
368+
"creation_number": "0",
369+
"account_address": "0x0"
370+
},
371+
"sequence_number": "0",
372+
"type": "0x1::coin::CoinStoreDeletion",
373+
"data": {
374+
"coin_type": "0x1::aptos_coin::AptosCoin",
375+
"deleted_deposit_event_handle_creation_number": "2",
376+
"deleted_withdraw_event_handle_creation_number": "3",
377+
"event_handle_creation_address": "0xf8e25f6c8ce40a15107fb4b4d288ca03dd434d057392f2ccb5fde505a300a0bf"
378+
}
348379
}
349-
}]
380+
]
350381
}
351382
```
352383
</details>
353384

354-
The Coin withdraw event is emitted when coins are withdrawn from an account. The
355-
account's balance will decrease by that amount in the field `data.amount`. To
385+
The Coin deposit event is emitted when coins are deposited into an account. The
386+
account's balance will increase by that amount in the field `data.amoount`. To
356387
determine the matching asset, you must match the `guid` in the `deposit_events`
357-
to the `guid` in the `changes` section for a `CoinStore`.
388+
to the `guid` in the `changes` section for a `CoinStore`. Similarly, if the `CoinStore`
389+
is not found in the `changes`, it means it got deleted, and a `CoinStoreDeleteEvent`
390+
must be present instead. Then you can match the `guid` with
391+
`deleted_deposit_event_handle_creation_number` and `event_handle_creation_address`.
358392

359393
<details>
360-
<summary>Coin Withdraw Event</summary>
394+
<summary>Coin Deposit Event</summary>
361395
```json
362396
{
363397
"events": [{
364398
"guid": {
365-
"creation_number": "3",
366-
"account_address": "0x559d4f690c683fca7c539237aa8dc4c6ec09886b7016bf66f2cdeffef55468f0"
399+
"creation_number": "2",
400+
"account_address": "0x5d6233bb8d7f8bd714af196339e9fb3104c9d66f38867b2a0585c4f7b9d04d28"
367401
},
368-
"sequence_number": "52484",
369-
"type": "0x1::coin::WithdrawEvent",
402+
"sequence_number": "0",
403+
"type": "0x1::coin::DepositEvent",
370404
"data": {
371405
"amount": "10"
372406
}
@@ -375,6 +409,7 @@ to the `guid` in the `changes` section for a `CoinStore`.
375409
```
376410
</details>
377411

412+
378413
4. Gas usage only is tracked for APT. There is no direct event for tracking gas,
379414
but it can be calculated from the transaction. Using the `gas_used` field, and
380415
the `gas_unit_price` field, you can calculate the total gas used. In this case,
@@ -704,7 +739,10 @@ is the address of the `metadata` for the fungible asset.
704739
Additionally, to figure out the actual owner of the assets, you will need to look
705740
at the owner of the store. In this case, you will need the `0x1::object::ObjectCore`, where
706741
the `address` field matches the `store` field from the events. The `owner` field
707-
will show the asset owner's address.
742+
will show the asset owner's address. similar to the coin events, if the `ObjectCore`
743+
is not found in the `changes`, it means it got deleted, and a `FungibleStoreDeletion`
744+
event must be present instead. Then you can match the `store` fields between the
745+
`Withdraw`/`Deposit` events and the `FungibleStoreDeletion` event.
708746

709747
<details>
710748
<summary>Fungible Asset Changes</summary>
@@ -753,6 +791,25 @@ will show the asset owner's address.
753791
```
754792
</details>
755793

794+
<details>
795+
<summary>FungibleStore Deletion Event</summary>
796+
```json
797+
{
798+
"guid": {
799+
"creation_number": "0",
800+
"account_address": "0x0"
801+
},
802+
"sequence_number": "0",
803+
"type": "0x1::fungible_asset::FungibleStoreDeletion",
804+
"data": {
805+
"metadata": "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
806+
"owner": "0xcf3906e2c9bc7e489c3b09d5ed5d90d8d403a68a50fe52932116b26e5878af26",
807+
"store": "0xa6ab8518e5f28a5f27247a895aa8b3de4a917209c6841b16187e8d64a67de242"
808+
}
809+
}
810+
```
811+
</details>
812+
756813

757814
### Coins migrated to Fungible Asset Balance Changes
758815

@@ -1108,6 +1165,7 @@ Here is an example of a migrated coin with APT: https://api.mainnet.aptoslabs.co
11081165
```
11091166
</details>
11101167

1168+
11111169
## Transferring Assets
11121170

11131171
### Coin (or migrated coin) Transfers
@@ -1149,7 +1207,7 @@ In order to check that everything is working correctly, we've provided these che
11491207
To test balance checks, you can check the balance for the account `0x5` for the asset `0x1::aptos_coin::AptosCoin`.
11501208
The balance should show `0.002 APT`, where 0.001 APT is a coin, and 0.001 APT is a migrated coin (fungible asset).
11511209

1152-
If your balance is not correct, see [Coin and Migrated Coin Balances](#coin-and-migrated-coin-balances) for more information.
1210+
If your balance is not correct, see [Coin and Migrated Coin Balances](#coin-and-migrated-coins-balances) for more information.
11531211

11541212
### Balance Change / Transfer Checks
11551213

apps/nextra/pages/en/build/sdks/ts-sdk/account.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const account = Account.generate({
2727
Following [AIP-55](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-55.md) the SDK supports `Legacy` and `Unified` authentications. `Legacy` includes `ED25519` and `MultiED25519` and `Unified` includes `SingleSender` and `MultiSender` authenticators.
2828
</Callout>
2929

30-
Once you have generated credentials, you **must** fund it for the network to know it exists.
30+
Once you have generated credentials, you **must** fund it for the network before using it.
3131

3232
In test environments this can be done with a faucet by running the following command:
3333

0 commit comments

Comments
 (0)