Push Data Endpoint
Learn how to push data to your Droplit instance.
Push Data Endpoint
This endpoint allows you to associate arbitrary data with your droplit instance. The data is pushed onto the Bitcoin blockchain within an OP_RETURN output.
- Endpoint:
POST /faucet/{droplitName}/push- Replace
{droplitName}with the name of your Droplit.
- Replace
- Authentication: Required (see Authentication)
Request Body
The request body must be a JSON object with the following structure:
{
"data": ["string1", "string2", ...],
"encoding": "utf8" // or "hex"
}data: An array of strings. Each string will be a separateOP_RETURNpush.encoding: Specifies how the strings in thedataarray are encoded."utf8": The strings are UTF-8 encoded."hex": The strings are hex-encoded binary data.
Example: JavaScript with BRC-103/104
import { AuthFetch, PrivateKey, ProtoWallet } from "@bsv/sdk";
async function pushDataToDroplit() {
const droplitName = "your-droplit-name";
const wallet = new ProtoWallet(
PrivateKey.fromWif(process.env.DROPLIT_SIGNER_WIF),
);
const client = new AuthFetch(wallet);
const response = await client.fetch(
`${process.env.DROPLIT_API_URL}/faucet/${droplitName}/push`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: ["Droplit is awesome!", new Date().toISOString()],
encoding: "utf8",
}),
},
);
if (!response.ok) throw new Error(await response.text());
console.log("Push data successful:", await response.json());
}
await pushDataToDroplit();For Sigma-hosted app flows, use Sigma signing directly and avoid storing WIFs in your application.
Success Response
On success, the API returns a JSON object containing the transaction ID (txid) of the Bitcoin transaction that includes your data, and an array of vouts indicating the output indices of your data pushes.
{
"txid": "abcdef123456...",
"vouts": [1, 2]
}Error Responses
Common errors include:
400 Bad Request: Invalid request body or parameters.401 Unauthorized: BRC-103/104 authentication failed.500 Internal Server Error: Server-side issue.
The error response body will typically contain a JSON object with an error or message field.