logo
Formal Ledger Specification
Start
Initializing search
    GitHub
    • Home
    • Preliminaries
    • Core
    • Conway
    • Dijkstra
    • Appendix
    GitHub
    • Home
      • Guide for Contributors
      • Introduction
      • Properties
      • Notation
      • Introduction
        • Address
        • Crypto
        • Epoch
      • Introduction
        • Abstract
        • BlockBody
          • Properties
            • Computational
        • Certs
          • Properties
            • Computational
            • PoV
            • PoVLemmas
            • VoteDelegsVDeleg
        • Chain
          • Properties
            • Computational
            • CredDepsEqualDomRwds
            • EpochStep
            • GovDepsMatch
            • PParamsWellFormed
        • Enact
          • Properties
            • Computational
        • Epoch
          • Properties
            • Computational
            • ConstRwds
            • ExpiredDReps
            • GovDepsMatch
            • NoPropSameDReps
        • Fees
        • Gov
          • Base
          • Actions
          • Properties
            • Computational
            • ChangePPGroup
        • Ledger
          • Properties
            • Base
            • Computational
            • GovDepsMatch
            • PoV
        • PoolReap
            • Computational
        • PParams
        • Properties
        • Ratify
          • Properties
            • Computational
        • Rewards
            • Computational
        • RewardUpdate
          • Properties
            • Computational
        • Script
          • Base
          • ScriptPurpose
          • Timelock
          • Validation
          • Base
          • Coin
          • ValueSet
          • ValueVector
        • Transaction
        • Utxo
          • Properties
            • Base
            • Computational
            • GenMinspend
            • MinSpend
            • PoV
        • Utxow
          • Properties
            • Computational
          • GovStructure
      • Introduction
      • Abstract
      • Certs
        • Actions
        • Base
      • PParams
      • Script
        • Validation
      • TokenAlgebra
      • Transaction
        • Definitions
        • Essential Agda
          • Bootstrapping Governance
          • Bootstrapping EnactState
        • Prelude
        • Ledger
        • Ledger.Core
        • Ledger.Prelude
          • Base
            • HSTypes
            • Util
          • HasCoin
          • Instances
          • Numeric
            • PositiveNat
            • UnitInterval
          • STS
          • ComputationalRelation
          • TypeClasses
            • TypeClasses
            • HasSubset
            • HasSubtract
              • Instance
          • Convertible
            • Deriving
            • DerivingTest
          • HaskellTypes
            • Deriving
        • MyDebugOptions
          • Examples
            • HelloWorld
            • SucceedIfNumber
              • Datum
                • Cleanup
                • Close
                • Deposit
                • Lib
                • OffChain
                • Open
                • Start
                • Transfer
                • Withdraw
                • Trace
              • Validator
              • Datum
                • Close
                • Exchange
                • Lib
                • OffChain
                • Start
                • Update
                • Trace
              • Validator
              • Datum
                • AddSig
                • Lib
                • OffChain
                • Open
                • Pay
                • Propose
                • Trace
              • Validator
              • Datum
                • AddSig
                • Cancel
                • Cleanup
                • Lib
                • OffChain
                • Open
                • Pay
                • Propose
                • Trace
              • Validator
          • AbstractImplementation
          • LedgerImplementation
          • Lib
          • Prelude
          • SymbolicData
          • Ledger.Dijkstra
          • Ledger.PreConway
              • NewPP
                • Properties
              • PPUp
                • Properties
            • NewPP
              • Properties
            • PPUp
              • Properties
          • Ledger.Conway
            • ExternalFunctions
            • HSLedger
              • Address
              • BaseTypes
              • Cert
              • Certs
              • Chain
              • Core
              • Enact
              • Epoch
              • ExternalStructures
              • Gov
                • Core
                • Actions
              • Ledger
              • NewEpoch
              • PParams
              • Ratify
              • Rewards
              • Transaction
              • Utxo
          • Conformance
            • Certs
              • Properties
            • Chain
              • Properties
            • Epoch
              • Properties
            • Equivalence
              • Bisimilarity
              • Certs
              • Convert
              • Deposits
              • Map
              • Utxo
            • Gov
            • Ledger
              • Properties
            • Properties
            • Rewards
            • Script
            • Utxo
              • Properties
            • Utxow
              • Properties

    Start

    {-# OPTIONS --safe #-}
    
    module Test.Examples.AccountSim.OffChain.Start where
    
    open import Ledger.Prelude
    open import Ledger.Conway.Specification.Transaction using (TransactionStructure)
    
    open import Test.Examples.AccountSim.Datum
    open import Test.Examples.AccountSim.OffChain.Lib
    open import Test.Examples.AccountSim.Validator
    open import Test.Prelude AccountSimData
    open import Test.SymbolicData AccountSimData
    open import Test.LedgerImplementation SData SData
    open import Test.Lib valContext
    
    open TransactionStructure SVTransactionStructure
    open Implementation
    
    startTxOut : Value → PlutusScript → TxOut
    startTxOut v script = inj₁ (record { net = 0 ;
                               pay = ScriptObj (proj₁ script) ;
                               stake = just (ScriptObj (proj₁ script)) })
                               , v
                               , just (inj₁ (inj₁ (inj₁ (Always [])))) , nothing
    
    -- txid, wallet, value at script, script index
    startTx : (id w tw : ℕ) → (v : Value) → PlutusScript → Tx
    startTx id w tw v script = record { body = record defaultTxBody
                             { txIns = Ledger.Prelude.fromList ((w , w) ∷ [])
                             ; txOuts = fromListIx ((tw , startTxOut v script)
                                                   ∷ (w
                                                     , ((inj₁ (record { net = 0 ;
                                                                        pay = KeyHashObj w ;
                                                                        stake = just (KeyHashObj w) }))
                                                   , ((startValue - feeValue) - v) , nothing , nothing))
                                                   ∷ [])
                             ; txId = id
                             ; collateralInputs = Ledger.Prelude.fromList ((w , w) ∷ [])
                             } ;
                    wits = record { vkSigs = fromListᵐ ((w , (_+_ {{addNat}} w id)) ∷ []) ;
                                    scripts = ∅ ;
                                    txdats = ∅ ;
                                    txrdmrs = ∅ } ;
    
                    txsize = 10 ;
                    isValid = true ;
                    txAD = nothing }
    
    Previous
    Open
    Next
    Transfer
    Made with Material for MkDocs