Sign a Message
FSCO provides a secure way to sign messages using your wallet’s private key. This is useful for proving ownership of a wallet or signing off-chain messages.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- A valid FSCO API key
- Your application’s environment configured with the API key
- A wallet ID for the wallet you want to use for signing
- The message data in hex format
Endpoint
Section titled “Endpoint”POST /v2/wallet/{walletId}/sign/msg
Request Parameters
Section titled “Request Parameters”{ "walletId": "8c1d496f-2827-4750-a11f-74b48c11108d", "data": "0xdeadbeef"}
The request requires:
walletId
: The unique ID of the wallet to use for signingdata
: The message to sign in hex format (must start with ‘0x’)
Example Request
Section titled “Example Request”curl -X POST "https://api.fsco.io/v2/wallet/8c1d496f-2827-4750-a11f-74b48c11108d/sign/msg" \ -H "Authorization: Bearer $FSCO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "walletId": "8c1d496f-2827-4750-a11f-74b48c11108d", "data": "0xdeadbeef" }'
import axios from 'axios';
const FSCO_API_KEY = process.env.FSCO_API_KEY;const FSCO_API_SECRET = process.env.FSCO_API_SECRET;const walletId = '8c1d496f-2827-4750-a11f-74b48c11108d';
const signMessage = async () => { const response = await axios.post( `https://api.fsco.io/v2/wallet/${walletId}/sign/msg`, { walletId, data: '0xdeadbeef', }, { headers: { 'x-api-key': FSCO_API_KEY, 'x-api-secret': FSCO_API_SECRET, 'Content-Type': 'application/json', }, } );
console.log('Signed Message:', response.data);};
signMessage();
import requestsimport os
FSCO_API_KEY = os.environ.get("FSCO_API_KEY")FSCO_API_SECRET = os.environ.get("FSCO_API_SECRET")wallet_id = "8c1d496f-2827-4750-a11f-74b48c11108d"
def sign_message(): response = requests.post( f"https://api.fsco.io/v2/wallet/{wallet_id}/sign/msg", json={"walletId": wallet_id, "data": "0xdeadbeef"}, headers={ "x-api-key": FSCO_API_KEY, "x-api-secret": FSCO_API_SECRET, "Content-Type": "application/json", }, )
print("Signed Message:", response.json())
sign_message()
using System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;using System.Text.Json;using System.Threading.Tasks;
class MessageSigner{ static async Task Main() { var apiKey = Environment.GetEnvironmentVariable("FSCO_API_KEY"); var client = new HttpClient(); var walletId = "8c1d496f-2827-4750-a11f-74b48c11108d";
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); client.DefaultRequestHeaders.Add("Content-Type", "application/json");
var requestBody = JsonSerializer.Serialize(new { walletId = walletId, data = "0xdeadbeef" }); var content = new StringContent(requestBody, Encoding.UTF8, "application/json");
var response = await client.PostAsync($"https://api.fsco.io/v2/wallet/{walletId}/sign/msg", content); var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine("Signed Message: " + responseString); }}
Response
Section titled “Response”{ "walletId": "8c1d496f-2827-4750-a11f-74b48c11108d", "signedData": "0x4a882e6a0d41b0832a1d3c38d1c2d8a3a4a34a5e6f7c8d9e0f1a2b3c4d5e6f7"}
Important Notes
Section titled “Important Notes”- The message must be in hex format and start with ‘0x’
- The wallet must exist and be active
- The signed message can be used for verification on-chain or off-chain
- The signature follows the standard Ethereum message signing format
- The walletId in the path must match the walletId in the request body