-
Notifications
You must be signed in to change notification settings - Fork 0
Add how to get wallet data page #596
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
Draft
Karkarmath
wants to merge
20
commits into
main
Choose a base branch
from
add-how-to-get-wallet-data
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+62
−2
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5ef3b30
Initial commit
Karkarmath d64f0e3
Formater
Karkarmath 6b1e894
Improvements
Karkarmath a131826
Merge branch 'main' into add-how-to-get-wallet-data
Karkarmath ad20a49
cool
Karkarmath 93a76f9
Pictures
Karkarmath 9decba6
Fixes
Karkarmath cfa31cd
Merge branch 'main' into add-how-to-get-wallet-data
Karkarmath 3879d3f
rm unnecessary dependencies
novusnota 44a8467
enhance!
novusnota 83bae91
better sidebar presence
novusnota 44ebf9c
Merge branch 'main' into add-how-to-get-wallet-data
Karkarmath 6d70516
Merge branch 'main' into add-how-to-get-wallet-data
Karkarmath 7787040
Merge branch 'main' into add-how-to-get-wallet-data
Karkarmath 322f67f
kapa
Karkarmath 6d11419
Impro
Karkarmath ebab335
Merge branch 'add-how-to-get-wallet-data' of github.com:tact-lang/min…
Karkarmath 0ab9b88
Formater
Karkarmath 6c7eef1
Impro
Karkarmath 83965ea
fix
skywardboundd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,59 @@ | ||
--- | ||
title: "How to get Jetton wallet data" | ||
sidebarTitle: "Get Jetton wallet data" | ||
--- | ||
|
||
import { Image } from '/snippets/image.jsx'; | ||
|
||
To retrieve the Jetton wallet's account jetton amount, owner identification information, and other details related to a specific Jetton wallet contract, | ||
use the `get_wallet_data()` [get method](/guidebook/first-smart-contract#6-2-reading-contract-data-with-get-methods) within the Jetton wallet contract. | ||
|
||
This method returns the following data: | ||
|
||
| Name | Type | Description | | ||
| ----------------------- | ---------------- | ---------------------------------------------- | | ||
| `balance` | `VarUInteger 16` | the amount of nano tokens on the Jetton wallet | | ||
| `owner` | `MsgAddress` | the address of owner's regular wallet | | ||
| `jetton_master_address` | `MsgAddress` | the address of the Jetton master contract | | ||
| `jetton_wallet_code` | `Cell` | a code of the Jetton wallet | | ||
|
||
You can call the `get_wallet_data()` method from your favorite IDE: | ||
|
||
```javascript | ||
Karkarmath marked this conversation as resolved.
Show resolved
Hide resolved
Karkarmath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { Address, TonClient } from "@ton/ton" | ||
|
||
async function main() { | ||
const client = new TonClient({ | ||
endpoint: 'https://toncenter.com/api/v2/jsonRPC', | ||
}); | ||
|
||
const JettonWalletAddress = Address | ||
.parse('EQDmVdCZ2SALvyfCDVlPLr0hoPhUxgjNFtTAxemz9V_C5wbN'); | ||
|
||
const data = await client.runMethod(JettonWalletAddress, | ||
'get_wallet_data'); | ||
|
||
const Stack = data.stack; | ||
|
||
console.log("Balance in nano tokens: ", Stack.readNumber()); | ||
|
||
// wallet address | ||
console.log("Owner: ", Stack.readAddress().toString({ bounceable: false })); | ||
|
||
console.log("Jetton Master address: ", Stack.readAddress().toString()); | ||
|
||
// default boc encoding in viewers | ||
console.log("Jetton Wallet code: ", Stack.readCell().toBoc().toString('hex')); | ||
} | ||
|
||
void main(); | ||
``` | ||
|
||
Or call it through a web service, such as [Tonviewer](https://tonviewer.com/EQDmVdCZ2SALvyfCDVlPLr0hoPhUxgjNFtTAxemz9V_C5wbN?section=method): | ||
|
||
<Image | ||
src="/resources/images/tonviewer/get-wallet-data.png" | ||
darkSrc="/resources/images/tonviewer/get-wallet-data-dark.png" | ||
/> | ||
|
||
Finally, you can get this information using the [API](https://toncenter.com/api/v3/jetton/wallets). |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.