apollo

package module
v0.0.0-...-ec97d81 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 37 Imported by: 0

README

Apollo: Pure Golang Cardano Building blocks

NOTE: This is a fork of the excellent library built by Edoardo Salvioni; Given the sensitivity of building transactions, we maintain our own fork to reduce the risk of a supply chain attack.

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/SundaeSwap-finance/apollo"
    "github.com/SundaeSwap-finance/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
)

Variables

This section is empty.

Functions

func NewBlockfrostBackend

func NewBlockfrostBackend(
	projectId string,
	network constants.Network,

) BlockFrostChainContext.BlockFrostChainContext

func SortInputs

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

func SortUtxos

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

Types

type Apollo

type Apollo struct {
	Context Base.ChainContext

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

func New

func New(cc Base.ChainContext) *Apollo

func (*Apollo) AddDatum

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

func (*Apollo) AddInput

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

func (*Apollo) AddInputAddress

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

func (*Apollo) AddInputAddressFromBech32

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

func (*Apollo) AddLoadedUTxOs

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

func (*Apollo) AddPayment

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

func (*Apollo) AddReferenceInput

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

func (*Apollo) AddRequiredSigner

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

func (*Apollo) AddRequiredSignerFromAddress

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

func (*Apollo) AddRequiredSignerFromBech32

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

func (*Apollo) AddVerificationKeyWitness

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

func (*Apollo) AddWithdrawal

func (b *Apollo) AddWithdrawal(address Address.Address, amount int, redeemerData PlutusData.PlutusData) *Apollo

func (*Apollo) AttachDatum

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

func (*Apollo) AttachV1Script

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

func (*Apollo) AttachV2Script

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

func (*Apollo) Clone

func (b *Apollo) Clone() *Apollo

func (*Apollo) CollectFrom

func (b *Apollo) CollectFrom(
	inputUtxo UTxO.UTxO,
	redeemerData PlutusData.PlutusData,
) *Apollo

func (*Apollo) Complete

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

func (*Apollo) ConsumeAssetsFromUtxo

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

func (*Apollo) ConsumeUTxO

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

func (*Apollo) DisableExecutionUnitsEstimation

func (b *Apollo) DisableExecutionUnitsEstimation() *Apollo

func (*Apollo) GetBurns

func (b *Apollo) GetBurns() (burns Value.Value)

func (*Apollo) GetTx

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

func (*Apollo) GetUsedUTxOs

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

func (*Apollo) GetWallet

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

func (*Apollo) LoadTxCbor

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

func (*Apollo) MintAssets

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

func (*Apollo) MintAssetsWithRedeemer

func (b *Apollo) MintAssetsWithRedeemer(mintUnit Unit, redeemerData PlutusData.PlutusData) *Apollo

func (*Apollo) PayToAddress

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

func (*Apollo) PayToAddressBech32

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

func (*Apollo) PayToContract

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

func (*Apollo) SetChangeAddress

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

func (*Apollo) SetChangeAddressBech32

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

func (*Apollo) SetEstimationExUnitsRequired

func (b *Apollo) SetEstimationExUnitsRequired() *Apollo

func (*Apollo) SetFeePadding

func (b *Apollo) SetFeePadding(padding int64) *Apollo

func (*Apollo) SetShelleyMetadata

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

func (*Apollo) SetTtl

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

func (*Apollo) SetValidityStart

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

func (*Apollo) SetWalletAsChangeAddress

func (b *Apollo) SetWalletAsChangeAddress() *Apollo

func (*Apollo) SetWalletFromBech32

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

func (*Apollo) SetWalletFromKeypair

func (a *Apollo) SetWalletFromKeypair(vkey string, skey string, network constants.Network) *Apollo

For use with key pairs generated by cardano-cli

func (*Apollo) SetWalletFromMnemonic

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

func (*Apollo) Sign

func (b *Apollo) Sign() *Apollo

func (*Apollo) SignWithSkey

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

func (*Apollo) Submit

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

func (*Apollo) UtxoFromRef

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

type Payment

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

func NewPayment

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

func NewPaymentFromValue

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

func PaymentFromTxOut

func PaymentFromTxOut(txOut *TransactionOutput.TransactionOutput) *Payment

func (*Payment) EnsureMinUTXO

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

func (*Payment) ToTxOut

func (*Payment) ToValue

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

type PaymentI

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

type Unit

type Unit struct {
	PolicyId string
	Name     string
	Quantity int
}

func NewUnit

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

func (*Unit) ToValue

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

Jump to

Keyboard shortcuts

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