Auth
Last updated
Last updated
To request the token, network, and other interface data for deposit and withdrawal services, you need to mount the authorization token to the HTTP request header.
For the configuration items used in the following examples, please refer to:
Normally, you only need one ETransferCore
instance initialized.
If you want to get a new token without any additional business logic.
First, init the ETransferCore instance. You can find it in ETransfer SDK Quick Start.
After getting the token, mount it to the request header and set it to storage.
Example
Method Parameters
pubkey
string
true
user account pubkey
plain_text
string
true
signed text
The signature text can be customized, but it must end with a timestamp. For example: Nonce:<current timestamp>
signature
string
true
user signature
version
PortkeyVersion
true
Portkey version: 'v1' | 'v2
'. Recommend using v2
source
AuthTokenSource
true
Wallet type: 'portkey' | 'nightElf'
ca_hash
string
false
user ca hash
If source='portkey'
, you must set this parameter.
chain_id
ChainId
false
'AELF' | 'tDVV'
If source='portkey'
, you must set this parameter.
managerAddress
string
false
user manager address.
recaptchaToken
string
false
Recaptcha result.
If source='portkey'
, you do not need to set this parameter.
If source='nightElf'
, you need to query the interface etransferCore.services.checkEOARegistration
first. If it returns true, you do not need to set this parameter; if it returns false, set the obtained verification result through human-machine verification.
You can directly call the etransferCore.getReCaptcha
method to help you quickly implement the above logic.
Method return value
token
string
The authorization token.
Get data from the cache first. If the data in the storage has expired, it will get a new token from the interface.After getting the token, mount it to the request header and set it to storage.
Example
Method Parameters
pubkey
string
true
user account pubkey
plainText
string
true
signed text
The signature text can be customized, but it must end with a timestamp. For example: Nonce:<current timestamp>
signature
string
true
user signature
version
PortkeyVersion
true
Portkey version: 'v1' | 'v2'
. Recommend using v2
managerAddress
string
true
user manager address
caHash
string
true
user ca hash
If source='portkey'
, you must set this parameter.
chainId
ChainId
true
'AELF' | 'tDVV'
If source='portkey'
, you must set this parameter.
source
AuthTokenSource
false
Wallet type: 'portkey' | 'nightElf'
Default is 'portkey'
recaptchaToken
string
false
Recaptcha result.
If source='portkey'
, you do not need to set this parameter.
If source='nightElf'
, you need to query the interface etransferCore.services.checkEOARegistration
first. If it returns true, you do not need to set this parameter; if it returns false, set the obtained verification result through human-machine verification.
You can directly call the etransferCore.getReCaptcha
method to help you quickly implement the above logic.
Method return value
token
string
The authorization token.
The premise is that authorization token has been obtained from the interface before.
If the authorization token is expired, return undefined
.
Example
Method Parameters
walletType
TWalletType
true
'portkey' | 'nightElf'
managerAddress
string
true
user manager address
caHash
string
false
user ca hash.
If walletType='portkey'
, you should set user's caHash.
If walletType='nightElf'
, you can not set this parameter, and storage key = 'nightElf'+managerAddress
Method return value
token
string | undefined
The authorization token.
Get a new token without any additional business logic.
Example
Method Parameters
pubkey
string
true
user account pubkey
plain_text
string
true
signed text.
The signature text can be customized, but it must end with a timestamp. For example: Nonce:<current timestamp>
signature
string
true
user signature
version
PortkeyVersion
true
Portkey version: 'v1' | 'v2
'. Recommend using v2
managerAddress
string
true
user manager address
source
AuthTokenSource
true
Wallet type: 'portkey' | 'nightElf'
ca_hash
string
false
user ca hash.
If source='portkey'
, you must set this parameter.
chain_id
ChainId
false
'AELF' | 'tDVV'.
If source='portkey'
, you must set this parameter.
recaptchaToken
string
false
Recaptcha result.
If source='portkey'
, you do not need to set this parameter.
If source='nightElf'
, you need to query the interface etransferCore.services.checkEOARegistration
first. If it returns true, you do not need to set this parameter; if it returns false, set the obtained verification result through human-machine verification.
You can directly call the etransferCore.getReCaptcha
method to help you quickly implement the above logic
Method return value
token_type
string
The return token type, such as Bearer
.
access_token
string
The return token body.
expires_in
number
Token expiration time, unit is seconds.