Skip to content

Commit 4873192

Browse files
authored
Merge pull request #78 from ten-protocol/0xjba-patch-3
Update and rename gateway-widget.md to programmable-gateway.md
2 parents 14e9712 + 7d1f164 commit 4873192

File tree

3 files changed

+117
-8
lines changed

3 files changed

+117
-8
lines changed

docs/tools-infrastructure/gateway-widget.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# Programmable Access to Gateway
6+
7+
# TEN Network Gateway API
8+
9+
Base URL: `https://testnet.ten.xyz`
10+
11+
## 1. Get Encryption Token
12+
13+
**Endpoint:** `GET /v1/join`
14+
15+
Generates and returns an EncryptionToken.
16+
17+
```bash
18+
curl -X GET https://testnet.ten.xyz/v1/join
19+
```
20+
21+
```javascript
22+
const response = await fetch('https://testnet.ten.xyz/v1/join');
23+
const token = await response.text();
24+
```
25+
26+
## 2. Get Message to Sign
27+
28+
**Endpoint:** `POST /v1/getmessage`
29+
30+
Generates and returns a message (if needed 712 typed message too) for the user to sign based on the provided encryption token.
31+
32+
```bash
33+
curl -X POST "https://testnet.ten.xyz/v1/getmessage/" \
34+
-H "Content-Type: application/json" \
35+
-d '{
36+
"encryptionToken": "$EncryptionToken",
37+
"formats": ["EIP712"]
38+
}'
39+
```
40+
41+
```javascript
42+
const msgRes = await fetch('https://testnet.ten.xyz/v1/getmessage/', {
43+
method: 'POST',
44+
headers: { 'Content-Type': 'application/json' },
45+
body: JSON.stringify({
46+
encryptionToken: token,
47+
formats: ['EIP712'],
48+
}),
49+
});
50+
const data = await msgRes.json();
51+
```
52+
53+
## 3. Authenticate User
54+
55+
**Endpoint:** `POST /v1/authenticate?token=$EncryptionToken`
56+
57+
Submits a signed message in the format address & signature, proving ownership of the private keys for the account, and links that account with the encryption token.
58+
59+
```bash
60+
curl -X POST "https://testnet.ten.xyz/v1/authenticate/?token=$EncryptionToken" \
61+
-H "Content-Type: application/json" \
62+
-d '{
63+
"address": "$Address",
64+
"signature": "$Signature"
65+
}'
66+
```
67+
68+
```javascript
69+
await fetch(`https://testnet.ten.xyz/v1/authenticate/?token=${EncryptionToken}`, {
70+
method: 'POST',
71+
headers: { 'Content-Type': 'application/json' },
72+
body: JSON.stringify({
73+
address,
74+
signature: sig
75+
}),
76+
});
77+
```
78+
79+
## 4. Query Address Registration
80+
81+
**Endpoint:** `GET /v1/query/address?token=$EncryptionToken&a=$Address`
82+
83+
Returns a JSON response indicating whether the address "a" is registered for the user.
84+
85+
```bash
86+
curl -X GET "https://testnet.ten.xyz/v1/query/address?token=$EncryptionToken&a=$Address"
87+
```
88+
89+
```javascript
90+
const response = await fetch(`https://testnet.ten.xyz/v1/query/address?token=${token}&a=${address}`);
91+
const data = await response.text();
92+
```
93+
94+
## 5. Revoke Access
95+
96+
**Endpoint:** `POST /v1/revoke?token=$EncryptionToken`
97+
98+
Deletes encryption token associated with the account.
99+
100+
```bash
101+
curl -X POST "https://testnet.ten.xyz/v1/revoke?token=abc123"
102+
```
103+
104+
```javascript
105+
await fetch(`https://testnet.ten.xyz/v1/revoke?token=${token}`, {
106+
method: 'POST'
107+
});
108+
```
109+
110+
## RPC Usage
111+
112+
After authentication, use the encryption token with RPC calls:
113+
114+
```
115+
https://testnet.ten.xyz/v1/?token=<EncryptionToken>
116+
```

docs/troubleshooting/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Keep in mind that you will not be able to query data on accounts that have not b
1414
You need to follow the following steps:
1515

1616
1. Change the functions of your smart contracts according to the instructions given [here](/docs/getting-started/for-developers/explore-contracts-in-ten).
17-
2. Integrate TEN Gateway into your dApp using the instructions provided [here](/docs/tools-infrastructure/gateway-widget).
17+
2. Integrate TEN Gateway into your dApp.
1818
3. Deploy your SCs into TEN using [compatible tools](/docs/tools-infrastructure/compatible-tools) (e.g. Truffle Suite).
1919
4. Invite your users to learn more about encryption!
2020

0 commit comments

Comments
 (0)