1

Generate a challenge

First, you need to use our /key/challenge endpoint to generate a challenge.

You will pass your user ‘s Ethereum address to this endpoint. The response will contain a field challenge that you need for the next step.

curl --request POST \
  --url https://api.openformat.tech/key/challenge \
  --header 'Content-Type: application/json' \
  --data '{
  "public_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
}'
2

Sign the challenge

Next, you need to sign the challenge with the user ‘s private key. You can use our Metamask with our signing tool or the following scripts:

import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount("YOUR_PRIVATE_KEY");

// Challenge returned from /key/challenge endpoint
const challenge = "7877fa9f42dd92bebfefa7d6469e774327afddf76718e93288182949af7d3ade";

const signed = await account.signMessage({ message: challenge });

console.log(signed);
// 0x9fe5ad28c81419f5135aec3c....

3

Respond the challenge and get the API key

Send the result of previous step to the /key/verify endpoint and recieve the API key in the response. You need to send the signature and your user ‘s Ethereum address as field public_address.

curl --request POST \
  --url https://api.openformat.tech/key/verify \
  --header 'Content-Type: application/json' \
  --data '{
  "signature": "0x860729b.....",
  "public_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
}'

Save this API key in appropiate place with sufficient security.