getSignaturesForAddress – Solana
The getSignaturesForAddress JSON-RPC method retrieves signatures for confirmed transactions that involve a given account address in their accountKeys list.
Last updated
Was this helpful?
Was this helpful?
https://go.getblock.io/<ACCESS-TOKEN>/curl --location "https://go.getblock.io/<ACCESS-TOKEN>/" -XPOST \
--header "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "getSignaturesForAddress",
"params": [
"Vote111111111111111111111111111111111111111",
{
"limit": 1
}
]
}'{
"jsonrpc": "2.0",
"result": [
{
"err": null,
"memo": null,
"signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv",
"slot": 114,
"blockTime": null
}
],
"id": 1
}{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid account address format"
},
"id": 1
}const axios = require('axios');
const url = "https://go.getblock.io/<ACCESS-TOKEN>/";
const headers = { "Content-Type": "application/json" };
const payload = {
jsonrpc: "2.0",
id: 1,
method: "getSignaturesForAddress",
params: [
"Vote111111111111111111111111111111111111111",
{ limit: 1 }
]
};
const fetchSignaturesForAddress = async () => {
try {
const response = await axios.post(url, payload, { headers });
if (response.status === 200 && Array.isArray(response.data.result)) {
const signatures = response.data.result;
if (signatures.length > 0) {
signatures.forEach((signature, index) => {
console.log(`Signature ${index + 1}:`);
console.log(` Signature: ${signature.signature}`);
console.log(` Slot: ${signature.slot}`);
console.log(` Block Time: ${signature.blockTime ? new Date(signature.blockTime * 1000) : "N/A"}`);
console.log(` Err: ${signature.err ? JSON.stringify(signature.err) : "No error"}`);
});
} else {
console.log("No signatures found for the specified address.");
}
} else {
console.error("Unexpected response:", response.data);
}
} catch (error) {
console.error("getSignaturesForAddress error:", error.response?.data || error.message);
}
};
fetchSignaturesForAddress();