plutus-use-cases-1.2.0.0: Collection of smart contracts to develop the plutus/wallet interface
Safe HaskellNone
LanguageHaskell2010

Plutus.Contracts.TokenAccount

Description

Plutus implementation of an account that can be unlocked with a token. Whoever owns the token can spend the outputs locked by the contract. (A suitable token can be created with the Currency contract, or with newAccount in this module)

Synopsis

Documentation

newtype Account Source #

Constructors

Account 

Fields

Instances

Instances details
Eq Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Show Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Generic Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Associated Types

type Rep Account :: Type -> Type Source #

FromJSON Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

parseJSON :: Value -> Parser Account

parseJSONList :: Value -> Parser [Account]

ToJSON Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

toJSON :: Account -> Value

toEncoding :: Account -> Encoding

toJSONList :: [Account] -> Value

toEncodingList :: [Account] -> Encoding

ToData Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

toBuiltinData :: Account -> BuiltinData

FromData Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

fromBuiltinData :: BuiltinData -> Maybe Account

Pretty Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

pretty :: Account -> Doc ann

prettyList :: [Account] -> Doc ann

UnsafeFromData Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

unsafeFromBuiltinData :: BuiltinData -> Account

Lift DefaultUni Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

lift :: Account -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ())

Typeable DefaultUni Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

typeRep :: Proxy Account -> RTCompile DefaultUni fun (Type TyName DefaultUni ())

type Rep Account Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

type Rep Account = D1 ('MetaData "Account" "Plutus.Contracts.TokenAccount" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'True) (C1 ('MetaCons "Account" 'PrefixI 'True) (S1 ('MetaSel ('Just "accountOwner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AssetClass)))

Contract functionality

pay :: AsTokenAccountError e => Account -> Value -> Contract w s e CardanoTx Source #

Pay some money to the given token account

redeem Source #

Arguments

:: AsTokenAccountError e 
=> CardanoAddress

Where the token should go after the transaction

-> Account

The token account

-> Contract w s e CardanoTx 

Empty the account by spending all outputs belonging to the Account.

newAccount Source #

Arguments

:: forall w s e. AsTokenAccountError e 
=> TokenName

Name of the token

-> CardanoAddress

Address of the token's initial owner

-> Contract w s e Account 

Create a new token and return its Account information.

balance :: AsTokenAccountError e => Account -> Contract w s e Value Source #

balance account returns the value of all unspent outputs that can be unlocked with accountToken account

address :: Account -> CardanoAddress Source #

payTx :: Value -> TxConstraints (RedeemerType TokenAccount) (DatumType TokenAccount) Source #

A transaction that pays the given value to the account

redeemTx :: forall w s e. AsTokenAccountError e => Account -> CardanoAddress -> Contract w s e (TxConstraints () (), ScriptLookups TokenAccount) Source #

Create a transaction that spends all outputs belonging to the Account.

Endpoints

type TokenAccountSchema = (Endpoint "redeem" (Account, CardanoAddress) .\/ Endpoint "pay" (Account, Value)) .\/ Endpoint "new-account" (TokenName, CardanoAddress) Source #

type HasTokenAccountSchema s = (HasEndpoint "redeem" (Account, CardanoAddress) s, HasEndpoint "pay" (Account, Value) s, HasEndpoint "new-account" (TokenName, CardanoAddress) s) Source #

tokenAccountContract :: forall w s e. (HasTokenAccountSchema s, AsTokenAccountError e) => Contract w s e () Source #

redeem, pay and newAccount with endpoints.

Etc.

data TokenAccount Source #

Instances

Instances details
ValidatorTypes TokenAccount Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Associated Types

type RedeemerType TokenAccount

type DatumType TokenAccount

type DatumType TokenAccount Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

type DatumType TokenAccount = ()
type RedeemerType TokenAccount Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

type RedeemerType TokenAccount = ()

data TokenAccountError Source #

Constructors

TAContractError ContractError 
TACurrencyError CurrencyError 

Instances

Instances details
Eq TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Show TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Generic TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Associated Types

type Rep TokenAccountError :: Type -> Type Source #

FromJSON TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

parseJSON :: Value -> Parser TokenAccountError

parseJSONList :: Value -> Parser [TokenAccountError]

ToJSON TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

AsContractError TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

Methods

_ContractError :: Prism' TokenAccountError ContractError

_WalletContractError :: Prism' TokenAccountError WalletAPIError

_ChainIndexContractError :: Prism' TokenAccountError (Text, ChainIndexResponse)

_ConstraintResolutionContractError :: Prism' TokenAccountError MkTxError

_ToCardanoConvertContractError :: Prism' TokenAccountError ToCardanoError

_ResumableContractError :: Prism' TokenAccountError MatchingError

_CCheckpointContractError :: Prism' TokenAccountError CheckpointError

_EndpointDecodeContractError :: Prism' TokenAccountError (EndpointDescription, EndpointValue Value, Text)

_OtherContractError :: Prism' TokenAccountError Text

AsCurrencyError TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

AsTokenAccountError TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

type Rep TokenAccountError Source # 
Instance details

Defined in Plutus.Contracts.TokenAccount

type Rep TokenAccountError = D1 ('MetaData "TokenAccountError" "Plutus.Contracts.TokenAccount" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "TAContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractError)) :+: C1 ('MetaCons "TACurrencyError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CurrencyError)))

validatorHash :: Account -> ValidatorHash Source #