Skip to main content

Authentication

ETHGas uses JWT Bearer token authentication. See Connect for the full login flow.

POST /v1/user/login

Get the EIP712 message for signing. Log in with your credentials.

curl -X POST "$ETHGAS_API_URL/v1/user/login?addr=0x8F02425B5f3c522b7EF8EA124162645F0397c478&name=username"

Request

ParameterRequiredTypeDescription
addrYESstringUser's EOA account address
nameNOstringDisplay name

Response Body

NameTypeDescription
statusstringLogin status
eip712MessageobjectEIP712 message to sign
nonceHashstringUnique four-byte nonce for this login request

Example Response

{
"success": true,
"data": {
"status": "verify",
"eip712Message": "{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"}...],\"primaryType\":\"data\",\"message\":{\"hash\":\"52a90c73\",\"message\":\"Please sign this message to verify account ownership\",\"domain\":\"ethgas.com\"},\"domain\":{\"name\":\"ETHGas Login\",\"version\":\"1\",\"chainId\":32382,\"verifyingContract\":\"0x0000000000000000000000000000000000000000\"}}",
"nonceHash": "52a90c73"
}
}

Usage

Get the response from /v1/user/login, sign the eip712Message, and send the signed message to /v1/user/login/verify.


POST /v1/user/login/verify

Verify login by submitting the signed EIP712 message.

curl -X POST "$ETHGAS_API_URL/v1/user/login/verify?addr=0xe61f536f031f77C854b21652aB0F4fBe7CF3196F&nonceHash=517d9272&signature=0xc046037e..."

Request

ParameterRequiredTypeDescription
addrYESstringUser's EOA account address
nonceHashYESstringNonce hash from login endpoint
signatureYESstringSigned EIP712 message signature

Response Body

NameTypeDescription
userobjectUser details
accessTokenobjectJWT access token with token field

Example Response

{
"success": true,
"data": {
"user": {
"userId": 78,
"address": "0xe61f536f031f77c854b21652ab0f4fbe7cf3196f",
"status": 1,
"userType": 1,
"userClass": 1,
"accounts": [
{
"accountId": 242,
"userId": 78,
"type": 1,
"name": "Current",
"status": 1,
"updateDate": 1698127521000
},
{
"accountId": 243,
"userId": 78,
"type": 2,
"name": "Preconf",
"status": 1,
"updateDate": 1698127521000
}
]
},
"accessToken": {
"token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
}

POST /v1/user/login/refresh

Get a new access token using a non-expired refresh token.

curl -X POST "$ETHGAS_API_URL/v1/user/login/refresh" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{access_token}}" \
-d '{"refreshToken": "your_refresh_token"}'

Request

ParameterRequiredTypeDescription
refreshTokenYESstringRefresh token

Response Body

NameTypeDescription
userobjectUser details
accessTokenobjectNew access token

POST /v1/user/logout

Log out the current session.

curl -H "Authorization: Bearer {{access_token}}" -X POST "$ETHGAS_API_URL/v1/user/logout"

Request

No parameters for this endpoint.

Response Body

No response data for this endpoint.