| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- newtype Account = Account {}
- pay :: AsTokenAccountError e => Account -> Value -> Contract w s e CardanoTx
- redeem :: AsTokenAccountError e => CardanoAddress -> Account -> Contract w s e CardanoTx
- newAccount :: forall w s e. AsTokenAccountError e => TokenName -> CardanoAddress -> Contract w s e Account
- balance :: AsTokenAccountError e => Account -> Contract w s e Value
- address :: Account -> CardanoAddress
- accountToken :: Account -> Value
- payTx :: Value -> TxConstraints (RedeemerType TokenAccount) (DatumType TokenAccount)
- redeemTx :: forall w s e. AsTokenAccountError e => Account -> CardanoAddress -> Contract w s e (TxConstraints () (), ScriptLookups TokenAccount)
- type TokenAccountSchema = (Endpoint "redeem" (Account, CardanoAddress) .\/ Endpoint "pay" (Account, Value)) .\/ Endpoint "new-account" (TokenName, CardanoAddress)
- type HasTokenAccountSchema s = (HasEndpoint "redeem" (Account, CardanoAddress) s, HasEndpoint "pay" (Account, Value) s, HasEndpoint "new-account" (TokenName, CardanoAddress) s)
- tokenAccountContract :: forall w s e. (HasTokenAccountSchema s, AsTokenAccountError e) => Contract w s e ()
- data TokenAccount
- data TokenAccountError
- class AsTokenAccountError r where
- validatorHash :: Account -> ValidatorHash
- typedValidator :: Account -> TypedValidator TokenAccount
Documentation
Constructors
| Account | |
Fields | |
Instances
Contract functionality
pay :: AsTokenAccountError e => Account -> Value -> Contract w s e CardanoTx Source #
Pay some money to the given token account
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.
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 #
accountToken :: Account -> Value 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
| ValidatorTypes TokenAccount Source # | |
Defined in Plutus.Contracts.TokenAccount | |
| type RedeemerType TokenAccount Source # | |
Defined in Plutus.Contracts.TokenAccount | |
| type DatumType TokenAccount Source # | |
Defined in Plutus.Contracts.TokenAccount | |
data TokenAccountError Source #
Constructors
| TAContractError ContractError | |
| TACurrencyError CurrencyError |
Instances
class AsTokenAccountError r where Source #
Minimal complete definition
Methods
_TokenAccountError :: Prism' r TokenAccountError Source #
Instances
validatorHash :: Account -> ValidatorHash Source #