apollo

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 35 Imported by: 0

README

Apollo: Pure Golang Cardano Building blocks

Pure Golang Cardano Serialization

The Objective of this library is to give Developers Access to each and every needed resource for cardano development. The final goal is to be able to have this library interact directly with the node without intermediaries.

Little Sample Usage:

package main

import (
    "encoding/hex"
    "fmt"

    "github.com/Salvionied/cbor/v2"
    "github.com/Salvionied/apollo"
    "github.com/Salvionied/apollo/txBuilding/Backend/BlockFrostChainContext"
)

func main() {
    bfc := BlockFrostChainContext.NewBlockfrostChainContext("blockfrost_api_key", int(apollo.MAINNET), apollo.BLOCKFROST_BASE_URL_MAINNET)
    cc := apollo.NewEmptyBackend()
    SEED := "your mnemonic here"
    apollob := apollo.New(&cc)
    apollob = apollob.
        SetWalletFromMnemonic(SEED).
        SetWalletAsChangeAddress()
    utxos := bfc.Utxos(*apollob.GetWallet().GetAddress())
    apollob, err := apollob.
        AddLoadedUTxOs(utxos).
        PayToAddressBech32("addr1qy99jvml0vafzdpy6lm6z52qrczjvs4k362gmr9v4hrrwgqk4xvegxwvtfsu5ck6s83h346nsgf6xu26dwzce9yvd8ysd2seyu", 1_000_000, nil).
        Complete()
    if err != nil {
        fmt.Println(err)
    }
    apollob = apollob.Sign()
    tx := apollob.GetTx()
    cborred, err := cbor.Marshal(tx)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(hex.EncodeToString(cborred))
    tx_id, _ := bfc.SubmitTx(*tx)

    fmt.Println(hex.EncodeToString(tx_id.Payload))

}

TODO:
  • Ledger

    • Byron Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Interfacing
      • Tests
    • Shelley Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Tests
    • ShelleyMary Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Tests
    • Allegra Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Tests
    • Alonzo Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Tests
    • Babbage Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Tests
    • Conway Support
      • Block
      • Transaction
      • TxOutputs
      • TxInputs
      • Serialization/deserialization
      • Tests
  • Serialization/Deserialization

    • Address
      • Enterprise Address
      • Staked Address
      • SC Address
      • Others...
    • Amount
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • Asset
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • AssetName
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • MultiAsset
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • Policy
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • Value
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • NativeScript
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • PlutusData
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • Redeemer
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
    • Keys
      • Serialization/Deserialization
      • Basic Functionality
      • Utility functions
      • Constructors
  • TxBuilding

    • Basic Tx Building
    • Basic Smart Contract Interaction
    • Advanced Smart Contract Interaction
    • Coin Selectors
      • LargestFirst
      • RandomImprove
      • Greedy
    • Utility Functions
    • Backends
      • Blockfrost
      • Ogmios + Kupo
      • DBSync
      • Carybdis
      • Koios

If you have any questions or requests feel free to drop into this discord and ask :) https://discord.gg/MH4CmJcg49

By: Edoardo Salvioni - Zhaata Tests By: Josh Marchand - JSHY

Documentation

Index

Constants

View Source
const (
	EX_MEMORY_BUFFER = 0.2
	EX_STEP_BUFFER   = 0.2
)
View Source
const BLOCKFROST_BASE_URL_MAINNET = "https://cardano-mainnet.blockfrost.io/api"
View Source
const BLOCKFROST_BASE_URL_PREPROD = "https://cardano-preprod.blockfrost.io/api"
View Source
const BLOCKFROST_BASE_URL_PREVIEW = "https://cardano-preview.blockfrost.io/api"
View Source
const BLOCKFROST_BASE_URL_TESTNET = "https://cardano-testnet.blockfrost.io/api"

Variables

View Source
var FAKE_SIGNATURE = []byte("577ccb5b487b64e396b0976c6f71558e52e44ad254db7d06dfb79843e5441a5d763dd42adcf5e8805d70373722ebbce62a58e3f30dd4560b9a898b8ceeab6a03")
View Source
var FAKE_VKEY = Key.VerificationKey{Payload: []byte("5797dc2cc919dfec0bb849551ebdf30d96e5cbe0f33f734a87fe826db30f7ef9")}

Functions

func NewBlockfrostBackend

func NewBlockfrostBackend(
	projectId string,
	network Network,

) (BlockFrostChainContext.BlockFrostChainContext, error)

func NewEmptyBackend added in v1.0.3

func NewEmptyBackend() FixedChainContext.FixedChainContext

func SortInputs added in v1.0.3

func SortInputs(inputs []UTxO.UTxO) []UTxO.UTxO

func SortUtxos added in v1.0.3

func SortUtxos(utxos []UTxO.UTxO) []UTxO.UTxO

Types

type Apollo

type Apollo struct {
	Context Base.ChainContext

	Fee           int64
	Ttl           int64
	ValidityStart int64
	// contains filtered or unexported fields
}

func New

func New(cc Base.ChainContext) *Apollo

func (*Apollo) AddDatum added in v1.0.3

func (b *Apollo) AddDatum(pd *PlutusData.PlutusData) *Apollo

func (*Apollo) AddInput added in v1.0.3

func (b *Apollo) AddInput(utxos ...UTxO.UTxO) *Apollo

func (*Apollo) AddInputAddress added in v1.0.3

func (b *Apollo) AddInputAddress(address Address.Address) *Apollo

func (*Apollo) AddInputAddressFromBech32 added in v1.0.3

func (b *Apollo) AddInputAddressFromBech32(address string) *Apollo

func (*Apollo) AddLoadedUTxOs added in v1.0.3

func (b *Apollo) AddLoadedUTxOs(utxos ...UTxO.UTxO) *Apollo

func (*Apollo) AddPayment added in v1.0.3

func (b *Apollo) AddPayment(payment PaymentI) *Apollo

func (*Apollo) AddReferenceInput added in v1.0.3

func (b *Apollo) AddReferenceInput(txHash string, index int) *Apollo

func (*Apollo) AddRequiredSigner added in v1.0.3

func (b *Apollo) AddRequiredSigner(pkh serialization.PubKeyHash) *Apollo

func (*Apollo) AddRequiredSignerFromAddress added in v1.0.3

func (b *Apollo) AddRequiredSignerFromAddress(address Address.Address, addPaymentPart, addStakingPart bool) *Apollo

func (*Apollo) AddRequiredSignerFromBech32 added in v1.0.3

func (b *Apollo) AddRequiredSignerFromBech32(address string, addPaymentPart, addStakingPart bool) *Apollo

func (*Apollo) AddVerificationKeyWitness added in v1.0.3

func (b *Apollo) AddVerificationKeyWitness(vkw VerificationKeyWitness.VerificationKeyWitness) *Apollo

func (*Apollo) AttachDatum added in v1.0.3

func (b *Apollo) AttachDatum(datum *PlutusData.PlutusData) *Apollo

func (*Apollo) AttachV1Script added in v1.0.3

func (b *Apollo) AttachV1Script(script PlutusData.PlutusV1Script) *Apollo

func (*Apollo) AttachV2Script added in v1.0.3

func (b *Apollo) AttachV2Script(script PlutusData.PlutusV2Script) *Apollo

func (*Apollo) Clone added in v1.0.3

func (b *Apollo) Clone() *Apollo

func (*Apollo) CollectFrom added in v1.0.3

func (b *Apollo) CollectFrom(
	inputUtxo UTxO.UTxO,
	redeemer Redeemer.Redeemer,
) *Apollo

func (*Apollo) Complete added in v1.0.3

func (b *Apollo) Complete() (*Apollo, error)

func (*Apollo) ConsumeAssetsFromUtxo added in v1.0.3

func (b *Apollo) ConsumeAssetsFromUtxo(utxo UTxO.UTxO, payments ...PaymentI) *Apollo

func (*Apollo) ConsumeUTxO added in v1.0.3

func (b *Apollo) ConsumeUTxO(utxo UTxO.UTxO, payments ...PaymentI) *Apollo

func (*Apollo) DisableExecutionUnitsEstimation added in v1.0.3

func (b *Apollo) DisableExecutionUnitsEstimation() *Apollo

func (*Apollo) GetTx added in v1.0.3

func (b *Apollo) GetTx() *Transaction.Transaction

func (*Apollo) GetUsedUTxOs added in v1.0.3

func (b *Apollo) GetUsedUTxOs() []string

func (*Apollo) GetWallet added in v1.0.3

func (b *Apollo) GetWallet() apollotypes.Wallet

func (*Apollo) LoadTxCbor added in v1.0.3

func (b *Apollo) LoadTxCbor(txCbor string) (*Apollo, error)

func (*Apollo) MintAssets added in v1.0.3

func (b *Apollo) MintAssets(mintUnit Unit) *Apollo

func (*Apollo) MintAssetsWithRedeemer added in v1.0.3

func (b *Apollo) MintAssetsWithRedeemer(mintUnit Unit, redeemer Redeemer.Redeemer) *Apollo

func (*Apollo) PayToAddress added in v1.0.3

func (b *Apollo) PayToAddress(address Address.Address, lovelace int, units ...Unit) *Apollo

func (*Apollo) PayToAddressBech32 added in v1.0.3

func (b *Apollo) PayToAddressBech32(address string, lovelace int, units ...Unit) *Apollo

func (*Apollo) PayToContract added in v1.0.3

func (b *Apollo) PayToContract(contractAddress Address.Address, pd *PlutusData.PlutusData, lovelace int, isInline bool, units ...Unit) *Apollo

func (*Apollo) SetChangeAddress added in v1.0.3

func (b *Apollo) SetChangeAddress(address Address.Address) *Apollo

func (*Apollo) SetChangeAddressBech32 added in v1.0.3

func (b *Apollo) SetChangeAddressBech32(address string) *Apollo

func (*Apollo) SetEstimationExUnitsRequired added in v1.0.3

func (b *Apollo) SetEstimationExUnitsRequired() *Apollo

func (*Apollo) SetShelleyMetadata added in v1.0.3

func (b *Apollo) SetShelleyMetadata(metadata Metadata.ShelleyMaryMetadata) *Apollo

func (*Apollo) SetTtl added in v1.0.3

func (b *Apollo) SetTtl(ttl int64) *Apollo

func (*Apollo) SetValidityStart added in v1.0.3

func (b *Apollo) SetValidityStart(invalidBefore int64) *Apollo

func (*Apollo) SetWalletAsChangeAddress added in v1.0.3

func (b *Apollo) SetWalletAsChangeAddress() *Apollo

func (*Apollo) SetWalletFromBech32 added in v1.0.3

func (a *Apollo) SetWalletFromBech32(address string) *Apollo

func (*Apollo) SetWalletFromMnemonic

func (a *Apollo) SetWalletFromMnemonic(mnemonic string) (*Apollo, error)

func (*Apollo) Sign added in v1.0.3

func (b *Apollo) Sign() *Apollo

func (*Apollo) SignWithSkey added in v1.0.3

func (b *Apollo) SignWithSkey(vkey Key.VerificationKey, skey Key.SigningKey) (*Apollo, error)

func (*Apollo) Submit added in v1.0.3

func (b *Apollo) Submit() (serialization.TransactionId, error)

func (*Apollo) UtxoFromRef added in v1.0.3

func (b *Apollo) UtxoFromRef(txHash string, txIndex int) *UTxO.UTxO

type Network

type Network int
const (
	MAINNET Network = iota
	TESTNET
	PREVIEW
	PREPROD
)

type Payment added in v1.0.3

type Payment struct {
	Lovelace  int
	Receiver  Address.Address
	Units     []Unit
	Datum     *PlutusData.PlutusData
	DatumHash []byte
	IsInline  bool
}

func NewPayment added in v1.0.3

func NewPayment(receiver string, lovelace int, units []Unit) *Payment

func NewPaymentFromValue added in v1.0.3

func NewPaymentFromValue(receiver Address.Address, value Value.Value) *Payment

func PaymentFromTxOut added in v1.0.3

func PaymentFromTxOut(txOut *TransactionOutput.TransactionOutput) *Payment

func (*Payment) EnsureMinUTXO added in v1.0.3

func (p *Payment) EnsureMinUTXO(cc Base.ChainContext)

func (*Payment) ToTxOut added in v1.0.3

func (*Payment) ToValue added in v1.0.3

func (p *Payment) ToValue() Value.Value

type PaymentI added in v1.0.3

type PaymentI interface {
	EnsureMinUTXO(cc Base.ChainContext)
	ToTxOut() *TransactionOutput.TransactionOutput
	ToValue() Value.Value
}

type Unit added in v1.0.3

type Unit struct {
	PolicyId string
	Name     string
	Quantity int
}

func NewUnit added in v1.0.3

func NewUnit(policyId string, name string, quantity int) Unit

func (*Unit) ToValue added in v1.0.3

func (u *Unit) ToValue() Value.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL