Skip to content

Golang library for serialization & deserialization of Cardano data structures.

License

Notifications You must be signed in to change notification settings

fivebinaries/go-cardano-serialization

Repository files navigation


Go Cardano Serialization Library

GoDoc

Golang library for serialization and deserialiation of Cardano data structures.

Installation

go get github.com/fivebinaries/go-cardano-serialization

Usage

Creating a simple transaction

The simplest transaction on Cardano network contains inputs(Unspent Transaction Outputs) and output.

package main

import (
    "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 folder.

License

Licensed under the Apache License 2.0, see LICENSE

About

Golang library for serialization & deserialization of Cardano data structures.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages