npm i tonkey-gateway-typescript-sdk
npm i @apollo/client
import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client";
const client = new ApolloClient({
uri: GRAPHQL_URI || "",
cache: new InMemoryCache(),
connectToDevTools: true,
});
<ApolloProvider client={client}>
{children}
</ApolloProvider>
const { safeInfo, loading, error } = useWalletByAddress(address, chainId);
//address:TON raw address
//chainId: Mainnet: -239, Testnet: -3
const { safeList, loading, error, refetch } = useWalletsByOwnerAddress(address);
//address:TON raw address
To get the list again after first query
refetch({ ownerAddress: yourAddress });
//ownerAddress:TON raw address
const { data, error, loading } = useTxHistory(address, chainId, POLLING_INTERVAL);
/address:TON raw address
//chainId: Mainnet: -239, Testnet: -3
//POLLING_INTERVAL: number, unit: ms
const { data, error, loading } = useTxQueue(address, chainId, POLLING_INTERVAL);
//address:TON raw address
//chainId: Mainnet: -239, Testnet: -3
//POLLING_INTERVAL: number, unit: ms
const { data, error, loading, refetch } = useGetBalanceBySafeAddress(address, chainId, POLLING_INTERVAL);
//address:TON raw address
//chainId: Mainnet: -239, Testnet: -3
//POLLING_INTERVAL: number, unit: ms
To get the balance again after first query
refetch({ chainId: chainId, safeAddress: rawAddress });
- Generate payload to server
const payload = await getTransferpayload(transferParams);
transferParams:
{
"recipient": "kQCmxsVr-UHBmi0lUTAFcI2q7C7zItI8czKuzjBX7yjvhdoM", //recipient's ton address
"amount": "10000000", //amount in nanoTon
"orderCellBoc": "bocCompiledFrom Tonkey-core-sdk", //to see how to build it checkout tonkey-coe-sdk
"queryId": "6488358a00000000", //you will get this info from tonkey-coe-sdk (createOrder)
"expiredTime": "1686648202000", //you will get this info from tonkey-coe-sdk (createOrder)
"wallet": {
"address": "0:a6c6c56bf941c19a2d25513005708daaec2ef322d23c7332aece3057ef28ef85", //ton raw address
"chain": "-3" //Mainnet: -239, Testnet: -3
},
"safe": {
"address": "0:d4e1d52bdecd315d8685cfccc985e2cf7da6fe39ab6617b420df914197f14b30",
"chainId": "-3",
"owners": [
{
"address": "0:a6c6c56bf941c19a2d25513005708daaec2ef322d23c7332aece3057ef28ef85",
"publicKey": "8d2f6c1743b61633094c91356bb4f0697286a89a624856f1a672ab97e119105b"
},
{
"address": "0:1f517d873e59c3b4b6f5dcafe87202231086920732d4386faa3cdefaf0912a62",
"publicKey": "ba9f6848becef9ccaf265d79a78af22127b0fc089c6a489ea57f0a0bed76e98b"
}
],
"safeId": "61709",
"threshold": 1,
"walletId": "61709"
}, //you will get all the columns from Get Safe Info method above
"tokenInfo": {
"jettonMinterAddress": "000000",
"tokenName": "Toncoin",
"tokenSymbol": "TON",
"logoUri": "https://ton.org/download/ton_symbol.svg",
"decimals": 9
}, //you can get tokenInfo from Get balance of a specific safe method
"signatures": [
"9177a7c7fe2e91e067490737883f8a2e804caef0894f9230a749ac10def2420bcd19c5ae8af7b0afc65a17f2da51e8f0d640191a1265248ebbab9b20852d3003",
""
] //please refer to tonkey-core-sdk using Sign with OpenMask
}
After getting the payload
- Send payload to server
const { createTransfer, data, loading, error } = useCreateNativeTransfer();
await createTransfer({ variables: { content: payload } });