apollo

package module
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 37 Imported by: 0

README

apollo logo

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
)

Variables

This section is empty.

Functions

func NewBlockfrostBackend

func NewBlockfrostBackend(
	projectId string,
	network constants.Network,

) (BlockFrostChainContext.BlockFrostChainContext, error)

*

NewBlockfrostBackend creates a BlockFrostChainContext instance based
on the specified network and project ID.

Params:
	projectId (string): The project ID to authenticate with BlockFrost.
	network (Network): The network to configure the BlockFrost context for.

Returns:
	BlockFrostChainContext.BlockFrostChainContext: A BlockFrostChainContext instance configured for the specified network.

func NewEmptyBackend added in v1.0.3

func NewEmptyBackend() FixedChainContext.FixedChainContext

* NewEmptyBackend creates and returns an empty FixedChainContext instance, which is iused for cases where no specific backend context is required.

Returns:

FixedChainContext.FixedChainContext: An empty FixedChainContext instance.

func NewMaestroBackend added in v1.0.12

func NewMaestroBackend(
	projectId string,
	network constants.Network,
) (MaestroChainContext.MaestroChainContext, error)

NewMaestroBackend NewMaestroBackend creates a MaestroChainContext instance based on the specified network and project ID. Params: projectId (string): The project ID to authenticate with Maestro. network (Network): The network to configure the Maestro context for. Returns: MaestroChainContext.MaestroChainContext: A MaestroChainContext instance configured for the specified network.

func SortInputs added in v1.0.3

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

*

SortInputs sorts a slice of UTxO objects based on their strings.

Params:
	inputs ([]UTxO.UTxO): A slice of UTxO objects to be sorted.

Returns:
	[]UTxO.UTxO: A new slice of UTxO objects sorted based on input strings.

func SortUtxos added in v1.0.3

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

* SortUtxos sorts a slice of UTxO objects in descending order based on their amounts.

Params:

utxos ([]UTxO.UTxO): A slice of UTxO objects to be sorted.

Returns:

[]UTxO.UTxO: A new slice of UTxO objects sorted by descending amounts.

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

*

New creates and initializes a new Apollo instance with the specified chain context,
in which sets up various internal data structures for building and handling transactions.

Params:
	cc (Base.ChainContext): The chain context to use for transaction building.

Returns:
	*Apollo: A pointer to the initialized Apollo instance.

func (*Apollo) AddCollateral added in v1.0.5

func (b *Apollo) AddCollateral(utxo UTxO.UTxO) *Apollo

func (*Apollo) AddDatum added in v1.0.3

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

*

	AddDatum appends a Plutus datum to the list of data associated with the Apollo instance.

	Params:
   		pd (*PlutusData.PlutusData): The Plutus datum to be added.

	Returns:
   		*Apollo: A pointer to the modified Apollo instance with the datum added.

func (*Apollo) AddInput added in v1.0.3

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

*

AddInput appends one or more UTxOs to the list of preselected
UTxOs for transaction inputs.

Params:
	utxos (...UTxO.UTxO): A set of UTxOs to be added as inputs.

Returns:
	*Apollo: A pointer to the modified Apollo instance.

func (*Apollo) AddInputAddress added in v1.0.3

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

*

AddInputAddress appends an input address to the list of input addresses for the transaction.

Params:
	address (Address.Address): The input address to be added.

Returns:
	*Apollo: A pointer to the modified Apollo instance.

func (*Apollo) AddInputAddressFromBech32 added in v1.0.3

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

*

AddInputAddressFromBech32 decodes a Bech32 address and
appends it to the list of input addresses for the transaction.

Params:
	address (string): The Bech32 address to be decoded and added

Returns:
	*Apollo: A pointer to the modified Apollo instance.

func (*Apollo) AddLoadedUTxOs added in v1.0.3

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

*

AddLoadedUTxOs appends one or more UTxOs to the list of loaded UTxOs.

Params:
	utxos (...UTxO.UTxO): A set of UTxOs to be added to the loaded UTxOs.

Returns:
	*Apollo: A pointer to the modified Apollo instance.

func (*Apollo) AddPayment added in v1.0.3

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

*

AddPayment appends a payment to the list of payments for the transaction.

Params:
	payment (PaymentI): The payment to be added.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the payment added.

func (*Apollo) AddReferenceInput added in v1.0.3

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

*

AddReferenceInput adds a reference input to the transaction.

Params:
	txHash (string): The hexadecimal representation of the reference transaction hash.
	index (int): The index of the reference input within its transaction.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the added reference input.

func (*Apollo) AddRequiredSigner added in v1.0.3

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

*

	AddRequiredSigner appends a public key hash to the list of required signers.

 	Params:
   		pkh (serialization.PubKeyHash): The public key hash to add as a required signer.

 	Returns:
   		*Apollo: A pointer to the modified Apollo instance with the required signer added.

func (*Apollo) AddRequiredSignerFromAddress added in v1.0.3

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

*

	AddRequiredSignerFromAddress extracts the payment and staking parts from an address and adds them as required signers.

 	Params:
   		address (Address.Address): The address from which to extract the parts and add them as required signers.
   		addPaymentPart (bool): Indicates whether to add the payment part as a required signer.
   		addStakingPart (bool): Indicates whether to add the staking part as a required signer.

 	Returns:
   		*Apollo: A pointer to the modified Apollo instance with the required signers added.

func (*Apollo) AddRequiredSignerFromBech32 added in v1.0.3

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

*

	AddRequiredSignerFromBech32 decodes an address in Bech32 format and adds
	its payment and staking parts as required signers.

	Params:
   		address (string): The Bech32-encoded address to decode and add its parts as required signers.
	   	addPaymentPart (bool): Indicates whether to add the payment part as a required signer.
   		addStakingPart (bool): Indicates whether to add the staking part as a required signer.

	Returns:
	   	*Apollo: A pointer to the modified Apollo instance with the required signers added.

func (*Apollo) AddVerificationKeyWitness added in v1.0.3

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

*

AddVerificationKeyWitness adds a verification key witness to the transaction.

Params:
	vkw (VerificationKeyWitness.VerificationKeyWitness): The verification key witness to add.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the added verification key witness.

func (*Apollo) AddWithdrawal added in v1.0.5

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

func (*Apollo) AttachDatum added in v1.0.3

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

*

AttachDatum attaches a datum to the transaction.

Params:
	datum *PlutusData.PlutusData: The datum to attach.

Returns:
	*Apollo: A pointer to the Apollo object with the datum added.

func (*Apollo) AttachV1Script added in v1.0.3

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

*

Attach a Plutus V1 script to the Apollo transaction.

Params:
	script: The Plutus V1 script to attach.

Returns:
	*Apollo: A pointer to the Apollo objecy with the attached script.

func (*Apollo) AttachV2Script added in v1.0.3

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

*

Attach a Plutus V2 script to the Apollo transaction.

Params:
	script: The Plutus V2 script to attach.

Returns:
	*Apollo: A pointer to the Apollo objecy with the attached script.

func (*Apollo) Clone added in v1.0.3

func (b *Apollo) Clone() *Apollo

*

Clone creates a deep copy of the Apollo object.

Returns:
	*Apollo: A pointer to the cloned Apollo object.

func (*Apollo) CollectFrom added in v1.0.3

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

*

Collect a UTXO and its associated redeemer for inclusion in the transaction.

Params:
	inputUtxo: The UTXO to collect.
	redeemer: The redeemer associated with the UTXO.

Returns:
	*Apollo: A pointer to the Apollo object with the collected UTXO and redeemer.

func (*Apollo) Complete added in v1.0.3

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

*

Complete assembles and finalizes the Apollo transaction, handling
inputs, change, fees, collateral and witness data.

Returns:
	*Apollo: A pointer to the Apollo object representing the completed transaction.
	error: An error if any issues are encountered during the process.

func (*Apollo) CompleteExact added in v1.0.10

func (b *Apollo) CompleteExact(fee int) (*Apollo, error)

func (*Apollo) ConsumeAssetsFromUtxo added in v1.0.3

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

*

	ConsumeAssetsFromUtxo adds a UTxO as an input to the transaction and deducts the specified asset payments from it.

 	Params:
   		utxo (UTxO.UTxO): The UTxO to be consumed as an input.
   		payments (...PaymentI): Asset payments to be deducted from the UTxO.

 	Returns:
	   	*Apollo: A pointer to the modified Apollo instance.

func (*Apollo) ConsumeUTxO added in v1.0.3

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

*

ConsumeUTxO adds a UTxO as an input to the transaction and deducts the specified payments from it.

Params:
	utxo (UTxO.UTxO): The UTxO to be consumed as an input.
	payments (...PaymentI): A sett of payments to be deducted from the UTxO.

Returns:
	*Apollo: A pointer to the modified Apollo instance.

func (*Apollo) DisableExecutionUnitsEstimation added in v1.0.3

func (b *Apollo) DisableExecutionUnitsEstimation() *Apollo

*

	DisableExecutionUnitsEstimation disables the estimation of execution units for the transaction.

 	Returns:
	   	*Apollo: A pointer to the modified Apollo instance with execution units estimation disabled.

func (*Apollo) GetBurns added in v1.0.5

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

func (*Apollo) GetTx added in v1.0.3

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

*

GetTx returns the transaction associated with the Apollo object.

Returns:
	*Transacction.Transaction: A pointer to the transaction.

func (*Apollo) GetUsedUTxOs added in v1.0.3

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

*

GetUsedUTxOs returns the list of used UTxOs in the transaction.

Returns:
   []string: The list of used UTxOs as strings.

func (*Apollo) GetWallet added in v1.0.3

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

*

GetWallet returns the wallet associated with the Apollo instance.

Returns:
	apollotypes.Wallet: The wallet associated with the Apollo instance.

func (*Apollo) LoadTxCbor added in v1.0.3

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

*

LoadTxCbor loads a transaction from its CBOR representation and updates
the apollo instances.

Params:
	txCbor (string): The CBOR-encoded representation of the transaction.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the loaded transaction.
	error: An error, if any, encountered during loading.

func (*Apollo) MintAssets added in v1.0.3

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

*

MintAssets adds a minting unit to the transaction's minting set.

Params:
	mintUnit Unit: The minting unit to add.

Returns:
	*Apollo: A pointer to the Apollo object to support method chaining.

func (*Apollo) MintAssetsWithRedeemer added in v1.0.3

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

*

MintAssetsWithRedeemer adds a minting unit with an associated redeemer to the transaction's minting set.

Params:
	mintUnit Unit: The minting unit to add.
	redeemer Redeemer.Redeemer: The redeemer associated with the minting unit.

Returns:
	*Apollo: A pointer to the Apollo object with the minting unit added.

func (*Apollo) PayToAddress added in v1.0.3

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

*

	PayToAddress creates a payment to the specified address with the given lovelace and units,
	then adds it to the list of payment.

	Params:
		address (Address.Address): The recipient's address for the payment.
   		lovelace (int): The amount in lovelace to send in the payment.
   		units (...Unit): A set of units to include in the payment.

	Returns:
		*Apollo: A pointer to the modified Apollo instance with the payment added.

func (*Apollo) PayToAddressBech32 added in v1.0.3

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

*

PayToAddressBech32 creates a payment to the specified Bech32 address
with the given lovelace and units.

Params:
	address (string): The Bech32 address to which the payment will be made.
	lovelace (int): The amount in lovelace to be paid.
	units (...Unit): The units (assets) to be paid along with the lovelace.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the payment added.

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

*

	PayToContract creates a payment to a smart contract address and includes a Plutus datum, which
 	is added to the list of payments, and if a datum is provided, it is added to the data list.

	Params:
	contractAddress (Address.Address): The smart contract address to send the payment to.
	pd (*PlutusData.PlutusData): Plutus datum to include in the payment.
	lovelace (int): The amount in lovelace to send in the payment.
	isInline (bool): Indicates if the payment is inline with the datum.
	units (...Unit): A set of units to include in the payment.

	Returns:
		*Apollo: A pointer to the modified Apollo instance with the payment and datum added.

func (*Apollo) SetChangeAddress added in v1.0.3

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

*

	SetChangeAddress sets the change address for the transaction using an Address object.

 	Params:
	   	address (Address.Address): The Address object to set as the change address.

	Returns:
	   	*Apollo: A pointer to the modified Apollo instance with the change address set.

func (*Apollo) SetChangeAddressBech32 added in v1.0.3

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

*

	SetChangeAddressBech32 sets the change address for the transaction using a Bech32-encoded address.

	Params:
   		address (string): The Bech32-encoded address to set as the change address.

 	Returns:
   		*Apollo: A pointer to the modified Apollo instance with the change address set.

func (*Apollo) SetEstimationExUnitsRequired added in v1.0.3

func (b *Apollo) SetEstimationExUnitsRequired() *Apollo

*

	SetEstimationExUnitsRequired enables the estimation of execution units
	for the transaction.

	Returns:
   		*Apollo: A pointer to the modified Apollo instance with execution units estimation enabled.

func (*Apollo) SetFeePadding added in v1.0.5

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

func (*Apollo) SetShelleyMetadata added in v1.0.3

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

*

SetShelleyMetadata function sets the Shelley Mary metadata for the transaction's
auxiliary data.

Params:
	metadata (Metadata.ShelleyMaryMetadata): The Shelley Mary metadat to set.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the Shelley Mary metadata set.

func (*Apollo) SetTtl added in v1.0.3

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

*

SetTtl function sets the time-to-live (TTL) for the transaction.

Params:
	ttl (int64): The TTL value to set fro the transaction.

Returns:
	*Apollo: A pointer to the modified Apollo instance with the TTl set.

func (*Apollo) SetValidityStart added in v1.0.3

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

*

SetValidityStart function sets the validity start for the transaction.

Params:
	invalidBefore (int64): The validity start value to set for the transaction.

Returns:
   	*Apollo: A pointer to the modified Apollo instance with the validity start set.

func (*Apollo) SetWalletAsChangeAddress added in v1.0.3

func (b *Apollo) SetWalletAsChangeAddress() *Apollo

*

Set the wallet as the change address for the Apollo transaction.

Returns:
	*Apollo: A pointer to the Apollo object with the wallet set as the change address.

func (*Apollo) SetWalletFromBech32 added in v1.0.3

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

*

Set the wallet for the Apollo transaction using a Bech32 address.

Params:
	address: The Bech32 address to use as the wallet.

Returns:
	*Apollo: A pointer to the Apollo object with the wallet set.

func (*Apollo) SetWalletFromKeypair added in v1.0.5

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, error)

func (*Apollo) Sign added in v1.0.3

func (b *Apollo) Sign() *Apollo

*

Sign the Apollo transaction using the wallet's keys.

Returns:
	*Apollo: A pointer to the Apollo object with the transaction signed.

func (*Apollo) SignWithSkey added in v1.0.3

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

*

Sign the Apollo transaction with the given verification key and signing key.

Parameters:
	vkey: The verification key to sign with.
	skey: The signing key to sign with.

Returns:
	*Apollo: A pointer to the Apollo object with the transaction signed.
	error: An error if the signing fails.

func (*Apollo) Submit added in v1.0.3

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

*

Submit function submits the constructed transaction to the blockchain
network using the associated chain context.

Returns:
	serialization.TransactionId: The ID of the submitted transaction.
	error: An error, if any, encountered during transaction submission.

func (*Apollo) UtxoFromRef added in v1.0.3

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

*

	UtxoFromRef retrieves a UTxO (Unspent Transaction Output) given its transaction hash and index.

	Params:
   		txHash (string): The hexadecimal representation of the transaction hash.
   		txIndex (int): The index of the UTxO within the transaction's outputs.

 	Returns:
   		*UTxO.UTxO: A pointer to the retrieved UTxO, or nil if not found.

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

*

NewPayment creates a new Payment object.

Params:
	receiver (string): The receiver's address.
	lovelace (int): The amount in Lovelace.
	units ([]Unit): The assets units to be included.

Returns:
	*Payment: The newly created Payment object.

func NewPaymentFromValue added in v1.0.3

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

*

NewPaymentFromValue creates a new Payment object from an Address
and Value object.

Params:
	receiver (Address.Address): The receiver's address.
	value (Value.Value): The value object containing payment details.

Returns:
	*Payment: The newly created Payment object.

func PaymentFromTxOut added in v1.0.3

func PaymentFromTxOut(txOut *TransactionOutput.TransactionOutput) *Payment

*

PaymentFromTxOut creates a Payment object from a TransactionOutput.

Params:
	txOut (*TransactionOutput.TransactionOutput): The TransactionOutput to create the Payment.

Returns:
	*Payment: The created Payment object.

func (*Payment) EnsureMinUTXO added in v1.0.3

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

*

EnsureMinUTXO ensures that the payment amount meets the minimun UTXO requirement.

Params:
	cc (Base.ChainContext): The chain context.

func (*Payment) ToTxOut added in v1.0.3

*

	ToTxOut converts a Payment object to a TransactionOutput object.

	Returns:
   		*TransactionOutput.TransactionOutput: The created TransactionOutput object.

func (*Payment) ToValue added in v1.0.3

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

*

ToValue converts a Payment to a Value object.

Returns:
	Value.Value: The constructed Value object representing the payment.

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

*

NewUnit creates a new Unit with the provided information.

Params:
	policyId (string): The policy ID of the asset.
	name (string): The name of the asset.
	quantity (int): The quantity of the asset.

Returns:
	Unit: The newly created Unit instance.

func (*Unit) ToValue added in v1.0.3

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

*

ToValue converts a Unit to a Value object.

Returns:
	Value: The constructed Value object representing the asset.

Jump to

Keyboard shortcuts

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