Skip to content

Commit 64c30d8

Browse files
authored
Merge pull request #2 from b-open-io/master
initial templates
2 parents 266d819 + d3d47c4 commit 64c30d8

File tree

87 files changed

+10518
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+10518
-25
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
playground-1.mongodb.js
2+
3+
coverage.out
4+
coverage.html
5+
todo.txt

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,55 @@ A collection of script templates for use with the official BSV Golang SDK
88

99
The goal of this repository is to provide a place where developers from around the ecosystem can publish all manner of script templates, without needing to update the core library. We're generally neutral and unbiased about what people contribute, so feel free to contribute and see what people do with your cool idea!
1010

11-
## Using
11+
## Available Templates
1212

13-
You can write code like this:
13+
| Template | Description |
14+
|----------|-------------|
15+
| [BitCom](./template/bitcom/) | BitCom protocol utilities (B, MAP, AIP) for structured data |
16+
| [BSocial](./template/bsocial/) | Social media actions using BitcoinSchema.org standards |
17+
| [BSV20](./template/bsv20/) | BSV20 token standard implementation |
18+
| [BSV21](./template/bsv21/) | BSV21 token standard implementation including LTM and POW20 |
19+
| [Cosign](./template/cosign/) | Co-signing transactions with multiple parties |
20+
| [Inscription](./template/inscription/) | On-chain NFT-like inscriptions |
21+
| [Lockup](./template/lockup/) | Time-locked transactions |
22+
| [OrdLock](./template/ordlock/) | Locking and unlocking functionality for ordinals |
23+
| [OrdP2PKH](./template/ordp2pkh/) | Ordinal-aware P2PKH transactions |
24+
| [P2PKH](./template/p2pkh/) | Standard Pay-to-Public-Key-Hash transactions |
25+
| [Shrug](./template/shrug/) | Experimental template for demo purposes |
1426

15-
```ts
16-
...soon
17-
```
27+
Each template folder contains its own README with detailed usage examples.
1828

19-
## Current Templates
2029

21-
Name | Description
22-
--------------------------------|--------------------------
23-
[Example](./src/example.ts) | Do a thing
30+
## Installation
2431

25-
## Contribution Guidelines
32+
```bash
33+
go get github.com/bitcoin-sv/go-templates
34+
```
2635

27-
We're always looking for contributors to add the coolest new templates. Whatever kinds of scripts you come up with - all contributions are welcome.
36+
## Basic Usage
2837

29-
1. **Fork & Clone**: Fork this repository and clone it to your local machine.
30-
2. **Set Up**: Run `go install github.com/bitcoin-sv/go-templates` to install all dependencies.
31-
3. **Make Changes**: Create a new branch and make your changes.
32-
4. **Test**: Ensure all tests pass by running `go test`.
33-
5. **Commit**: Commit your changes and push to your fork.
34-
6. **Pull Request**: Open a pull request from your fork to this repository.
35-
For more details, check the [contribution guidelines](./CONTRIBUTING.md).
38+
Import the specific template you need:
3639

37-
For information on past releases, check out the [changelog](./CHANGELOG.md). For future plans, check the [roadmap](./ROADMAP.md)!
40+
```go
41+
import "github.com/bitcoin-sv/go-templates/template/bsocial"
42+
```
3843

39-
## Support & Contacts
44+
See each template's README for detailed examples.
4045

41-
Project Owners: Luke Rohenaz
46+
## Contributing
4247

43-
Development Team Lead: Luke Rohenaz
48+
We welcome contributions of all kinds:
4449

45-
For questions, bug reports, or feature requests, please open an issue on GitHub or contact us directly.
50+
1. **Fork & Clone**: Fork this repository and clone it locally
51+
2. **Make Changes**: Add or improve templates
52+
3. **Test**: Ensure all tests pass with `go test`
53+
4. **Document**: Add clear documentation with examples in the template's README
54+
5. **Pull Request**: Submit your changes for review
4655

4756
## License
4857

49-
The license for the code in this repository is the Open BSV License. Refer to [LICENSE.txt](./LICENSE.txt) for the license text.
58+
Open BSV License - See [LICENSE.txt](./LICENSE.txt)
59+
60+
## Support
5061

51-
Thank you for being a part of the BSV Blockchain Script Templates Project. Let's build the future of BSV Blockchain together!
62+
For questions or issues, please open a GitHub issue or contact the project maintainers.

docs/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# BSV Script Templates Documentation
2+
3+
Welcome to the documentation for the BSV Script Templates repository. This documentation provides detailed information about the various Bitcoin SV script templates available in this repository.
4+
5+
## Structure
6+
7+
- Templates `./templates/*/README.md` - Documentation for individual script templates
8+
- [Contributing](../CONTRIBUTING.md) - Guide for contributors
9+
10+
## Getting Started
11+
12+
### Installation
13+
14+
```bash
15+
go get github.com/bitcoin-sv/go-templates
16+
```
17+
18+
### Basic Usage
19+
20+
1. Import the specific template you need:
21+
```go
22+
import "github.com/bitcoin-sv/go-templates/template/bsocial"
23+
```
24+
25+
2. Use the template functions to create or decode transactions:
26+
```go
27+
// See individual template documentation for specific usage examples
28+
```
29+
30+
## Available Templates
31+
32+
The repository includes templates for various use cases:
33+
34+
- **[BitCom](./templates/bitcom/README.md)** - BitCom protocol utilities (B, MAP, AIP)
35+
- **[BSocial](./templates/bsocial/README.md)** - Social media actions using BitcoinSchema.org standards
36+
- **[BSV20](./templates/bsv20/README.md)** - BSV20 token standard implementation
37+
- **[BSV21](./templates/bsv21/README.md)** - BSV21 token standard implementation including LTM and POW20
38+
- **[Cosign](./templates/cosign/README.md)** - Co-signing transactions with multiple parties
39+
- **[Inscription](./templates/inscription/README.md)** - On-chain NFT-like inscriptions
40+
- **[Lockup](./templates/lockup/README.md)** - Time-locked transactions
41+
- **[OrdLock](./templates/ordlock/README.md)** - Locking and unlocking functionality for ordinals
42+
- **[OrdP2PKH](./templates/ordp2pkh/README.md)** - Ordinal-aware P2PKH transactions
43+
- **[P2PKH](./templates/p2pkh/README.md)** - Standard Pay-to-Public-Key-Hash transactions
44+
- **[Shrug](./templates/shrug/README.md)** - Experimental template for demo purposes
45+
46+
## Support
47+
48+
If you encounter issues or have questions, please:
49+
50+
1. Check the documentation for the specific template
51+
2. Search existing GitHub issues
52+
3. Open a new issue if needed
53+
54+
## License
55+
56+
The code in this repository is licensed under the Open BSV License. See [LICENSE.txt](../LICENSE.txt) for details.

docs/templates/SIGMA.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Sigma Protocol Template
2+
3+
This package implements a Go version of the Sigma digital signature protocol for Bitcoin SV. Sigma is a signature scheme for signing Bitcoin transaction data, which can be used to prove ownership or authenticity of data stored on the blockchain.
4+
5+
## Overview
6+
7+
The Sigma protocol allows for:
8+
- Creating digital signatures with various algorithms
9+
- Multiple signature formats (string, binary, hex)
10+
- Optional message and nonce fields
11+
- Verification of signatures
12+
13+
## Usage
14+
15+
### Decoding Sigma Signatures from Scripts
16+
17+
```go
18+
import (
19+
"github.com/bitcoin-sv/go-templates/template/bitcom"
20+
"github.com/bitcoin-sv/go-templates/template/sigma"
21+
)
22+
23+
// Decode the transaction script
24+
b := bitcom.DecodeTx(tx)
25+
26+
// Extract Sigma signatures
27+
signatures := sigma.Decode(b)
28+
29+
// Process signatures
30+
for _, sig := range signatures {
31+
// Get the signature bytes based on the signature type
32+
sigBytes, err := sig.GetSignatureBytes()
33+
if err != nil {
34+
// Handle error
35+
}
36+
37+
// Use the signature bytes for verification or other purposes
38+
// ...
39+
}
40+
```
41+
42+
## Protocol Details
43+
44+
The Sigma protocol uses the following format in scripts:
45+
46+
```
47+
OP_RETURN
48+
1signaturezzYYzQ2H2st5SvdT9KwGe # Sigma protocol prefix
49+
<algorithm> # e.g., "ECDSA", "SHA256-ECDSA"
50+
<signer_address> # Bitcoin address of the signer
51+
<signature_value> # The actual signature
52+
[<signature_type>] # Optional: "string", "binary", or "hex"
53+
[<message>] # Optional: the message that was signed
54+
[<nonce>] # Optional: random nonce used for signing
55+
```
56+
57+
### Required Fields
58+
59+
- **Algorithm**: The signature algorithm used (e.g., "ECDSA", "SHA256-ECDSA")
60+
- **Signer Address**: The Bitcoin address of the signer
61+
- **Signature Value**: The signature itself
62+
63+
### Optional Fields
64+
65+
- **Signature Type**: The format of the signature ("string", "binary", "hex")
66+
- Defaults to "string" if not specified
67+
- **Message**: The content that was signed
68+
- **Nonce**: A random value used during signature generation
69+
70+
## Examples
71+
72+
See the test file for examples of creating and decoding Sigma signatures.
73+
74+
## Reference
75+
76+
This implementation is based on the [Sigma protocol specification](https://github.com/BitcoinSchema/go-sigma) and is compatible with the JavaScript Sigma Library.

0 commit comments

Comments
 (0)