-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from xssnick/addr-improvements
LoadAddr check type
- Loading branch information
Showing
7 changed files
with
114 additions
and
31 deletions.
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
Binary file not shown.
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,55 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/xssnick/tonutils-go/address" | ||
"github.com/xssnick/tonutils-go/liteclient" | ||
"github.com/xssnick/tonutils-go/ton" | ||
"github.com/xssnick/tonutils-go/tvm/cell" | ||
"log" | ||
) | ||
|
||
func main() { | ||
client := liteclient.NewClient() | ||
|
||
// connect to mainnet lite server | ||
err := client.Connect(context.Background(), "135.181.140.212:13206", "K0t3+IWLOXHYMvMcrGZDPs+pn58a17LFbnXoQkKc2xw=") | ||
if err != nil { | ||
log.Fatalln("connection err: ", err.Error()) | ||
return | ||
} | ||
|
||
// initialize ton api lite connection wrapper | ||
api := ton.NewAPIClient(client) | ||
|
||
// we need fresh block info to run get methods | ||
b, err := api.GetBlockInfo(context.Background()) | ||
if err != nil { | ||
log.Fatalln("get block err:", err.Error()) | ||
return | ||
} | ||
|
||
// call method to get data from nft address | ||
res, err := api.RunGetMethod(context.Background(), b, address.MustParseAddr("EQAMo8TmviyZpBLLJMDDwYDhFsdyj26XoAM4_mNyMtfxuT6O"), "get_nft_data") | ||
if err != nil { | ||
log.Fatalln("run get method err:", err.Error()) | ||
return | ||
} | ||
|
||
collectionAddr, err := res[2].(*cell.Cell).BeginParse().LoadAddr() | ||
if err != nil { | ||
log.Fatalln("addr err:", err.Error()) | ||
return | ||
} | ||
|
||
ownerAddr, err := res[3].(*cell.Cell).BeginParse().LoadAddr() | ||
if err != nil { | ||
log.Fatalln("addr err:", err.Error()) | ||
return | ||
} | ||
|
||
fmt.Println("NFT collection: ", collectionAddr.String()) | ||
fmt.Println("NFT owner: ", ownerAddr.String()) | ||
fmt.Println("Content:", res[4].(*cell.Cell).Dump()) | ||
} |
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
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