@@ -27,7 +27,7 @@ const [tonConnectUI] = useTonConnectUI();
27
27
28
28
const transaction = {
29
29
// transaction body
30
- })
30
+ }
31
31
32
32
export const Settings = () => {
33
33
const [tonConnectUI , setOptions ] = useTonConnectUI ();
@@ -1355,15 +1355,13 @@ Go examples are using [tonconnect](https://github.com/cameo-engineering/tonconne
1355
1355
1356
1356
``` go
1357
1357
import " github.com/cameo-engineering/tonconnect"
1358
- import " github.com/xssnick/tonutils-go/ton "
1358
+ import " github.com/xssnick/tonutils-go/address "
1359
1359
```
1360
1360
1361
1361
:::tip
1362
1362
Read [ tonconnect] ( https://github.com/cameo-engineering/tonconnect/blob/master/examples/basic/main.go ) and [ tonutils-go] ( https://github.com/xssnick/tonutils-go?tab=readme-ov-file#how-to-use ) examples.
1363
1363
:::
1364
1364
1365
- ### Initiate connector and send transaction
1366
-
1367
1365
There you can find how to create tonconnect session and send transaction constructed with messages.
1368
1366
1369
1367
``` go
@@ -1381,7 +1379,13 @@ In further examples only messages and transactions will be created.
1381
1379
Example of function for building regular TON transfer message:
1382
1380
1383
1381
``` go
1384
- func transfer (dest string , amount uint64 ) (*tonconnect .Message , error ) {
1382
+ import (
1383
+ " fmt"
1384
+
1385
+ " github.com/cameo-engineering/tonconnect"
1386
+ )
1387
+
1388
+ func Transfer (dest string , amount uint64 ) (*tonconnect .Message , error ) {
1385
1389
msg , err := tonconnect.NewMessage (
1386
1390
dest,
1387
1391
fmt.Sprintf (" %d " , amount), // nanocoins to transfer/compute message
@@ -1392,7 +1396,7 @@ func transfer(dest string, amount uint64) (*tonconnect.Message, error) {
1392
1396
Final transaction body:
1393
1397
1394
1398
``` go
1395
- msg , err := transfer (" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbLZ" , uint64 (math.Pow (10 , 9 )))
1399
+ msg , err := Transfer (" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbLZ" , uint64 (math.Pow (10 , 9 )))
1396
1400
if err != nil {
1397
1401
log.Fatal (err)
1398
1402
}
@@ -1411,7 +1415,14 @@ if err != nil {
1411
1415
Example of function for building transfer with comment message:
1412
1416
1413
1417
``` go
1414
- func transfer_with_comment (dest string , amount uint64 , comment string ) (*tonconnect .Message , error ) {
1418
+ import (
1419
+ " fmt"
1420
+
1421
+ " github.com/cameo-engineering/tonconnect"
1422
+ " github.com/xssnick/tonutils-go/tvm/cell"
1423
+ )
1424
+
1425
+ func TransferWithComment (dest string , amount uint64 , comment string ) (*tonconnect .Message , error ) {
1415
1426
payload , _ := cell.BeginCell ().
1416
1427
MustStoreUInt (0 , 32 ).
1417
1428
MustStoreStringSnake (comment).
@@ -1426,7 +1437,7 @@ func transfer_with_comment(dest string, amount uint64, comment string) (*tonconn
1426
1437
Final transaction body:
1427
1438
1428
1439
``` go
1429
- msg , err := transfer_with_comment (" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbLZ" , uint64 (math.Pow (10 , 9 )), " new comment" )
1440
+ msg , err := TransferWithComment (" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbLZ" , uint64 (math.Pow (10 , 9 )), " new comment" )
1430
1441
if err != nil {
1431
1442
log.Fatal (err)
1432
1443
}
@@ -1445,7 +1456,15 @@ if err != nil {
1445
1456
Example of function for jetton transfer message:
1446
1457
1447
1458
``` go
1448
- func jetton_transfer_message (jetton_wallet_address string , amount uint64 ,
1459
+ import (
1460
+ " fmt"
1461
+
1462
+ " github.com/cameo-engineering/tonconnect"
1463
+ " github.com/xssnick/tonutils-go/address"
1464
+ " github.com/xssnick/tonutils-go/tvm/cell"
1465
+ )
1466
+
1467
+ func JettonTransferMessage (jetton_wallet_address string , amount uint64 ,
1449
1468
jettons_amount uint64 , recipient_address, response_address string ,
1450
1469
fwd_amount uint64 , fwd_payload *cell.Cell ) (*tonconnect.Message , error ) {
1451
1470
payload , _ := cell.BeginCell ().
@@ -1475,7 +1494,7 @@ func jetton_transfer_message(jetton_wallet_address string, amount uint64,
1475
1494
Final transaction body:
1476
1495
1477
1496
``` go
1478
- msg , err := jetton_transfer_message (" kQA8Q7m_pSNPr6FcqRYxllpAZv-0ieXy_KYER2iP195hBXiX" ,
1497
+ msg , err := JettonTransferMessage (" kQA8Q7m_pSNPr6FcqRYxllpAZv-0ieXy_KYER2iP195hBXiX" ,
1479
1498
uint64 (math.Pow (10 , 9 )),
1480
1499
uint64 (10 ),
1481
1500
" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbL2" ,
@@ -1499,7 +1518,15 @@ if err != nil {
1499
1518
Example of function for jetton burn message:
1500
1519
1501
1520
``` go
1502
- func jetton_burn_message (jetton_wallet_address string , amount uint64 ,
1521
+ import (
1522
+ " fmt"
1523
+
1524
+ " github.com/cameo-engineering/tonconnect"
1525
+ " github.com/xssnick/tonutils-go/address"
1526
+ " github.com/xssnick/tonutils-go/tvm/cell"
1527
+ )
1528
+
1529
+ func JettonBurnMessage (jetton_wallet_address string , amount uint64 ,
1503
1530
jettons_amount uint64 , response_address string ) (*tonconnect.Message , error ) {
1504
1531
1505
1532
payload , _ := cell.BeginCell ().
@@ -1525,7 +1552,7 @@ func jetton_burn_message(jetton_wallet_address string, amount uint64,
1525
1552
Final transaction body:
1526
1553
1527
1554
``` go
1528
- msg , err := jetton_burn_message (" kQA8Q7m_pSNPr6FcqRYxllpAZv-0ieXy_KYER2iP195hBXiX" ,
1555
+ msg , err := JettonBurnMessage (" kQA8Q7m_pSNPr6FcqRYxllpAZv-0ieXy_KYER2iP195hBXiX" ,
1529
1556
uint64 (math.Pow (10 , 9 )),
1530
1557
uint64 (10 ),
1531
1558
" EQBuObr2M7glm08w6cBGjIuuCbmvBFGwuVs6qb3AQpac9XpX" )
@@ -1547,7 +1574,15 @@ if err != nil {
1547
1574
Example of function for NFT transfer message:
1548
1575
1549
1576
``` go
1550
- func nft_transfer_message (nft_address string , amount uint64 , recipient_address, response_address string ,
1577
+ import (
1578
+ " fmt"
1579
+
1580
+ " github.com/cameo-engineering/tonconnect"
1581
+ " github.com/xssnick/tonutils-go/address"
1582
+ " github.com/xssnick/tonutils-go/tvm/cell"
1583
+ )
1584
+
1585
+ func NftTransferMessage (nft_address string , amount uint64 , recipient_address, response_address string ,
1551
1586
fwd_amount uint64 , fwd_payload *cell.Cell ) (*tonconnect.Message , error ) {
1552
1587
1553
1588
payload , _ := cell.BeginCell ().
@@ -1576,7 +1611,7 @@ func nft_transfer_message(nft_address string, amount uint64, recipient_address,
1576
1611
Final transaction body:
1577
1612
1578
1613
``` go
1579
- msg , err := nft_transfer_message (" EQDrA-3zsJXTfGo_Vdzg8d07Da4vSdHZllc6W9qvoNoMstF-" ,
1614
+ msg , err := NftTransferMessage (" EQDrA-3zsJXTfGo_Vdzg8d07Da4vSdHZllc6W9qvoNoMstF-" ,
1580
1615
uint64 (math.Pow (10 , 9 )),
1581
1616
" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbL2" ,
1582
1617
" 0QBZ_35Wy144n2GBM93YpcV4KOKcIjDJk8DdX4kyXEEHcbL2" ,
@@ -1619,7 +1654,18 @@ Because message requires a lot of steps, the entire algorithm huge and could be
1619
1654
<summary >Show entire algorithm for the creating NFT Sale message body</summary >
1620
1655
1621
1656
``` go
1622
- func nft_sale_message (wallet , royalty , nft string , amount , price uint64 ) (*tonconnect .Message , error ) {
1657
+ import (
1658
+ " fmt"
1659
+ " math"
1660
+ " time"
1661
+
1662
+ " github.com/cameo-engineering/tonconnect"
1663
+ " github.com/xssnick/tonutils-go/address"
1664
+ " github.com/xssnick/tonutils-go/tlb"
1665
+ " github.com/xssnick/tonutils-go/tvm/cell"
1666
+ )
1667
+
1668
+ func NftSaleMessage (wallet , royalty , nft string , amount , price uint64 ) (*tonconnect .Message , error ) {
1623
1669
fixPriceV3R2Code := new (cell.Cell )
1624
1670
fixPriceV3R2Code.UnmarshalJSON ([]byte (" te6cckECCwEAArkAART/APSkE/S88sgLAQIBIAIDAgFIBAUAfvIw7UTQ0wDTH/pA+kD6QPoA1NMAMMABjh34AHAHyMsAFssfUATPFljPFgHPFgH6AszLAMntVOBfB4IA//7y8AICzQYHAFegOFnaiaGmAaY/9IH0gfSB9AGppgBgYaH0gfQB9IH0AGEEIIySsKAVgAKrAQH30A6GmBgLjYSS+CcH0gGHaiaGmAaY/9IH0gfSB9AGppgBgYOCmE44BgAEqYhOmPhW8Q4YBKGATpn8cIxbMbC3MbK2QV44LJOZlvKAVxFWAAyS+G8BJrpOEBFcCBFd0VYACRWdjYKdxjgthOjq+G6hhoaYPqGAD9gHAU4ADAgB92YIQO5rKAFJgoFIwvvLhwiTQ+kD6APpA+gAwU5KhIaFQh6EWoFKQcIAQyMsFUAPPFgH6AstqyXH7ACXCACXXScICsI4XUEVwgBDIywVQA88WAfoCy2rJcfsAECOSNDTiWnCAEMjLBVADzxYB+gLLaslx+wBwIIIQX8w9FIKAejy0ZSzjkIxMzk5U1LHBZJfCeBRUccF8uH0ghAFE42RFrry4fUD+kAwRlAQNFlwB8jLABbLH1AEzxZYzxYBzxYB+gLMywDJ7VTgMDcowAPjAijAAJw2NxA4R2UUQzBw8AXgCMACmFVEECQQI/AF4F8KhA/y8AkA1Dg5ghA7msoAGL7y4clTRscFUVLHBRWx8uHKcCCCEF/MPRQhgBDIywUozxYh+gLLassfFcs/J88WJ88WFMoAI/oCE8oAyYMG+wBxUGZFFQRwB8jLABbLH1AEzxZYzxYBzxYB" ))
1625
1671
@@ -1702,7 +1748,7 @@ func nft_sale_message(wallet, royalty, nft string, amount, price uint64) (*tonco
1702
1748
The final transaction body:
1703
1749
1704
1750
``` go
1705
- msg , err := nft_sale_message (" EQArLGBnGPvkxaJE57Y6oS4rwzDWuOE8l8_sghntXLkIt162" ,
1751
+ msg , err := NftSaleMessage (" EQArLGBnGPvkxaJE57Y6oS4rwzDWuOE8l8_sghntXLkIt162" ,
1706
1752
" EQArLGBnGPvkxaJE57Y6oS4rwzDWuOE8l8_sghntXLkIt162" ,
1707
1753
" EQCUWoe7hLlklVxH8gduCf45vPNocsjRP4wbX42UJ0Ja0S2f" ,
1708
1754
uint64 (1.08 *math.Pow (10 , 9 )), uint64 (5 *math.Pow (10 , 9 )))
0 commit comments