Show / Hide Table of Contents

Class Account

An internal implementation of IAccount.

Inheritance
Object
Account
Implements
IAccount
IAccountState
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Action.State
Assembly: Libplanet.Action.dll
Syntax
[Pure]
public class Account : IAccount, IAccountState

Constructors

| Improve this Doc View Source

Account(IAccountState, IAccountDelta)

An internal implementation of IAccount.

Declaration
public Account(IAccountState baseState, IAccountDelta delta)
Parameters
Type Name Description
IAccountState baseState
IAccountDelta delta
| Improve this Doc View Source

Account(IAccountState)

An internal implementation of IAccount.

Declaration
public Account(IAccountState baseState)
Parameters
Type Name Description
IAccountState baseState

Properties

| Improve this Doc View Source

Delta

The IAccountDelta representing the delta part of this IAccount.

Declaration
public IAccountDelta Delta { get; }
Property Value
Type Description
IAccountDelta
| Improve this Doc View Source

TotalUpdatedFungibleAssets

A set of Address and Currency pairs where each pair has its asoociated FungibleAssetValue changed since the previous Block's output states.

Declaration
public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets { get; }
Property Value
Type Description
IImmutableSet<(T1 Item1, T2 Item2)<Address, Currency>>
| Improve this Doc View Source

TotalUpdatedFungibles

An internal implementation of IAccount.

Declaration
public IImmutableDictionary<(Address, Currency), BigInteger> TotalUpdatedFungibles { get; }
Property Value
Type Description
IImmutableDictionary<(T1 Item1, T2 Item2)<Address, Currency>, BigInteger>
| Improve this Doc View Source

Trie

An internal implementation of IAccount.

Declaration
public ITrie Trie { get; }
Property Value
Type Description
ITrie

Methods

| Improve this Doc View Source

BurnAsset(IActionContext, Address, FungibleAssetValue)

Burns the fungible asset value (i.e., in-game monetary) from owner's balance.

Declaration
[Pure]
public IAccount BurnAsset(IActionContext context, Address owner, FungibleAssetValue value)
Parameters
Type Name Description
IActionContext context

The IActionContext of the IAction executing this method.

Address owner

The address who owns the fungible asset to burn.

FungibleAssetValue value

The fungible asset value to burn.

Returns
Type Description
IAccount

A new IAccount instance that the given value is subtracted from owner's balance.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when the value is less than or equal to zero.

CurrencyPermissionException

Thrown when a transaction signer (or a miner in case of block actions) is not a member of the Currency's Minters.

InsufficientBalanceException

Thrown when the owner has insufficient balance than value to burn.

| Improve this Doc View Source

GetBalance(Address, Currency)

Queries address's balance of the currency.

Declaration
[Pure]
public FungibleAssetValue GetBalance(Address address, Currency currency)
Parameters
Type Name Description
Address address

The owner address to query.

Currency currency

The currency type to query.

Returns
Type Description
FungibleAssetValue

The address's balance of the currency.

| Improve this Doc View Source

GetState(Address)

Gets the account state of the given address.

Declaration
[Pure]
public IValue GetState(Address address)
Parameters
Type Name Description
Address address

The Address referring the account to get its state.

Returns
Type Description
Bencodex.Types.IValue

The account state of the given address. If it has never been set to any state it returns null instead.

| Improve this Doc View Source

GetStates(IReadOnlyList<Address>)

Gets multiple account states associated with the specified addresses at once.

Declaration
[Pure]
public IReadOnlyList<IValue> GetStates(IReadOnlyList<Address> addresses)
Parameters
Type Name Description
IReadOnlyList<Address> addresses

The Addresses associated with states to get.

Returns
Type Description
IReadOnlyList<Bencodex.Types.IValue>

The states associated to the specified addresses. Associated values are ordered in the same way to the corresponding addresses. Absent states are represented as null.

| Improve this Doc View Source

GetTotalSupply(Currency)

Returns the total supply of a currency.

Declaration
[Pure]
public FungibleAssetValue GetTotalSupply(Currency currency)
Parameters
Type Name Description
Currency currency

The currency type to query.

Returns
Type Description
FungibleAssetValue

The total supply of the currency.

Exceptions
Type Condition
TotalSupplyNotTrackableException

Thrown when the total supply of the given currency is not trackable.

See Also
MaximumSupply
| Improve this Doc View Source

GetValidatorSet()

Returns the validator set.

Declaration
[Pure]
public ValidatorSet GetValidatorSet()
Returns
Type Description
ValidatorSet

The validator set of type ValidatorSet.

| Improve this Doc View Source

MintAsset(IActionContext, Address, FungibleAssetValue)

Mints the fungible asset value (i.e., in-game monetary), and give it to the recipient.

Declaration
[Pure]
public IAccount MintAsset(IActionContext context, Address recipient, FungibleAssetValue value)
Parameters
Type Name Description
IActionContext context

The IActionContext of the IAction executing this method.

Address recipient

The address who receives the minted asset.

FungibleAssetValue value

The asset value to mint.

Returns
Type Description
IAccount

A new IAccount instance that the given value is added to recipient's balance.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when the value is less than or equal to 0.

CurrencyPermissionException

Thrown when a transaction signer (or a miner in case of block actions) is not a member of the Currency's Minters.

SupplyOverflowException

Thrown when the sum of the value to be minted and the current total supply amount of the Currency exceeds the MaximumSupply.

| Improve this Doc View Source

SetState(Address, IValue)

Gets a new instance that the account state of the given address is set to the given state.

Declaration
[Pure]
public IAccount SetState(Address address, IValue state)
Parameters
Type Name Description
Address address

The Address referring the account to set its state.

Bencodex.Types.IValue state

The new state to fill the account with.

Returns
Type Description
IAccount

A new IAccount instance that the account state of the given address is set to the given state.

Remarks

This method method does not manipulate the instance, but returns a new IAccount instance with updated states instead.

| Improve this Doc View Source

SetValidator(Validator)

Sets validator to the stored ValidatorSet. If 0 is given as its power, removes the validator from the ValidatorSet.

Declaration
[Pure]
public IAccount SetValidator(Validator validator)
Parameters
Type Name Description
Validator validator

The Validator instance to write.

Returns
Type Description
IAccount

A new IAccount instance with validator set.

| Improve this Doc View Source

TransferAsset(IActionContext, Address, Address, FungibleAssetValue, Boolean)

Transfers the fungible asset value (i.e., in-game monetary) from the sender to the recipient.

Declaration
[Pure]
public IAccount TransferAsset(IActionContext context, Address sender, Address recipient, FungibleAssetValue value, bool allowNegativeBalance = false)
Parameters
Type Name Description
IActionContext context

The IActionContext of the IAction executing this method.

Address sender

The address who sends the fungible asset to the recipient.

Address recipient

The address who receives the fungible asset from the sender.

FungibleAssetValue value

The asset value to transfer.

Boolean allowNegativeBalance

Turn on to allow sender's balance less than zero. Turned off by default.

Returns
Type Description
IAccount

A new IAccount instance that the given value is subtracted from sender's balance and added to recipient's balance.

Remarks

The behavior is different depending on context's BlockProtocolVersion. There is a bug for version 0 where this may not act as intended. Such behavior is left intact for backward compatibility.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when the value is less than or equal to zero.

InsufficientBalanceException

Thrown when the sender has insufficient balance than value to transfer and the allowNegativeBalance option is turned off.

Implements

IAccount
IAccountState

Extension Methods

AccountExtensions.GetUpdatedStates(IAccount)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium