From f8943b503bfd021554726418c05f4847788f8d63 Mon Sep 17 00:00:00 2001 From: Will Hester Date: Fri, 6 Feb 2026 14:43:30 +0000 Subject: [PATCH] add programmable gateway back to docs --- .../9-programmable-gateway-access.md | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 docs/4-write-ten-dapp/9-programmable-gateway-access.md diff --git a/docs/4-write-ten-dapp/9-programmable-gateway-access.md b/docs/4-write-ten-dapp/9-programmable-gateway-access.md new file mode 100644 index 00000000..f90a036c --- /dev/null +++ b/docs/4-write-ten-dapp/9-programmable-gateway-access.md @@ -0,0 +1,116 @@ +--- +sidebar_position: 9 +--- + +# Programmable Access to Gateway + +# TEN Network Gateway API + +Base URL: `https://testnet.ten.xyz` + +## 1. Get Encryption Token + +**Endpoint:** `GET /v1/join` + +Generates and returns an EncryptionToken. + +```bash +curl -X GET https://testnet.ten.xyz/v1/join +``` + +```javascript +const response = await fetch('https://testnet.ten.xyz/v1/join'); +const token = await response.text(); +``` + +## 2. Get Message to Sign + +**Endpoint:** `POST /v1/getmessage` + +Generates and returns a message (if needed 712 typed message too) for the user to sign based on the provided encryption token. + +```bash +curl -X POST "https://testnet.ten.xyz/v1/getmessage/" \ + -H "Content-Type: application/json" \ + -d '{ + "encryptionToken": "$EncryptionToken", + "formats": ["EIP712"] + }' +``` + +```javascript +const msgRes = await fetch('https://testnet.ten.xyz/v1/getmessage/', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + encryptionToken: token, + formats: ['EIP712'], + }), +}); +const data = await msgRes.json(); +``` + +## 3. Authenticate User + +**Endpoint:** `POST /v1/authenticate?token=$EncryptionToken` + +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. + +```bash +curl -X POST "https://testnet.ten.xyz/v1/authenticate/?token=$EncryptionToken" \ + -H "Content-Type: application/json" \ + -d '{ + "address": "$Address", + "signature": "$Signature" + }' +``` + +```javascript +await fetch(`https://testnet.ten.xyz/v1/authenticate/?token=${EncryptionToken}`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + address, + signature: sig + }), +}); +``` + +## 4. Query Address Registration + +**Endpoint:** `GET /v1/query/address?token=$EncryptionToken&a=$Address` + +Returns a JSON response indicating whether the address "a" is registered for the user. + +```bash +curl -X GET "https://testnet.ten.xyz/v1/query/address?token=$EncryptionToken&a=$Address" +``` + +```javascript +const response = await fetch(`https://testnet.ten.xyz/v1/query/address?token=${token}&a=${address}`); +const data = await response.text(); +``` + +## 5. Revoke Access + +**Endpoint:** `POST /v1/revoke?token=$EncryptionToken` + +Deletes encryption token associated with the account. + +```bash +curl -X POST "https://testnet.ten.xyz/v1/revoke?token=abc123" +``` + +```javascript +await fetch(`https://testnet.ten.xyz/v1/revoke?token=${token}`, { + method: 'POST' +}); +``` + +## RPC Usage + +After authentication, use the encryption token with RPC calls: + +``` +https://testnet.ten.xyz/v1/?token= +``` \ No newline at end of file