Request EVM challenge
curl --request POST \
--url https://authapi.moralis.io/challenge/request/evm \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"domain": "defi.finance",
"uri": "https://defi.finance/",
"timeout": 15,
"chainId": 1,
"address": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
"statement": "Please confirm",
"expirationTime": "2020-01-01T00:00:00.000Z",
"notBefore": "2020-01-01T00:00:00.000Z",
"resources": [
"https://docs.moralis.io/"
]
}
'import requests
url = "https://authapi.moralis.io/challenge/request/evm"
payload = {
"domain": "defi.finance",
"uri": "https://defi.finance/",
"timeout": 15,
"chainId": 1,
"address": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
"statement": "Please confirm",
"expirationTime": "2020-01-01T00:00:00.000Z",
"notBefore": "2020-01-01T00:00:00.000Z",
"resources": ["https://docs.moralis.io/"]
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
domain: 'defi.finance',
uri: 'https://defi.finance/',
timeout: 15,
chainId: 1,
address: '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
statement: 'Please confirm',
expirationTime: '2020-01-01T00:00:00.000Z',
notBefore: '2020-01-01T00:00:00.000Z',
resources: ['https://docs.moralis.io/']
})
};
fetch('https://authapi.moralis.io/challenge/request/evm', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://authapi.moralis.io/challenge/request/evm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'domain' => 'defi.finance',
'uri' => 'https://defi.finance/',
'timeout' => 15,
'chainId' => 1,
'address' => '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
'statement' => 'Please confirm',
'expirationTime' => '2020-01-01T00:00:00.000Z',
'notBefore' => '2020-01-01T00:00:00.000Z',
'resources' => [
'https://docs.moralis.io/'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://authapi.moralis.io/challenge/request/evm"
payload := strings.NewReader("{\n \"domain\": \"defi.finance\",\n \"uri\": \"https://defi.finance/\",\n \"timeout\": 15,\n \"chainId\": 1,\n \"address\": \"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\",\n \"statement\": \"Please confirm\",\n \"expirationTime\": \"2020-01-01T00:00:00.000Z\",\n \"notBefore\": \"2020-01-01T00:00:00.000Z\",\n \"resources\": [\n \"https://docs.moralis.io/\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://authapi.moralis.io/challenge/request/evm")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"domain\": \"defi.finance\",\n \"uri\": \"https://defi.finance/\",\n \"timeout\": 15,\n \"chainId\": 1,\n \"address\": \"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\",\n \"statement\": \"Please confirm\",\n \"expirationTime\": \"2020-01-01T00:00:00.000Z\",\n \"notBefore\": \"2020-01-01T00:00:00.000Z\",\n \"resources\": [\n \"https://docs.moralis.io/\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://authapi.moralis.io/challenge/request/evm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"domain\": \"defi.finance\",\n \"uri\": \"https://defi.finance/\",\n \"timeout\": 15,\n \"chainId\": 1,\n \"address\": \"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\",\n \"statement\": \"Please confirm\",\n \"expirationTime\": \"2020-01-01T00:00:00.000Z\",\n \"notBefore\": \"2020-01-01T00:00:00.000Z\",\n \"resources\": [\n \"https://docs.moralis.io/\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "fRyt67D3eRss3RrXa",
"profileId": "0xbfbcfab169c67072ff418133124480fea02175f1402aaa497daa4fd09026b0e1",
"message": "defi.finance wants you to sign in with your Ethereum account:\n0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\n\nPlease confirm\n\nURI: https://defi.finance/\nVersion: 1\nChain ID: 1\nNonce: DbU1DCTmdzR4lg3wi\nIssued At: 2022-06-12T12:15:31.290Z\nExpiration Time: 2020-01-01T00:00:00.000Z\nNot Before: 2020-01-01T00:00:00.000Z\nResources:\n- https://docs.moralis.io/"
}Challenge
Request EVM challenge
POST
/
challenge
/
request
/
evm
Request EVM challenge
curl --request POST \
--url https://authapi.moralis.io/challenge/request/evm \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"domain": "defi.finance",
"uri": "https://defi.finance/",
"timeout": 15,
"chainId": 1,
"address": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
"statement": "Please confirm",
"expirationTime": "2020-01-01T00:00:00.000Z",
"notBefore": "2020-01-01T00:00:00.000Z",
"resources": [
"https://docs.moralis.io/"
]
}
'import requests
url = "https://authapi.moralis.io/challenge/request/evm"
payload = {
"domain": "defi.finance",
"uri": "https://defi.finance/",
"timeout": 15,
"chainId": 1,
"address": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
"statement": "Please confirm",
"expirationTime": "2020-01-01T00:00:00.000Z",
"notBefore": "2020-01-01T00:00:00.000Z",
"resources": ["https://docs.moralis.io/"]
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
domain: 'defi.finance',
uri: 'https://defi.finance/',
timeout: 15,
chainId: 1,
address: '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
statement: 'Please confirm',
expirationTime: '2020-01-01T00:00:00.000Z',
notBefore: '2020-01-01T00:00:00.000Z',
resources: ['https://docs.moralis.io/']
})
};
fetch('https://authapi.moralis.io/challenge/request/evm', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://authapi.moralis.io/challenge/request/evm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'domain' => 'defi.finance',
'uri' => 'https://defi.finance/',
'timeout' => 15,
'chainId' => 1,
'address' => '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
'statement' => 'Please confirm',
'expirationTime' => '2020-01-01T00:00:00.000Z',
'notBefore' => '2020-01-01T00:00:00.000Z',
'resources' => [
'https://docs.moralis.io/'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://authapi.moralis.io/challenge/request/evm"
payload := strings.NewReader("{\n \"domain\": \"defi.finance\",\n \"uri\": \"https://defi.finance/\",\n \"timeout\": 15,\n \"chainId\": 1,\n \"address\": \"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\",\n \"statement\": \"Please confirm\",\n \"expirationTime\": \"2020-01-01T00:00:00.000Z\",\n \"notBefore\": \"2020-01-01T00:00:00.000Z\",\n \"resources\": [\n \"https://docs.moralis.io/\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://authapi.moralis.io/challenge/request/evm")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"domain\": \"defi.finance\",\n \"uri\": \"https://defi.finance/\",\n \"timeout\": 15,\n \"chainId\": 1,\n \"address\": \"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\",\n \"statement\": \"Please confirm\",\n \"expirationTime\": \"2020-01-01T00:00:00.000Z\",\n \"notBefore\": \"2020-01-01T00:00:00.000Z\",\n \"resources\": [\n \"https://docs.moralis.io/\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://authapi.moralis.io/challenge/request/evm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"domain\": \"defi.finance\",\n \"uri\": \"https://defi.finance/\",\n \"timeout\": 15,\n \"chainId\": 1,\n \"address\": \"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\",\n \"statement\": \"Please confirm\",\n \"expirationTime\": \"2020-01-01T00:00:00.000Z\",\n \"notBefore\": \"2020-01-01T00:00:00.000Z\",\n \"resources\": [\n \"https://docs.moralis.io/\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "fRyt67D3eRss3RrXa",
"profileId": "0xbfbcfab169c67072ff418133124480fea02175f1402aaa497daa4fd09026b0e1",
"message": "defi.finance wants you to sign in with your Ethereum account:\n0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\n\nPlease confirm\n\nURI: https://defi.finance/\nVersion: 1\nChain ID: 1\nNonce: DbU1DCTmdzR4lg3wi\nIssued At: 2022-06-12T12:15:31.290Z\nExpiration Time: 2020-01-01T00:00:00.000Z\nNot Before: 2020-01-01T00:00:00.000Z\nResources:\n- https://docs.moralis.io/"
}Body
application/json
Request EVM challenge message.
Response
201 - application/json
The back channel challenge containing the id to store on the api and the message to be signed by the user
Message that needs to be signed by the end user
Example:
"defi.finance wants you to sign in with your Ethereum account:\n0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\n\nPlease confirm\n\nURI: https://defi.finance/\nVersion: 1\nChain ID: 1\nNonce: DbU1DCTmdzR4lg3wi\nIssued At: 2022-06-12T12:15:31.290Z\nExpiration Time: 2020-01-01T00:00:00.000Z\nNot Before: 2020-01-01T00:00:00.000Z\nResources:\n- https://docs.moralis.io/"

