Show / Hide Table of Contents

Interface IAccount

An interface to manipulate an account state with maintaining .

It is like a map which is virtually initialized such that every possible Address exists and is mapped to null. That means that:

  • it does not have length,
  • its index getter never throws KeyNotFoundException, but returns null instead, and
  • filling an Address with null state cannot be distinguished from the Address having never been set to any state.
Inherited Members
IAccountState.Trie
IAccountState.GetState(Address)
IAccountState.GetStates(IReadOnlyList<Address>)
IAccountState.GetBalance(Address, Currency)
IAccountState.GetTotalSupply(Currency)
IAccountState.GetValidatorSet()
Namespace: Libplanet.Action.State
Assembly: Libplanet.Action.dll
Syntax
public interface IAccount : IAccountState
Remarks

This interface is immutable. SetState(Address, IValue) method does not manipulate the instance, but returns a new IAccount instance with updated states.

Properties

| 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
[Pure]
IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets { get; }
Property Value
Type Description
IImmutableSet<(T1 Item1, T2 Item2)<Address, Currency>>
Remarks

This interface is immutable. SetState(Address, IValue) method does not manipulate the instance, but returns a new IAccount instance with updated states.

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]
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.

Remarks

This interface is immutable. SetState(Address, IValue) method does not manipulate the instance, but returns a new IAccount instance with updated states.

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

MintAsset(IActionContext, Address, FungibleAssetValue)

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

Declaration
[Pure]
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.

Remarks

This interface is immutable. SetState(Address, IValue) method does not manipulate the instance, but returns a new IAccount instance with updated states.

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

RemoveState(Address)

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

Declaration
[Pure]
IAccount RemoveState(Address address)
Parameters
Type Name Description
Address address

The Address referring the account to remove its state.

Returns
Type Description
IAccount

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

Remarks

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

| 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]
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]
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.

Remarks

This interface is immutable. SetState(Address, IValue) method does not manipulate the instance, but returns a new IAccount instance with updated states.

| 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]
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.

System.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.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium