Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fivebinaries/go-cardano-serialization
Golang library for serialization & deserialization of Cardano data structures.
https://github.com/fivebinaries/go-cardano-serialization
cardano go golang protocol serialization
Last synced: 2 months ago
JSON representation
Golang library for serialization & deserialization of Cardano data structures.
- Host: GitHub
- URL: https://github.com/fivebinaries/go-cardano-serialization
- Owner: fivebinaries
- License: apache-2.0
- Created: 2021-04-01T18:00:34.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-04T02:10:20.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T17:08:59.524Z (6 months ago)
- Topics: cardano, go, golang, protocol, serialization
- Language: Go
- Homepage:
- Size: 267 KB
- Stars: 28
- Watchers: 5
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Cardano Serialization Library
[![GoDoc](https://godoc.org/github.com/fivebinaries/go-cardano-serialization?status.svg)](https://godoc.org/github.com/fivebinaries/go-cardano-serialization)Golang library for serialization and deserialiation of Cardano data structures.
## Installation
```bash
go get github.com/fivebinaries/go-cardano-serialization
```## Usage
### Creating a simple transactionThe simplest transaction on Cardano network contains inputs(Unspent Transaction Outputs) and output.
```golang
package mainimport (
"log""github.com/fivebinaries/go-cardano-serialization/address"
"github.com/fivebinaries/go-cardano-serialization/tx"
)func main() {
adaTx := tx.NewTx()
adaTx.AddInput(
tx.NewInput(
"TX_HASH", // Transaction Hash
0, // Transaction Index
10000000 // Lovelace value of UTXO
)
)receiverAddr, err := address.NewAddress("addr1bech32_receiver_address_here")
if err != nil {
log.Fatal(err)
}adaTx.AddOutput(
tx.NewOutput(
receiverAddr,
5000000
)
)// Set an estimated transaction cost
adaTx.SetFee(170000)// Set the transaction's time to live
adaTx.SetTTL(505050505)// Encode example transaction to cbor hex.
fmt.Println(adaTx.Hex())
}
```More examples covering building through signing and submission of transactions can be found in the [`examples`](./examples/) folder.
## License
Licensed under the [Apache License 2.0](https://opensource.org/licenses/Apache-2.0), see [`LICENSE`](https://github.com/fivebinaries/go-cardano-serialization/blob/master/LICENSE)