From 637866c4aa12b788f9bcd22e4541204c17dcf574 Mon Sep 17 00:00:00 2001
From: Justin <102846781+HoangVD2@users.noreply.github.com>
Date: Wed, 12 Jun 2024 22:36:12 +0700
Subject: [PATCH 1/2] docs: add content for Gas Tank API Documentation
(XDEFI-6907) (#34)
* docs: base init for Gas Tank API Documentation
* base: add code sample for some feature
* chore: update api endpoint
* docs: update content for Gas Tank API Documentation
* chore: update api endpoint
* chore: fix comment
* docs: update for comment
* base: fix comment
* base: update
* base: update
* chore: update
* chore: small updates
* chore: small update for body request
* chore: update title
* base: add Message Gastank docs
* chore: update
* chore: fix comment
* chore: update endpoint
---------
Co-authored-by: dp <25910069+davidp94@users.noreply.github.com>
---
.vitepress/config.ts | 28 +-
assets-services/assets-and-prices-api.md | 6 +-
components/staking/CreateCosmosDelegateTx.jsx | 2 +-
components/staking/CreateErc20ApproveTx.jsx | 2 +-
components/staking/CreateLidoStakeTx.jsx | 2 +-
.../staking/CreateStrideLiquidStakingTx.jsx | 2 +-
components/staking/GetCosmosDelegations.jsx | 2 +-
components/staking/GetLidoStakedBalance.jsx | 2 +-
.../staking/GetStrideStakedAssetBalance.jsx | 2 +-
gas-tank/authentication-services.md | 133 +++++
gas-tank/balance-services.md | 553 ++++++++++++++++++
gas-tank/chains-services.md | 169 ++++++
gas-tank/gas-tank-api.md | 24 +-
gas-tank/messages-service.md | 142 +++++
gas-tank/other-services.md | 110 ++++
staking/staking-api.md | 20 +-
16 files changed, 1176 insertions(+), 23 deletions(-)
create mode 100644 gas-tank/authentication-services.md
create mode 100644 gas-tank/balance-services.md
create mode 100644 gas-tank/chains-services.md
create mode 100644 gas-tank/messages-service.md
create mode 100644 gas-tank/other-services.md
diff --git a/.vitepress/config.ts b/.vitepress/config.ts
index d8dcf64b8..fd2a6cf99 100644
--- a/.vitepress/config.ts
+++ b/.vitepress/config.ts
@@ -756,7 +756,33 @@ function sidebarHome() {
{
text: "⛽ Gas Tank API",
link: "/gas-tank/gas-tank-api",
- items: [],
+ collapsed: true,
+ items: [
+ {
+ text: "🔹 Introduction",
+ link: "/gas-tank/gas-tank-api",
+ },
+ {
+ text: "🔹 Authentication",
+ link: "/gas-tank/gas-tank-api#authentication",
+ },
+ {
+ text: "🔹 Messages",
+ link: "/gas-tank/gas-tank-api#messages",
+ },
+ {
+ text: "🔹 Chains / Tokens / Status",
+ link: "/gas-tank/gas-tank-api#chains-token-status",
+ },
+ {
+ text: "🔹 Balances & Gas top-up: Deposit, Withdraw, Send Gas",
+ link: "/gas-tank/gas-tank-api#balance-transactions-deposit-withdraw-send-gas",
+ },
+ {
+ text: "🔹 Other services",
+ link: "/gas-tank/gas-tank-api#other-services",
+ },
+ ],
},
{
text: "🛠️ Partners APIs",
diff --git a/assets-services/assets-and-prices-api.md b/assets-services/assets-and-prices-api.md
index cefef09a0..41c7b0889 100644
--- a/assets-services/assets-and-prices-api.md
+++ b/assets-services/assets-and-prices-api.md
@@ -170,7 +170,7 @@ getSupportedChains();
Get Assets Crypto Currencies provides information about cryptocurrencies on various blockchains, including Ethereum, Binance Smart Chain, and Solana. The API returns data such as the cryptocurrency's name, symbol, icon, type, external data, scaling factor, chain, market cap, and price.
-[Query GraphQL directly here](https://gql-router.dev.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAMKEAOKEJMeeyUAlggM4AUAJOQIYDmC6UhCRIEUFI2EBBPLxYBCADREOAM0YAbFPkFkClarXpIoBAGKbteZR26qrABTyMoAogBFu2gCqNENuytBTx8-BABKImAAHSQiIm4WFgQUFijY%2BPioCioaOgZmdh5%2BQS4%2BBGV1LR0VKqtlQPwnFzdbeybnVwb2vFLGvEiYuMz44oQQ7nThkayIGFQMmfiNP0YURaWIVVVk9enMgF8NzLGppdHygEkkVQgz8-iAC0SAOQQADxQHcuOl5DA8iwIHhfodQfEEGB%2BGkhg94kgIGAEPc4URGGBwTMkNxEJiRiwCHAAEYQDR4zIuYTk%2BIofQIalED5WbEaCYMuDcPAAaxSJG45AZLCg3BWSF4Zm44mBDKgz0YSAZ5E6yNhqMyOLmC32DyO2pmup1oINYOGuoOIEUIAAbpzGNwiRpWBgQKroiAxm7BKr4m71HgWOsMEQAKyKY5u-qeohIGAaMmmsPDX2WfBR71EN2y7jylhRmNxxMjN3o3NB-MaQuZN0E4mk0uCcuLA6ViM9ZquPOxiuLVtWTtx2Lmy3kCAB1QrXiPFAAeXI%2BC8kiQAGVsoxKM6QAcgA)
+[Query GraphQL directly here](https://gql-router.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAMKEAOKEJMeeyUAlggM4AUAJOQIYDmC6UhCRIEUFI2EBBPLxYBCADREOAM0YAbFPkFkClarXpIoBAGKbteZR26qrABTyMoAogBFu2gCqNENuytBTx8-BABKImAAHSQiIm4WFgQUFijY%2BPioCioaOgZmdh5%2BQS4%2BBGV1LR0VKqtlQPwnFzdbeybnVwb2vFLGvEiYuMz44oQQ7nThkayIGFQMmfiNP0YURaWIVVVk9enMgF8NzLGppdHygEkkVQgz8-iAC0SAOQQADxQHcuOl5DA8iwIHhfodQfEEGB%2BGkhg94kgIGAEPc4URGGBwTMkNxEJiRiwCHAAEYQDR4zIuYTk%2BIofQIalED5WbEaCYMuDcPAAaxSJG45AZLCg3BWSF4Zm44mBDKgz0YSAZ5E6yNhqMyOLmC32DyO2pmup1oINYOGuoOIEUIAAbpzGNwiRpWBgQKroiAxm7BKr4m71HgWOsMEQAKyKY5u-qeohIGAaMmmsPDX2WfBR71EN2y7jylhRmNxxMjN3o3NB-MaQuZN0E4mk0uCcuLA6ViM9ZquPOxiuLVtWTtx2Lmy3kCAB1QrXiPFAAeXI%2BC8kiQAGVsoxKM6QAcgA)
::: code-group
@@ -349,7 +349,7 @@ getCryptoAssets();
Get Assets Fiat Currencies provides information about fiat currencies on various blockchains, including Ethereum, Binance Smart Chain, and Solana. The API returns data such as the fiat currency's name, symbol, scaling factor, character, and price.
-[Query GraphQL directly here](https://gql-router.dev.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAGICWAhigMIx57JRkIDOAFACQAOFA5guiLUISJAigoyIgIJ5eLAIQAaIhwBmZADYp8g8lVr1GBctvwqOFNTryCAIlQQAVMogtWbABTxkoAog46LogAlETAADpIREQULCwIKCzhUTExGgZ0DEhMrGw8-ILcfAgqGma2quU2Kh66qnV4tdb43r7%2Bli14bX5hkdFpMQUIgRQpA4MxUBAwqKmTMZquZCjzCxBqagmrE2kAvmtpw%2BMLQyUAkkhqECenMchghiwQeIcLABZxAHIIAB4onhKb32wPuYH4yX6dxiSAgYAQt2hRDIYFBkyQFEQaMGLAIcAARhBNNi0iwoBQlkheCQKBIXiSpp88LSbAyiFwfH5EUjYnAZnNdncDoLJsKhcCxSCBsK9iAlCAAG4UHwUfGaVgYEBQogREDDXWCbUxXUaPAsVYYIgAViUh11jQNRCQME0xOltoGJq0rMtRp1IBRLEdztd8z2HuNIAdlpDmgj-saPQQwZdbtl8q4EHNaiWvHeKAA8lx8FQpEgAMpQHxcNCYEB7IA)
+[Query GraphQL directly here](https://gql-router.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAGICWAhigMIx57JRkIDOAFACQAOFA5guiLUISJAigoyIgIJ5eLAIQAaIhwBmZADYp8g8lVr1GBctvwqOFNTryCAIlQQAVMogtWbABTxkoAog46LogAlETAADpIREQULCwIKCzhUTExGgZ0DEhMrGw8-ILcfAgqGma2quU2Kh66qnV4tdb43r7%2Bli14bX5hkdFpMQUIgRQpA4MxUBAwqKmTMZquZCjzCxBqagmrE2kAvmtpw%2BMLQyUAkkhqECenMchghiwQeIcLABZxAHIIAB4onhKb32wPuYH4yX6dxiSAgYAQt2hRDIYFBkyQFEQaMGLAIcAARhBNNi0iwoBQlkheCQKBIXiSpp88LSbAyiFwfH5EUjYnAZnNdncDoLJsKhcCxSCBsK9iAlCAAG4UHwUfGaVgYEBQogREDDXWCbUxXUaPAsVYYIgAViUh11jQNRCQME0xOltoGJq0rMtRp1IBRLEdztd8z2HuNIAdlpDmgj-saPQQwZdbtl8q4EHNaiWvHeKAA8lx8FQpEgAMpQHxcNCYEB7IA)
::: code-group
@@ -605,7 +605,7 @@ getLosersTokens();
Get LP Tokens is fully the same structure as Get Assets Tokens but it’s like "Low Priority" tokens. The API returns data such as the LP token's symbol, scaling factor, address, chain, fees, defi protocols and external data.
-[Query GraphQL directly here](https://gql-router.dev.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABADIAKAKhANbIDOAFACQAOAhgOYLpEDCESJAigoAlgICCeDnQCEAGiJMAZqIA2KfDyq0kAMXWa8ipm2VGeAETaaKoxCbNGyeUVG5Frt%2BwgCURYAAdJCIiNjo6BBQ6AODQ0LUWHXoGdi4eVk4ERVUNLSVco0UnfNNzfGLyvBc3DzLnV3d-IJD40LSELzZY1rbQqAgYVDi%2BhPtRFBHRiGVlSMne%2BIBfKfiOntH2rIBJJGUIDc3Q5DBeGDw6CDxV0YALcIA5BAAPFDIsm%2BXP47AuGJajqEkBAwAhDoCiANUHg2CJ-t9NqIwAjRnQCHAAEYQNQovp0KBsNSiJAcPSwlBXXFtNhgMB4BARKnxKD3YlM0LKBBggEQvoAN0JuHZRBWiwhoNULggFIGanBvP6rKQwtCbgEKqISDYiGFooVet5LyMWrUXSZSPNUKZWp1Ys2cDYeFoKF4bBYTJYjW5wu1g2GdtGBohaMx2KZKAILAQuKDfVjoVjBtFSxA8hAAtcbAxagZGBAPMCIA6hZ4PNChdUF0mGCIAFZ5KtCyVrjWkDA1DjWksG60K4Z8CX5YWQ1i1HRB22Oz22oWkePW%2B21NP4oWWWxifOeJOl42QDS6QzN5rFyNuyMm1UJ4vlxeGrUrx3gim0ywIHQUMoiRxbigAPJRmExAEABlKBXBYNBMBAJYgA)
+[Query GraphQL directly here](https://gql-router.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABADIAKAKhANbIDOAFACQAOAhgOYLpEDCESJAigoAlgICCeDnQCEAGiJMAZqIA2KfDyq0kAMXWa8ipm2VGeAETaaKoxCbNGyeUVG5Frt%2BwgCURYAAdJCIiNjo6BBQ6AODQ0LUWHXoGdi4eVk4ERVUNLSVco0UnfNNzfGLyvBc3DzLnV3d-IJD40LSELzZY1rbQqAgYVDi%2BhPtRFBHRiGVlSMne%2BIBfKfiOntH2rIBJJGUIDc3Q5DBeGDw6CDxV0YALcIA5BAAPFDIsm%2BXP47AuGJajqEkBAwAhDoCiANUHg2CJ-t9NqIwAjRnQCHAAEYQNQovp0KBsNSiJAcPSwlBXXFtNhgMB4BARKnxKD3YlM0LKBBggEQvoAN0JuHZRBWiwhoNULggFIGanBvP6rKQwtCbgEKqISDYiGFooVet5LyMWrUXSZSPNUKZWp1Ys2cDYeFoKF4bBYTJYjW5wu1g2GdtGBohaMx2KZKAILAQuKDfVjoVjBtFSxA8hAAtcbAxagZGBAPMCIA6hZ4PNChdUF0mGCIAFZ5KtCyVrjWkDA1DjWksG60K4Z8CX5YWQ1i1HRB22Oz22oWkePW%2B21NP4oWWWxifOeJOl42QDS6QzN5rFyNuyMm1UJ4vlxeGrUrx3gim0ywIHQUMoiRxbigAPJRmExAEABlKBXBYNBMBAJYgA)
::: code-group
diff --git a/components/staking/CreateCosmosDelegateTx.jsx b/components/staking/CreateCosmosDelegateTx.jsx
index 0dda8fca0..7c23d2996 100644
--- a/components/staking/CreateCosmosDelegateTx.jsx
+++ b/components/staking/CreateCosmosDelegateTx.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { cosmosSupportedAssets as assetSupported } from "../common";
const CreateCosmosDelegateTx = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const validators = ["Meria", "StakeLab", "Custom"];
const [loading, setLoading] = useState(false);
diff --git a/components/staking/CreateErc20ApproveTx.jsx b/components/staking/CreateErc20ApproveTx.jsx
index 04d711419..4c4ee99bf 100644
--- a/components/staking/CreateErc20ApproveTx.jsx
+++ b/components/staking/CreateErc20ApproveTx.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { otherSupportedAssets as assetSupported } from "../common";
const CreateErc20ApproveTx = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const [loading, setLoading] = useState(false);
const [response, setResponse] = useState({});
const [assetSelected, setAssetSelected] = useState(undefined);
diff --git a/components/staking/CreateLidoStakeTx.jsx b/components/staking/CreateLidoStakeTx.jsx
index 4e238b170..09a23a235 100644
--- a/components/staking/CreateLidoStakeTx.jsx
+++ b/components/staking/CreateLidoStakeTx.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { otherSupportedAssets as assetSupported } from "../common";
const CreateLidoStakeTx = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const [loading, setLoading] = useState(false);
const [response, setResponse] = useState({});
const [assetSelected, setAssetSelected] = useState(undefined);
diff --git a/components/staking/CreateStrideLiquidStakingTx.jsx b/components/staking/CreateStrideLiquidStakingTx.jsx
index 9b1866da1..b4027d270 100644
--- a/components/staking/CreateStrideLiquidStakingTx.jsx
+++ b/components/staking/CreateStrideLiquidStakingTx.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { cosmosSupportedAssets as assetSupported } from "../common";
const CreateStrideLiquidStakingTx = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const [loading, setLoading] = useState(false);
const [response, setResponse] = useState({});
const [assetSelected, setAssetSelected] = useState(undefined);
diff --git a/components/staking/GetCosmosDelegations.jsx b/components/staking/GetCosmosDelegations.jsx
index a6cb3d1c4..23f5b4052 100644
--- a/components/staking/GetCosmosDelegations.jsx
+++ b/components/staking/GetCosmosDelegations.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { cosmosSupportedAssets as assetSupported } from "../common";
const GetCosmosDelegations = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const [loading, setLoading] = useState(false);
const [response, setResponse] = useState({});
const [assetSelected, setAssetSelected] = useState(undefined);
diff --git a/components/staking/GetLidoStakedBalance.jsx b/components/staking/GetLidoStakedBalance.jsx
index 58a11540c..734c40c5a 100644
--- a/components/staking/GetLidoStakedBalance.jsx
+++ b/components/staking/GetLidoStakedBalance.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { otherSupportedAssets as assetSupported } from "../common";
const GetLidoStakedBalance = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const [loading, setLoading] = useState(false);
const [response, setResponse] = useState({});
const [assetSelected, setAssetSelected] = useState(undefined);
diff --git a/components/staking/GetStrideStakedAssetBalance.jsx b/components/staking/GetStrideStakedAssetBalance.jsx
index 200fb2709..512b70e2c 100644
--- a/components/staking/GetStrideStakedAssetBalance.jsx
+++ b/components/staking/GetStrideStakedAssetBalance.jsx
@@ -4,7 +4,7 @@ import PlayIcon from "../PlayIcon";
import { cosmosSupportedAssets as assetSupported } from "../common";
const GetStrideStakedAssetBalance = () => {
- const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+ const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const [loading, setLoading] = useState(false);
const [response, setResponse] = useState({});
const [assetSelected, setAssetSelected] = useState(undefined);
diff --git a/gas-tank/authentication-services.md b/gas-tank/authentication-services.md
new file mode 100644
index 000000000..8b5a65f52
--- /dev/null
+++ b/gas-tank/authentication-services.md
@@ -0,0 +1,133 @@
+## Authentication
+
+### Multiple Addresses Login
+
+This endpoint facilitates the generation of JWT tokens for multiple wallet addresses in a single request. The request payload should consist of an array of objects, each containing an address and its corresponding signature. Upon successful validation of the signatures, the server will generate JWT tokens for the provided addresses.
+
+To get signatures, you can use `personal_sign` method from web3.js or ethers.js. Below is an example of how to get a signature using web3.js:
+
+::: code-group
+
+```javascript [Request]
+const web3 = new Web3(window.ethereum);
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+const address1 = "0x1234567890123456789012345678901234567890";
+const address2 = "0x0987654321098765432109876543210987654321";
+
+const messageToSign = await (
+ await fetch(`${GAS_TANK_ENDPOINT}/v2/auth/message`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify([address1, address2]),
+ })
+).json();
+
+const message = messageToSign.message;
+
+
+const signature1 = await web3.eth.personal.sign(message, address1);
+const signature2 = await web3.eth.personal.sign(message, address2);
+
+await fetch(`${GAS_TANK_ENDPOINT}/v2/auth/login`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify([
+ {
+ address: address1, // Address of the user // [!code highlight]
+ signature: signature1, // Signature // [!code highlight]
+ },
+ {
+ address: address2, // [!code highlight]
+ signature: signature2, // [!code highlight]
+ },
+ ...
+ ]),
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+```
+
+```json [Response]
+{
+ "access": "jwt.access.token",
+ "refresh": "jwt.refresh.token"
+}
+```
+
+:::
+
+You can also add new wallets to an existing JWT token. Request will be secured by JWT header. Clients need to submit an array of objects containing the address and signature for each new wallet. The server will validate the signatures and, if successful, update the existing JWT token to include the new wallets and generate new JWT.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/v2/auth/update`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify([
+ {
+ address: newAddress, // [!code highlight]
+ signature: newSignature, // [!code highlight]
+ },
+ ...
+ ]),
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+```
+
+```json [Response]
+{
+ "access": "jwt.access.token",
+ "refresh": "jwt.refresh.token"
+}
+```
+
+:::
+
+### Refresh JWT Token
+
+Clients can use this endpoint to obtain a new JWT token without re-authenticating, providing a refresh token.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/v2/auth/refresh`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify({
+ refresh: refreshToken, // Refresh token // [!code highlight]
+ }),
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "access": "jwt.access.token",
+ "refresh": "jwt.refresh.token"
+}
+```
+
+:::
diff --git a/gas-tank/balance-services.md b/gas-tank/balance-services.md
new file mode 100644
index 000000000..a4c424326
--- /dev/null
+++ b/gas-tank/balance-services.md
@@ -0,0 +1,553 @@
+## Balance & Transactions - Deposit, Withdraw, Send Gas
+
+### Get all balance entries for user
+
+This endpoint returns a list of all balance entries per address by using JWT
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "additionalProp1": [
+ {
+ "id": "string",
+ "address": "string",
+ "tokenAddress": "string",
+ "balance": 0,
+ "chain": "string"
+ }
+ ],
+ "additionalProp2": [
+ {
+ "id": "string",
+ "address": "string",
+ "tokenAddress": "string",
+ "balance": 0,
+ "chain": "string"
+ }
+ ],
+ ...
+}
+```
+
+:::
+
+### Get balances by address
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/${address}`, { // Address to retrieve balances // [!code highlight]
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json"
+ "Authorization": `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+```
+
+```json [Response]
+[
+ {
+ "id": "string",
+ "address": "string",
+ "tokenAddress": "string",
+ "balance": 0,
+ "chain": "string"
+ },
+ ...
+]
+```
+
+:::
+
+### Get total balances using JWT
+
+This endpoint returns a list of total balances for the specified JWT.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/totals`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+[
+ {
+ "address": "string",
+ "symbol": "string",
+ "value": "string",
+ "decimals": 0
+ },
+ ...
+]
+```
+
+:::
+
+### Deposit balance
+
+This endpoint allows users to deposit balance to the Gas Tank platform.
+
+To deposit the balance, you need to sign the message with the private key of the address you want to deposit the balance for. `v`, `r`, `s` are the signature fields of the message signed by the address owner and `message` is generated in [Construct Deposit Message](#construct-deposit-message).
+
+You can sign a string of data using [ethers.js](https://docs.ethers.org/v5), below is an example of [how to sign a message using ethers.js](https://docs.ethers.org/v5/getting-started/#getting-started--signing) and deposit the balance.
+
+::: code-group
+
+```javascript [Request]
+import { ethers } from "ethers";
+
+const web3 = new Web3(window.ethereum);
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+const address = "0x1234567890123456789012345678901234567890"; // Address to deposit balance // [!code highlight]
+const message = message; // Message is generated in Construct Deposit Message
+const privateKey = "0x1234"; // Private key of the address // [!code highlight]
+const wallet = new ethers.Wallet(privateKey);
+const signature = await wallet.signMessage(message);
+const { v, r, s } = ethers.utils.splitSignature(signature);
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/increase`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json"
+ "Authorization": `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify({
+ address: address, // [!code highlight]
+ tokenAddress: "string", // Token contract address for deposit // [!code highlight]
+ chain: "string", // The blockchain network [!code highlight]
+ owner: "string", // The owner's address (can match the 'address' field) [!code highlight]
+ spender: "string", // Gas Tank's internal address [!code highlight]
+ value: "string", // Amount of deposited token [!code highlight]
+ deadline: 0, // Date for checking the validity of the signature [!code highlight]
+ v: v, // [!code highlight]
+ r: r, // [!code highlight]
+ s: s // [!code highlight]
+ }),
+})
+ .then((response) => {
+ // Balance deposit successfully
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+:::
+
+### Withdraw balance
+
+This endpoint allows users to withdraw their balance from the Gas Tank platform.
+
+To withdraw the balance, you need to sign the message with the private key of the address you want to withdraw the balance from. The `signature` field is the signature of the message signed by the address owner and `message` is generated in [Aonstruct Withdraw Message](#construct-withdraw-message).
+
+Same as the [Deposit balance](#deposit-balance), you can sign a string of data using [ethers.js](https://docs.ethers.org/v5/getting-started/), below is an example of [how to sign a message using ethers.js](https://docs.ethers.org/v5/getting-started/#getting-started--signing) and withdraw the balance.
+
+::: code-group
+
+```javascript [Request]
+import { ethers } from "ethers";
+
+const web3 = new Web3(window.ethereum);
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+const address = "0x1234567890123456789012345678901234567890"; // Address to withdraw balance // [!code highlight]
+const message = message; // Message is generated in Construct Withdraw Message
+const privateKey = "0x1234"; // Private key of the address // [!code highlight]
+const wallet = new ethers.Wallet(privateKey);
+const signature = await wallet.signMessage(message);
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/withdraw`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json"
+ "Authorization": `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify({
+ address: address, // [!code highlight]
+ tokenAddress: "string", // Token contract address for withdraw [!code highlight]
+ amount: "string", // Amount of withdraw token [!code highlight]
+ chain: "string", // The blockchain network [!code highlight]
+ recipient: "string", // The recipient's wallet address [!code highlight]
+ message: message, // [!code highlight]
+ signature: signature // [!code highlight]
+ }),
+})
+ .then((response) => {
+ // Balance withdrawn successfully
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+:::
+
+### Internal transfer
+
+This endpoint allows users to create an internal transfer task on the Gas Tank platform. The internal transfer task is used to transfer balance from one address to another address on the Gas Tank platform. The `signature` field is the signature of the message signed by the address owner and `message` is generated in [Construct Internal Transfer Message](#construct-internal-transfer-message).
+
+::: code-group
+
+```javascript [Request]
+import { ethers } from "ethers";
+
+const web3 = new Web3(window.ethereum);
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+const address = "0x1234567890123456789012345678901234567890"; // Address to transfer balance // [!code highlight]
+const message = message; // Message is generated in Construct Internal Transfer Message
+const privateKey = "0x1234"; // Private key of the address // [!code highlight]
+const wallet = new ethers.Wallet(privateKey);
+const signature = await wallet.signMessage(message);
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/transfer`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify({
+ address: address, // [!code highlight]
+ tokenAddress: "string", // Token contract address for transfer [!code highlight]
+ amount: "string", // Amount of transfer [!code highlight]
+ chain: "string", // The blockchain network [!code highlight]
+ recipient: "string", // The recipient's wallet address [!code highlight]
+ message: message, // [!code highlight]
+ signature: signature, // [!code highlight]
+ }),
+})
+ .then((response) => {
+ // Internal transfer task created successfully
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+:::
+
+### Get a quote for consuming balance
+
+This endpoint allows users to generate a quote for consuming their balance on the Gas Tank platform.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/consume/quote`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify({
+ address: "string", // Your wallet address // [!code highlight]
+ minDestinationAmount: "string", // Minimum amount of the token to consume // [!code highlight]
+ destinationChain: "string", // The blockchain network // [!code highlight]
+ }),
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+{
+ "expectedOutput": "string",
+ "fee": "string",
+ "spentAssets": [
+ {
+ "tokenAddress": "string",
+ "amount": "string",
+ "chain": "string"
+ }
+ ]
+}
+```
+:::
+
+### Consume balance
+
+This endpoint allows users to consume their balance on the Gas Tank platform.
+
+To consume the balance, you need to sign the message with the private key of the address you want to consume the balance from. The `signature` field is the signature of the message signed by the address owner and `message` is generated in [Construct Consume Message](#construct-consume-message).
+
+Same as the [Deposit balance](#deposit-balance)/[Withdraw balance](#withdraw-balance), you can sign a string of data using [ethers.js](https://docs.ethers.org/v5/getting-started/), below is an example of [how to sign a message using ethers.js](https://docs.ethers.org/v5/getting-started/#getting-started--signing) and consume the balance.
+
+::: code-group
+
+```javascript [Request]
+import { ethers } from "ethers";
+
+const web3 = new Web3(window.ethereum);
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+const address = "0x1234567890123456789012345678901234567890"; // Address to consume balance // [!code highlight]
+const message = message; // Message is generated in Construct Consume Message
+const privateKey = "0x1234"; // Private key of the address // [!code highlight]
+const wallet = new ethers.Wallet(privateKey);
+const signature = await wallet.signMessage(message);
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/consume`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ body: JSON.stringify({
+ address: address, // [!code highlight]
+ minDestinationAmount: "string", // Minimum amount of the token to consume // [!code highlight]
+ destinationAddress: "string", // The recipient's wallet address // [!code highlight]
+ destinationChain: "string", // The blockchain network // [!code highlight]
+ message: message, // [!code highlight]
+ signature: signature, // [!code highlight]
+ }),
+})
+ .then((response) => {
+ // Balance consumed successfully
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+:::
+
+### Get user balance queue update
+
+This endpoint allows users to get the balance queue update for any job ongoing (e.g., deposit, withdrawal, transfer, consume).
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/transactions`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+{
+ "additionalProp1": [
+ {
+ "id": "string",
+ "type": "string",
+ "address": "string",
+ "tokenAddress": "string",
+ "amount": "string",
+ "chain": "string",
+ "destinationChain": "string",
+ "destinationAddress": "string",
+ "permitObject": {},
+ "processed": true,
+ "processedMetadata": {},
+ "pendingTransactions": [
+ {
+ "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "chain": "ethereum",
+ "transactionHash": "0x6b175474e89094c44da98b954eedeac495271d0f",
+ "blockNumber": 123456,
+ "balanceUpdateId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "confirmed": false,
+ "createdAt": "2023-01-01T00:00:00Z",
+ "updatedAt": "2023-01-01T00:00:00Z"
+ }
+ ],
+ "createdAt": "2024-04-11T04:13:07.102Z",
+ "updatedAt": "2024-04-11T04:13:07.102Z"
+ }
+ ],
+ ...
+}
+```
+
+:::
+
+### Get balance queue update by ID
+
+This endpoint allows users to get the balance queue update for a specific ID (e.g., deposit, withdrawal, transfer, consume).
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/transactions/${id}`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+{
+ "id": "string",
+ "type": "string",
+ "address": "string",
+ "tokenAddress": "string",
+ "amount": "string",
+ "chain": "string",
+ "destinationChain": "string",
+ "destinationAddress": "string",
+ "permitObject": {},
+ "processed": true,
+ "processedMetadata": {},
+ "pendingTransactions": [
+ {
+ "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "chain": "ethereum",
+ "transactionHash": "0x6b175474e89094c44da98b954eedeac495271d0f",
+ "blockNumber": 123456,
+ "balanceUpdateId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "confirmed": false,
+ "createdAt": "2023-01-01T00:00:00Z",
+ "updatedAt": "2023-01-01T00:00:00Z"
+ }
+ ],
+ "createdAt": "2024-04-11T04:17:30.107Z",
+ "updatedAt": "2024-04-11T04:17:30.107Z"
+}
+```
+
+:::
+
+### Get pending transactions by address
+
+This endpoint allows users to get pending transactions for a specific address. Results returned a list of pending transactions.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(
+ `${GAS_TANK_ENDPOINT}/transactions/pending/${address}`, // Address to retrieve pending transaction // [!code highlight]
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ },
+)
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+[
+ {
+ "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "chain": "ethereum",
+ "transactionHash": "0x6b175474e89094c44da98b954eedeac495271d0f",
+ "blockNumber": 123456,
+ "balanceUpdateId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ "confirmed": false,
+ "createdAt": "2023-01-01T00:00:00Z",
+ "updatedAt": "2023-01-01T00:00:00Z"
+ },
+ ...
+]
+```
+
+:::
+
+### Get fee for a given amount
+
+This endpoint allows users to get the fee for a given amount in a specific chain.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(
+ `${GAS_TANK_ENDPOINT}/fees/${chain}`, // Chain to get fee // [!code highlight]
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+ },
+)
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+{
+ "high": "string",
+ "medium": "string",
+ "low": "string"
+}
+```
+
+:::
diff --git a/gas-tank/chains-services.md b/gas-tank/chains-services.md
new file mode 100644
index 000000000..c993f2e1f
--- /dev/null
+++ b/gas-tank/chains-services.md
@@ -0,0 +1,169 @@
+## Chains / Token / Status
+
+### Get all Tokens
+
+This endpoint allows users to retrieve information about all tokens available on the Gas Tank platform.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/chains/tokens`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "additionalProp1": {
+ "name": "string",
+ "key": "string",
+ "chainId": "string",
+ "native": {
+ "symbol": "string",
+ "decimals": 0,
+ "address": "string",
+ "actions": [
+ "string"
+ ]
+ },
+ "tokens": [
+ {
+ "name": "string",
+ "symbol": "string",
+ "decimals": 0,
+ "address": "string",
+ "actions": [
+ "string"
+ ]
+ }
+ ]
+ },
+ "additionalProp2": {
+ "name": "string",
+ "key": "string",
+ "chainId": "string",
+ "native": {
+ "symbol": "string",
+ "decimals": 0,
+ "address": "string",
+ "actions": [
+ "string"
+ ]
+ },
+ "tokens": [
+ {
+ "name": "string",
+ "symbol": "string",
+ "decimals": 0,
+ "address": "string",
+ "actions": [
+ "string"
+ ]
+ }
+ ]
+ },
+ ...
+}
+```
+
+:::
+
+### Get dispatchers information
+
+This endpoint provides information about the dispatchers on the Gas Tank platform.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/chains/dispatchers-info`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "additionalProp1": {
+ "chain": "string",
+ "address": "string",
+ "balance": "string",
+ "status": "string",
+ "threshold": "string"
+ },
+ "additionalProp2": {
+ "chain": "string",
+ "address": "string",
+ "balance": "string",
+ "status": "string",
+ "threshold": "string"
+ },
+ ...
+}
+```
+
+:::
+
+### Get chains Operational status
+
+This endpoint provides information about the status of all supported chains on the Gas Tank platform.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/chains/status`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${jwtToken}`, // JWT token // [!code highlight]
+ },
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "operational": true,
+ "chains": [
+ {
+ "chain": "string",
+ "operational": true,
+ "actions": {
+ "increase": true,
+ "withdraw": true,
+ "consume": true
+ },
+ "extras": {
+ "address": "string",
+ "balance": "string",
+ "threshold": "string",
+ "status": "string"
+ },
+ "comment": "string"
+ },
+ ...
+ ]
+}
+```
+
+:::
diff --git a/gas-tank/gas-tank-api.md b/gas-tank/gas-tank-api.md
index 5464b97f8..65ac786c3 100644
--- a/gas-tank/gas-tank-api.md
+++ b/gas-tank/gas-tank-api.md
@@ -1,3 +1,23 @@
-# Gas Tank API
+---
+next:
+ text: "🔹 Campaigns Service API"
+ link: "/campaigns/campaigns-service-api"
+---
-Coming soon...
+# Gas Tank API Documentation
+
+The Gas Tank is a versatile platform that empowers users to manage gas tank balances seamlessly across different blockchain networks. This project facilitates actions such as depositing, withdrawing, internal transferring, and consuming gas tank balances, allowing users to efficiently utilize their resources on EVM, Cosmos-like, and UTXO chains. With support for multiple blockchain environments, The Gas Tank offers users a unified solution for gas utilization across diverse networks. Check the [Gas Tank API Swagger](https://gas-tank.xdefi.services/docs/) for more information.
+
+The base URL for all Gas Tank API is: https://gas-tank.xdefi.services
+
+Below are the available services provided by the Gas Tank API. You need to have a valid JWT token to access the services. You can get the JWT token by using the _[Multiple Address Login](#multiple-address-login)_ endpoint.
+
+
+
+
+
+
+
+
+
+
diff --git a/gas-tank/messages-service.md b/gas-tank/messages-service.md
new file mode 100644
index 000000000..a1bd5806f
--- /dev/null
+++ b/gas-tank/messages-service.md
@@ -0,0 +1,142 @@
+## Messages
+
+### Construct Deposit Message
+
+This endpoint will generate `messages` parameter for [Deposit balances](#deposit-balance).
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/msg/increase`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ owner: "0xOwnerWalletAddress", // The wallet address of the owner // [!code highlight]
+ tokenAddress: "0xTokenContractAddress", // The contract address of the token // [!code highlight]
+ amount: "1", // Amount of the token to deposit // [!code highlight]
+ chain: "ethereum", // The blockchain network, e.g., 'ethereum' // [!code highlight]
+ }),
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "type": "string",
+ "message": "string"
+}
+```
+
+:::
+
+### Construct Withdraw Message
+
+This endpoint will generate `messages` parameter for [Withdraw balances](#withdraw-balance).
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/msg/withdraw`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ address: "0xYourWalletAddress", // Your wallet address // [!code highlight]
+ tokenAddress: "0xTokenContractAddress", // The contract address of the token // [!code highlight]
+ amount: "1", // Amount of the token to withdraw // [!code highlight]
+ chain: "ethereum", // The blockchain network, e.g., 'ethereum' // [!code highlight]
+ recipient: "0xRecipientWalletAddress", // The recipient's wallet address // [!code highlight]
+ }),
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "type": "string",
+ "message": "string"
+}
+```
+
+:::
+
+### Construct Internal Transfer Message
+
+This endpoint will generate `messages` parameter for [Internal Transfer balances](#internal-transfer).
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/msg/internal-transfer`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ address: "0xYourWalletAddress", // Your wallet address // [!code highlight]
+ tokenAddress: "0xTokenContractAddress", // The contract address of the token // [!code highlight]
+ amount: "1", // Amount of the token to transfer // [!code highlight]
+ chain: "ethereum", // The blockchain network, e.g., 'ethereum' // [!code highlight]
+ recipient: "0xRecipientWalletAddress", // The recipient's wallet address // [!code highlight]
+ }),
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "type": "string",
+ "message": "string"
+}
+```
+
+:::
+
+### Construct Consume Message
+
+This endpoint will generate `messages` parameter for [Consume balances](#consume-balance).
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/msg/consume`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ address: "0xYourWalletAddress", // Your wallet address // [!code highlight]
+ minDestinationAmount: "1", // Minimum amount of the token to consume // [!code highlight]
+ destinationChain: "ethereum", // The blockchain network, e.g., 'ethereum' // [!code highlight]
+ }),
+}).then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+});
+```
+
+```json [Response]
+{
+ "type": "string",
+ "message": "string"
+}
+```
+
+:::
diff --git a/gas-tank/other-services.md b/gas-tank/other-services.md
new file mode 100644
index 000000000..327fd0078
--- /dev/null
+++ b/gas-tank/other-services.md
@@ -0,0 +1,110 @@
+## Other services
+
+This section provides information about the other services provided by the Gas Tank API. APIs in this section not require JWT token for authentication.
+
+### Get information about the Gas Tank
+
+This endpoint provides information about the conversion rates between different tokens and fees for deposit, withdrawal and consume actions.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/balances/info`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+{
+ "conversionRates": {
+ "xdefi": {
+ "eth": 0.00003406230336183101,
+ "bnb": 0.00020052618581142264,
+ "usdc": 0.13496037812654052,
+ "usdt": 0.1349557894736842,
+ ...
+ },
+ "eth": {
+ "xdefi": 29357.967644682656,
+ "usdt": 3763.926315789474,
+ ...
+ },
+ ... // Other pairs
+ },
+ "spenderAddresses": [
+ "0x0E87C393120410d1edd00Ae5b616419795c5B57D"
+ ],
+ "fees": {
+ "deposit": {
+ "fees": {
+ "high": "357840000000000",
+ "medium": "357420000000000",
+ "low": "357210000000000"
+ }
+ },
+ "withdraw": {
+ "fees": {
+ "high": "357840000000000",
+ "medium": "357420000000000",
+ "low": "357210000000000"
+ }
+ },
+ "consume": {
+ "fees": {
+ "high": "357840000000000",
+ "medium": "357420000000000",
+ "low": "357210000000000"
+ }
+ }
+ }
+}
+```
+
+:::
+
+### Check the status of the application
+
+This endpoint provides information about the status of the Gas Tank application and its dependencies.
+
+::: code-group
+
+```javascript [Request]
+const GAS_TANK_ENDPOINT = "https://gas-tank.xdefi.services";
+
+await fetch(`${GAS_TANK_ENDPOINT}/healthcheck`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+})
+ .then((response) => {
+ console.log(response);
+ // Handle & do something with the response
+ })
+ .catch((error) => {
+ // Catch & handle the error
+ });
+```
+
+```json [Response]
+{
+ "status": "OK",
+ "database": "Connected",
+ "mnemonic": "Set",
+ "nats": "Connected"
+}
+```
+
+:::
diff --git a/staking/staking-api.md b/staking/staking-api.md
index 1c9074a2c..5cf4c0b04 100644
--- a/staking/staking-api.md
+++ b/staking/staking-api.md
@@ -6,7 +6,7 @@ Staking is a process that involves holding funds in a cryptocurrency wallet to s
XDEFI offers a staking API that enables developers to engage with the staking features across multiple blockchain networks. This API is crafted for simplicity and ease of use, emphasizing a high degree of abstraction from the complexities of the underlying blockchains.
-The base URL for all API endpoints is: https://gql-router.dev.xdefi.services/graphql
+The base URL for all API endpoints is: https://gql-router.xdefi.services/graphql
Below are the services provided by the staking API.
@@ -28,7 +28,7 @@ You can use the `getStrideStakedAssetBalance` query to get the balance of a stak
::: code-group
```javascript [GetStrideStakedAssetBalance]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetStrideStakedAssetBalance($strideAddress: String!, $asset: SupportedAssets!) {
staking {
getStrideStakedAssetBalance(asset: $asset, strideAddress: $strideAddress) {
@@ -80,7 +80,7 @@ You can use the `createStrideLiquidStakingTx` mutation to create a staking trans
::: code-group
```javascript [CreateStrideLiquidStakingTx]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query CreateStrideLiquidStakingTx($input: StrideStakingInput!) {
staking {
createStrideLiquidStakingTx(input: $input)
@@ -134,7 +134,7 @@ You can use the `getCosmosDelegations` query to get the delegations of a Cosmos
::: code-group
```javascript [GetCosmosDelegations]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query getCosmosDelegations($asset: SupportedAssets!, $address: String!) {
staking {
getCosmosDelegations(address: $address, asset: $asset) {
@@ -189,7 +189,7 @@ You can use the `createCosmosDelegateTx` mutation to create a native staking tra
::: code-group
```javascript [Meria/StakeLab Validator]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query CreateCosmosDelegateTx($delegationInput: CosmosDelegationInput!, $validatorAddress: String, $provider: Providers) {
staking {
createCosmosDelegateTx(
@@ -230,7 +230,7 @@ await fetch(GRAPHQL_ENDPOINT, {
```
```javascript [Custom validator’s address]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query CreateCosmosDelegateTx($delegationInput: CosmosDelegationInput!, $validatorAddress: String, $provider: Providers) {
staking {
createCosmosDelegateTx(
@@ -293,7 +293,7 @@ You can use the `getLidoStakedAssetBalance` query to get the balance of a staked
::: code-group
```javascript [GetLidoStakedBalance]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetLidoStakedBalance($asset: SupportedAssets!, $address: String!) {
staking {
getLidoStakedBalance(address: $address, asset: $asset) {
@@ -343,7 +343,7 @@ You can use the `createLidoStakeTx` query to create a staking transaction on LID
::: code-group
```javascript [CreateLidoStakeTx]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query CreateLidoStakeTx($input: LidoStakingInput!) {
staking {
createLidoStakeTx(input: $input) {
@@ -397,7 +397,7 @@ You can use the `lidoCheckErc20Allowance` query to check the allowance for staki
::: code-group
```javascript [LidoCheckErc20Allowance]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query LidoCheckErc20Allowance($ownerAddress: String!, $asset: SupportedAssets!) {
staking {
lidoCheckErc20Allowance(input: {ownerAddress: $ownerAddress, asset: $asset})
@@ -443,7 +443,7 @@ You can use the `createErc20ApproveTx` query to create an approval transaction t
::: code-group
```javascript [CreateErc20ApproveTx]
-const GRAPHQL_ENDPOINT = "https://gql-router.dev.xdefi.services/graphql";
+const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query createErc20ApproveTx($input: Erc20ApproveInput!) {
staking {
createErc20ApproveTx(input: $input) {
From a7ee03634833ee06590b4ba1ceacf7133e1a7d47 Mon Sep 17 00:00:00 2001
From: maxlm-devico <98474638+maxlm-devico@users.noreply.github.com>
Date: Wed, 12 Jun 2024 18:37:28 +0300
Subject: [PATCH 2/2] docs: libraries integration (#15)
* feat: update RainbowKit integration docs
* feat: add results and theming
* chore: remove unnecessary quotes
* feat: web3onboard integration guide
* feat: CosmosKit docs
* add solana documentation
---
developers/blocknative-xdefi-integration.md | 314 +++++++++++++++++-
developers/cosmoskit-xdefi-integration.md | 20 +-
.../blocknative/blocknative_connect_modal.jpg | Bin 0 -> 140524 bytes
.../web3-onboard-connect-wallet-btn.jpg | Bin 0 -> 26597 bytes
.../web3onboard-account-information.jpg | Bin 0 -> 123992 bytes
.../web3onboard-control-center.jpg | Bin 0 -> 90140 bytes
.../blocknative/web3onboard-disconnect.jpg | Bin 0 -> 32088 bytes
.../cosmos-kit-xdefi-integration.jpg | Bin 0 -> 182050 bytes
.../rainbowkit_integration_result.jpg | Bin 0 -> 162726 bytes
.../solana-detected-wallet-standard.jpg | Bin 0 -> 52527 bytes
.../solana/solana-no-wallets-available.jpg | Bin 0 -> 52807 bytes
.../solana/solana-wallet-not-installed.jpg | Bin 0 -> 51914 bytes
...lana-xdefi-integration-nextjs-template.jpg | Bin 0 -> 36545 bytes
developers/rainbowkit-xdefi-integration.md | 207 +++++++++---
.../solana-adapter-xdefi-integration.md | 92 +++--
15 files changed, 535 insertions(+), 98 deletions(-)
create mode 100644 developers/images/blocknative/blocknative_connect_modal.jpg
create mode 100644 developers/images/blocknative/web3-onboard-connect-wallet-btn.jpg
create mode 100644 developers/images/blocknative/web3onboard-account-information.jpg
create mode 100644 developers/images/blocknative/web3onboard-control-center.jpg
create mode 100644 developers/images/blocknative/web3onboard-disconnect.jpg
create mode 100644 developers/images/cosmos-kit/cosmos-kit-xdefi-integration.jpg
create mode 100644 developers/images/rainbowkit/rainbowkit_integration_result.jpg
create mode 100644 developers/images/solana/solana-detected-wallet-standard.jpg
create mode 100644 developers/images/solana/solana-no-wallets-available.jpg
create mode 100644 developers/images/solana/solana-wallet-not-installed.jpg
create mode 100644 developers/images/solana/solana-xdefi-integration-nextjs-template.jpg
diff --git a/developers/blocknative-xdefi-integration.md b/developers/blocknative-xdefi-integration.md
index d54b61882..476ee6ac0 100644
--- a/developers/blocknative-xdefi-integration.md
+++ b/developers/blocknative-xdefi-integration.md
@@ -1,28 +1,310 @@
# BlockNative XDEFI Integration
-First, your app need to install the core Onboard library, the injected wallets module and optionally ethers js to support browser extension and mobile wallets:
+In this tutorial we're going to build dApp which supports multiple wallets using the [Web3-Onboard](https://onboard.blocknative.com) library.
+
+![image](images/blocknative/blocknative_connect_modal.jpg)
+
+### Get started
+
+Create new react app
+
+```bash
+npx create-react-app my-blocknative-app --template typescript
+```
+
+> It's always good idea to start explore something new with fresh and pristine codebase to make sure that exploration subject does not interferes with your existing codebase.
+
+I
+Install web3-onboard core and react packages.
```bash
-yarn add @web3-onboard/core @web3-onboard/injected-wallets ethers
+yarn add @web3-onboard/core @web3-onboard/react
+```
+
+> We'll be using `@web3-onboard/react` which provides some fancy react hooks on top of core package,
+
+Install wallet providers
+
+```bash
+yarn add @web3-onboard/xdefi @web3-onboard/injected-wallets @web3-onboard/walletconnect
+```
+
+> We'll be using `@web3-onboard/xdefi` package and packages for fallback wallets: `@web3-onboard/walletconnect` and `@web3-onboard/injected-wallets`
+
+### Setting up Web3Onboard provider
+
+First, we need to configure our Web3Onboard.
+Let's make Web3Onboard configuration function and complete it step by step
+
+```javascript
+import { init } from "@web3-onboard/react";
+
+export function configureWeb3Onboard() {
+ const web3Onboard = init({
+ wallets: [],
+ chains: [],
+ theme: "dark",
+ appMetadata: {
+ name: "My App",
+ description: "My App with Web3Onboard",
+ recommendedInjectedWallets: [{ name: "XDEFI", url: "https://xdefi.io" }],
+ },
+ });
+
+ return web3Onboard;
+}
+```
+
+Now we have our configuration function, but it does not do much yet.
+Let's provide some wallets
+
+```javascript
+import { init } from "@web3-onboard/react";
+import xdefiWalletModule from "@web3-onboard/xdefi"; // [!code ++]
+import walletConnectModule from "@web3-onboard/walletconnect"; // [!code ++]
+import injectedModule from "@web3-onboard/injected-wallets"; // [!code ++]
+
+export function configureWeb3Onboard() {
+
+ const wallets =
+ const web3Onboard = init({
+ wallets:[
+ xdefiWalletModule(), // [!code ++]
+ walletConnectModule({ projectId: "YOUR_PROJECT_ID" }), // [!code ++]
+ injectedModule(), // [!code ++]
+ ];
+ chains: [],
+ theme: "dark",
+ appMetadata: {
+ name: "My App",
+ description: "My App with Web3Onboard",
+ recommendedInjectedWallets: [{ name: "XDEFI", url: "https://xdefi.io" }],
+ },
+ });
+
+ return web3Onboard;
+}
+```
+
+and add supported chains
+
+```javascript
+export function configureWeb3Onboard(chains = defaultChainsList) {
+ const wallets = [
+ xdefiWalletModule(),
+ walletConnectModule({ projectId: "YOUR_PROJECT_ID" }),
+ injectedModule(),
+ ];
+ const web3Onboard = init({
+ wallets,
+ chains: export function configureWeb3Onboard() {
+ const web3Onboard = init({
+ wallets: [
+ xdefiWalletModule(),
+ walletConnectModule({ projectId: "YOUR_PROJECT_ID" }),
+ injectedModule(),
+ ],
+ chains: [// [!code ++]
+ {// [!code ++]
+ id: "0x1", // [!code ++]
+ token: "ETH", // [!code ++]
+ label: "Ethereum", // [!code ++]
+ rpcUrl: "https://ethereum-rpc.publicnode.com",// [!code ++]
+ },// [!code ++]
+ {// [!code ++]
+ id: "0x2105", // [!code ++]
+ token: "ETH", // [!code ++]
+ label: "Base",// [!code ++]
+ rpcUrl: "https://mainnet.base.org", // [!code ++]
+ },// [!code ++]
+ {// [!code ++]
+ id: "0x89",// [!code ++]
+ token: "MATIC",// [!code ++]
+ label: "Polygon",// [!code ++]
+ rpcUrl: "https://matic-mainnet.chainstacklabs.com",// [!code ++]
+ },// [!code ++]
+ ],// [!code ++]
+ theme: "dark",
+ appMetadata: {
+ name: "My App",
+ description: "My App with Web3Onboard",
+ recommendedInjectedWallets: [{ name: "XDEFI", url: "https://xdefi.io" }],
+ },
+ });
+
+ return web3Onboard;
+},
+ theme: "dark",
+ appMetadata: {
+ name: "My App",
+ description: "My App with Web3Onboard",
+ recommendedInjectedWallets: [{ name: "XDEFI", url: "https://xdefi.io" }],
+ },
+ });
+
+ return web3Onboard;
+}
+```
+
+Now, we're ready to set up Web3OnboardProvider. Open your React app enty file and wrap your app with Web3OnboardProvider like on sample below
+
+```javascript
+import React from "react";
+import ReactDOM from "react-dom/client";
+import "./index.css";
+import App from "./App";
+import { Web3OnboardProvider } from "@web3-onboard/react";
+import { configureWeb3Onboard } from "./configureWeb3Onboard";
+
+const root = ReactDOM.createRoot(
+ document.getElementById("root") as HTMLElement
+);
+
+root.render(
+