Getting Started
Get started using Bitcoin Schema in your applications
This guide will help you get started with implementing Bitcoin Schema in your applications.
Examples
JavaScript
First, we'll demonstrate creating a new transaction containing some data according to a Bitcoin Schema. For this example, we will create a new "like". Likes refer to an existing transaction by its transaction ID.
Here, we use RelayOne Javascript API to create the transaction. This is very similar to creating the tx using MoneyButton, and is simplified for demonstration purposes.
// Initialize payload object
let payload = {
outputs: []
}
// Create data payload for Like Schema
const dataPayload = [
'1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5', // MAP Prefix
'SET',
'app',
appName,
'type',
'like',
'tx',
<liking_txid>
];
// Create a script from the data payload
const s = Script.fromSafeDataArray(
dataPayload.map((d) => {
return Buffer.from(d);
})
);
// Add the script to our outputs
payload.outputs = [
{
script: s.toAsmString(),
},
];
// Add tip / change outputs
let toOuts = [
{ to: <tipAddress>, amount: <tipAmount>, currency: <currency> },
{ to: <changeAddress>, amount: <changeAmount>, currency: <currency>}
];
// Combine the outputs
payload.outputs = [...payload.outputs.concat(toOuts)];
// Broadcast the transaction
let response = await relayOne.send(payload);
Real Transaction Example
Here's a real MAP protocol transaction that was broadcast to the Bitcoin SV blockchain:
Transaction ID: cdfe7ae5c91afe4dc3a5db383e0ca948ec3d51dc2954a9d18ca464db7c9d5d3d
This transaction uses the MAP protocol to set paymail verification data:
1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5 // MAP Protocol Prefix
SET // MAP Command
app // Key
2paymail // Value
paymail // Key
hagbard@moneybutton.com // Value
public_key // Key
02c89b6790eb605062a31f124250594bd0fd02988da2541b3d25e7ef3937fb4ae0 // Value
You can view this transaction on any BSV block explorer or query it using BMAP APIs.
Getting Help
Join the 1sat Discord for support and discussions about Bitcoin Schema development.
Next Steps
Now that you have a basic understanding of how to implement Bitcoin Schema, explore the different schema types:
- Generic Schemas - General-purpose schemas
- Social Schemas - Social networking schemas